monads

Can anyone explain Monads?

I think I understand what 'Maybe Monads' are, but I'm not sure about the other types....

How can I learn about parser combinators?

I've found a few resources on the subject, but they all require a deep understanding of SmallTalk or Haskell, neither of which I know. ...

What is a monad?

Having briefly looked at Haskell recently I wondered whether anybody could give a brief, succinct, practical explanation as to what a monad essentially is? I have found most explanations I've come across to be fairly inaccessible and lacking in practical detail, so could somebody here help me? ...

What are monads?

everyone keeps talking about monads and monadic style and Haskell. i can't find much information or tutorial on haskell monads. ...

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? ...

Restricting a monad to a type class

In Haskell, is there a way to restrict a monad M a so that a satisfy a type class constraint? I am translating the probabilistic modeling example from F# to Haskell. However, in Haskell, I omitted support because it would change data Distribution a to data (Ord a) => Distribution a. With this change, I get the following error: ...proba...

Must a Language that Implements Monads be Statically Typed?

I am learning functional programming style. From this link http://channel9.msdn.com/shows/Going+Deep/Brian-Beckman-Dont-fear-the-Monads/, Brian Beckman gave a brilliant introduction about Monad. He mentioned that Monad is about composition of functions so as to address complexity. A Monad includes a unit function that transfers type...

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. ...

Are there any good examples on how to use Haskell monad functions?

Haskell monad functions are not easy to understand, where can I find usage examples? ...

Are continuations monads?

Can continuations be said to be monads? Are they a subset of monads or are they simply a way of implementing monads? Edit: Or maybe I got it wrong and monads is a more abstract concept than continuations? (So I'm really comparing apples to oranges here) ...

Haskell: How to pipe the contents of one handle into another in real time.

I am writing a program that runs an external sub process interactively and I need the contents of the output handle to be output to stdout as soon as it is available. I have tried something like this: main = do processInfo <- createProcess (proc "ghci" []){std_out = CreatePipe, std_in ...

Help a C# developer understand: What is a monad?

There is a lot of talk about monads these days. I have read a few articles / blog posts, but I can't go far enough with their examples to fully grasp the concept. The reason is that monads are a functional language concept, and thus the examples are in languages I haven't worked with (since I haven't used a functional language in depth)....

Computation Expression doesn't execute Let

I'm using F# v 1.9.6.2, and I've defined a very simple computation expression: type MaybeBuilder() = member this.Let(x, f) = printfn "this.Let: %A" x this.Bind(Some x, f) member this.Bind(x, f) = printfn "this.Bind: %A" x match x with | Some(x) when x >= 0 && x <= 100 -> f(x) | _ -...

What is the difference between a monad and a closure?

i am kinda confused reading the definition between the two. Can they actually intersect in terms of definition? or am i completely lost? Thanks. ...

What is the compelling scenario for using Monads in C#

Let me state up front that I have an infantile understanding of Monads. I have read the various threads on Monads here and have done a few hours of study on the concept. I hardly feel comfortable with the term, but I think it is safe to say that I generally understand what a Monad is/does. I'm a C# developer who is looking to improve th...

Error handling in Haskell with Either monad

I have a function that checks whether a type is a subtype of another type: st :: Monad m => Map String Type -- ^type environment -> Set (Type, Type) -- ^assumed subtypes -> (Type, Type) -- ^we are checking if lhs <: rhs -> m (Set (Type, Type)) I want to do error handling. I have the following definition: instance Mona...

How does 'get' actually /get/ the initial state in Haskell?

I have a function: test :: String -> State String String test x = get >>= \test -> let test' = x ++ test in put test' >> get >>= \test2 -> put (test2 ++ x) >> return "test" I can pretty much understand what goes on throughout this function, and I'm starting to get the hang of monads. What I don't understand is how...

scala Iterable#map vs. Iterable#flatMap

What is the difference between the map and flatMap functions of Iterable? ...

How can I initialize state in a hidden way in Haskell (like the PRNG does)?

Hi, I went through some tutorials on the State monad and I think I got the idea. For example, as in this nice tutorial: import Data.Word type LCGState = Word32 lcg :: LCGState -> (Integer, LCGState) lcg s0 = (output, s1) where s1 = 1103515245 * s0 + 12345 output = fromIntegral s1 * 2^16 `div` 2^32 getRandom :: State LCG...

How do I combine monads in Haskell?

Particularly, I need to be able to combine the CGI monad with the IO monad, but an example of how to combine the IO monad with the Maybe monad might be even better... ...