FAQ Database Discussion Community


Why does GHCI get “stuck” in an error state after an error?

haskell,monads,io-monad
First of all, my apologies for the non-descriptive title. Since I have no idea what's actually going on I can't really make it any more specific. Now for my question. I have implemented the following snippet for problem 23 of the 99 Haskell problems, which should randomly select n items...

How do I map and concatenate FilePaths?

haskell,monads,io-monad
I'm still figuring out Haskell, especially the IO monad. I have a list of directory paths, e.g., ["/some/path", "/another/path", "/yet/another/path", "/still/more"] and I want to map this list into a list of fully-qualified contents of each of these paths (without . and ..), like this: ["/some/path/file.1", "/some/path/somedir", "/some/path/file.2", "/another/path/file.a", "/another/path/a/directory",...

Iterate over a list until the resulting list is an empty list

haskell,io-monad
I'm trying to see if I can do something like this: Say I have a list: [1, 8, 90, 100, 82] Now, what I would like to do is something like this print [8, 90, 100, 82] print [90, 100, 82] print [100, 82] print [82] So basically, I would...

Guess My Number, a monadic headache

haskell,state-monad,io-monad
To test my skills in Haskell, I decided I wanted to implement the very first game you find in Land of Lisp / Realm of Racket. The "Guess My Number" game. The game relies on mutable state to run, as it constantly has to update upper and lower bounds for...

Refactor an IO recursive loop into a monad folding in Haskell

sockets,haskell,network-programming,io-monad
I writing a tcp server, and here's my main loop method: serverLoop :: Socket -> IO () serverLoop sock = do (conn, _) <- accept sock forkIO $ handleConn conn serverLoop sock (Note: handleConn :: Socket -> IO () is a function specific to my program.) I would like to...