haskell

Haskell newbie: use layout or not? What are the pro's and con's (use examples)

I cant seem to find much info on haskells layout features, as I understand it is something like pythons formatting requirements except that is optional. How can I choose not to use this option correctly? Would it be a good idea to start without it so that I get a solid feel for the language itself? ...

Programming future web apps

For now I'm looking into languages like Haskell and Erlang just for the fun of it, but if I were to take bets, what would you suggest be the language of choice for programming the future web and why? ...

How do you make a generic memoize function in Haskell?

I've seen the other post about this, but is there a clean way of doing this in Haskell? As a 2nd part, can it also be done without making the function monadic? ...

Which Haskell package contains given module.

I know a Haskell module name, but I can't figure out in what package it is defined. This is bad because I can't compile without a package exposing this module. Specificaly it is Text.Regex that I can't locate, but I would like to know how to solve that problem in general. ...

Which language is better for general purpose programming, F# or Haskell?

I'm currently learning Haskell, Which language (F# or Haskell) do you prefer for programming general purpose applications? Which do you think is the stronger language? ...

How can I use functional programming in the real world?

Functional languages are good because they avoid bugs by eliminating state, but also because they can be easily parallelized automatically for you, without you having to worry about the thread count. As a Win32 developer though, can I use Haskell for some dlls of my application? And if I do, is there a real advantage that would be take...

Haskell Syntax case expression in a do block

I can't quite figure out this syntax problem with a case expression in a do block. What is the correct syntax? If you could correct my example and explain it that would be the best. Thanks module Main where main = do putStrLn "This is a test" s <- foo putStrLn s foo = do args <- getArgs return case ar...

Gaining a better understanding of functional programming

What would you recommend for an experienced OO programmer who wants to learn more about functional programming? Since reading Mark Dominus's Higher Order Perl, I've begun using more functional techniques in my day-to-day work, such as closures, currying, and lazy evaluation. However, Perl is of course not a purely functional language (...

Haskell FFI / C MPFR library wrapper woes

In order to create an arbitrary precision floating point / drop in replacement for Double, I'm trying to wrap MPFR using the FFI but despite all my efforts the simplest bit of code doesn't work. It compiles, it runs, but it crashes mockingly after pretending to work for a while. A simple C version of the code happily prints the number "1...

Where next, after Haskell?

I tend to have a stereotype of Haskell as the most "advanced" (high-level, sophisticated, powerful, abstract) language. One which has lots of weird features that, if I could grasp them, would make me a super-hero programmer. But what comes after Haskell? What languages and new kinds of abstraction are being invented now in academia whic...

Any Real-World Experience Using Software Transactional Memory?

It seems that there has been a recent rising interest in STM (software transactional memory) frameworks and language extensions. Clojure in particular has an excellent implementation which uses MVCC (multi-version concurrency control) rather than a rolling commit log. GHC Haskell also has an extremely elegant STM monad which also allow...

Hidden features of Haskell

What are the lesser-known but useful features of the Haskell programming language. (I understand the language itself is lesser-known, but work with me. Even explanations of the simple things in Haskell, like defining the Fibonacci sequence with one line of code, will get upvoted by me.) Try to limit answers to the Haskell core One fea...

Haskell: Inserting every line from a file into a list

I'm currently working on project with Haskell, and have found myself some trouble. I'm supposed to read and insert into a list each line in a "dictionary.txt" file, but I can't seem to do so. I've got this code: main = do let list = [] loadNums "dictionary.txt" list loadNums location list = do inh <- openFile location ReadM...

Seething over MSYS shell - is it replaceable?

I need a serviceable shell for MSYS. This is my current dilemma: The default rxvt.exe has a scroll bar and copy and paste, but doesn't send control characters or arrow keys to a running program in the shell (like interpreters/debuggers). This is a real thorn when using the Haskell interpreter ghci. The other shell sh.exe handles con...

How to view output .mp files from Functional MetaPost

I'm interested in using Functional MetaPost on Mac OS X: http://cryp.to/funcmp/ I'm looking for a tutorial like: http://haskell.org/haskellwiki/Haskell_in_5_steps but for a trivial FuncMP example, i.e. using GHC, I can compile something simple such as: import FMP myPicture = text "blah" main = generate "foo" 1 myPicture but I ...

implement zip using foldr

I'm currently on chapter 4 of Real World Haskell, and I'm trying to wrap my head around implementing foldl in terms of foldr. (Here's their code:) myFoldl :: (a -> b -> a) -> a -> [b] -> a myFoldl f z xs = foldr step id xs z where step x g a = g (f a x) I thought I'd try to implement zip using the same technique, but I don't see...

Pattern matching of lists in Python

I want to do some pattern matching on lists in Python. For example, in Haskell, I can do something like the following: fun (head : rest) = ... So when I pass in a list, head will be the first element, and rest will be the trailing elements. Likewise, in Python, I can automatically unpack tuples: (var1, var2) = func_that_returns_a_tu...

How would one share data between a parent and forked child process in Haskell?

How would I even go about forking a child process using Haskell in the first place? Also, if pipes are an obvious solution to the data sharing question - is there any other way to do it besides using pipes? I'm familiar with the use of shared memory segments in C (the shmget, *shmat, shmdt and shmctl functions). Could Haskell be able to...

Why is lazy evaluation useful?

I have long been wondering why lazy evaluation is useful. I have yet to have anyone explain to me in a way that makes sense; mostly it ends up boiling down to "trust me". Note: I do not mean memoization. ...

How can I increase the stack size with runhaskell?

I'm writing some disposable Haskell scripts to solve some of the Project Euler problems. I don't really want to have to compile them because of the number of changes I'm constantly having to make, but in a few cases I've found that I've run out of stack space. The documentation for runhaskell says that the following syntax should increa...