haskell

Any real world experience debugging a production functional program?

I'm interested in what tools and methods are used for diagnosing flaws in large scale functional programs. What tools are useful? My current understanding is that 'printf' debugging (e.g. add logging and redeploy) is what is typically used. If you've done debugging of a functional system what was different about it then debugging a ...

Haskell for a server?

With regards to making a game server, it seems Erlang always comes up as a language that is "built for this kind of thing" with its scalability and concurrency features. I don't have experience in either Haskell nor Erlang, but on the surface they seem the same. Looking into Haskell's docs it seems like it has support for multiprocessor ...

Saving graphs in Haskell

I can easily define a datatype for a node of a directed graph. data Node = Node String [Node] derving (Show, Read) I can save the graph to a file using show function, then restore it using read. However, show will not cope with a cycle. Is there a trivial way to save and restore a graph? ...

Visual Haskell 2008

Is Haskell for Visual Studio 2005 compatible with VS2008 SP1 ? ...

When should I use $ (and can it always be replaced with parentheses)?

From what I'm reading, $ is described as "applies a function to its arguments." However, it doesn't seem to work quite like (apply ...) in Lisp, because it's a binary operator, so really the only thing it looks like it does is help to avoid parentheses sometimes, like foo $ bar quux instead of foo (bar quux). Am I understanding it right?...

Mutual recursion -- can someone help explain how this code works?

I'm reading through "A Gentle Introduction to Haskell," and early on it uses this example, which works fine in GHC and horribly in my brain: initial = 0 next resp = resp process req = req+1 reqs = client initial resps resps = server reqs server (re...

Show a list of words repeated in haskell

I need to be able to write a function that shows repeated words from a string and return a list of strings in order of its occurrence and ignore non-letters e.g at hugs prompt repetitions :: String -> [String] repetitions > "My bag is is action packed packed." output> ["is","packed"] repetitions > "My name name name is Sean ." output...

exercise in haskell

hi i prepare myself for the exams and i am styding on previous past papers. could anybody give me a model answer to the following question,it would be very helpful to me to work through the answer! a) Show how to read a line using getLine and use putStrLn to write out the capitalized version of the line. (15%) b) Consider the followin...

Typed FP: Tuple Arguments and Curriable Arguments

In statically typed functional programming languages, like Standard ML, F#, OCaml and Haskell, a function will usually be written with the parameters separated from each other and from the function name simply by whitespace: let add a b = a + b The type here being "int -> (int -> int)", i.e. a function that takes an int and return...

How to handle this exception?

Haskell is givinig me a headache today. I want to handle an exception. When it gets to the top it prints like this: *** Exception: ../p/trip/Trip.hs:(88,16)-(89,50): Non-exhaustive patterns in function split To me it looks like it is PatternMatchFail, but this doesn't work: handle (\(PatternMatchFail _) -> return env) f I mean, it c...

Haskell parser error in where clause

What is wrong with rs definition in first where section? palindrome :: [a] -> [a] palindrome xs = con xs rs where con a b = rev (rev a []) b rs = rev xs -- here where rev [] rs = rs rev (x:xs) rs = rev xs (x:rs) I'm just learning haskell but its syntax rules confuse me. Error mes...

How does Haskell tail recursion work?

I wrote this snippet of code and I assume len is tail-recursive, but a stack overflow still occurs. What is wrong? myLength :: [a] -> Integer myLength xs = len xs 0 where len [] l = l len (x:xs) l = len xs (l+1) main = print $ myLength [1..10000000] ...

Creative uses of monads

I'm looking for creative uses of monads to learn from. I've read somewhere that monads have been used for example in AI, but being a monad newbie, I fail to see how. Please include a link to the source code and sample usages. No standard monads please. ...

Haskell: How to compose `not` with a function of arbitrary arity?

When I have some function of type like f :: (Ord a) => a -> a -> Bool f a b = a > b I should like make function which wrap this function with not. e.g. make function like this g :: (Ord a) => a -> a -> Bool g a b = not $ f a b I can make combinator like n f = (\a -> \b -> not $ f a b) But I don't know how. *Main> let n f = (\a...

is it possible to print all reductions in Haskell - using WinHugs?

I have written the following function.. and executed using WinHugs teneven = [x | x <- [1..10], even x] My output : Main> teneven [2,4,6,8,10] :: [Integer] (63 reductions, 102 cells) is there anyway to print all the reductions.. so I can learn the core evaluation happening inside WinHugs? ...

What's your naming convention for helper functions?

In functional programming, it's often important to optimize any "looping" code to be tail recursive. Tail recursive algorithms are usually split between two functions, however - one which sets up the base case, and another that implements the actual loop. A good (albeit academic) example would be the reverse function. reverse :: [a] -> ...

What would be a good functional language to pick up?

I come from a background of a large variety of languages but my only experience with functional programming languages was a brief stint with OCaml. I want to dive a lot deeper into one of these languages (Lisp/Scheme, Erlang, Scala, Haskell, etc.) but I want it to hopefully be one that is practical in working environments and also has a ...

Haskell REST/GDATA API library

Is there available REST api library for haskell? I need it primary for google gdata client, but will probably use it for other purposes too. I know there is HTTP library, but I need something more high level, which supports things like json encoding/decoding, etc... ...

Which is more efficient in Haskell; pattern matching or nested if/case statements?

I'm just curious about the efficiency of pattern matching in Haskell. What is a simple case of where pattern matching would be better than nested if/case statements and then the converse? Thanks for your help. ...

Ambiguous type variable error msg

I don't think it is a bug, but I am a bit puzzled as to why that doesn't work. A bonus question is why does it mention variable e? There is no variable e. Prelude> :m +Control.Exception Prelude Control.Exception> handle (\_-> return "err") undefined <interactive>:1:0: Ambiguous type variable `e' in the constraint: ...