The tag has no wiki summary.

learn more… | top users | synonyms

5
votes
1answer
135 views

When we say a monad 'encapsulates a computation' - is this just saying 'wraps a functional transformation of data'?

When I think of the word 'computation' - my mind jumps to lambda calculus or operations on a state machine representing a CPU. It is quite a broad definition. Now some people talk about monads as ...
0
votes
1answer
328 views

When does a Monad become a hammer?

I realize my precursory understanding on Monads is severely lacking in detail considering my knowledge comes mostly from Douglas Crockford's Monads and Gonads talk and complicated with my sevear ...
1
vote
1answer
194 views

Picking a card from a shuffled deck

I'm pretty new to Haskell although I did some ML many moons ago. I'm trying to set up a deck of playing cards, shuffle them and then deal them. I have the deck and shuffle sorted (of a fashion) but ...
10
votes
2answers
621 views

Are monads a viable (maybe preferable) alternative to inheritance hierarchies?

I'm going to use a language-agnostic description of monads like this, first describing monoids: A monoid is (roughly) a set of functions that take some type as a parameter and return the same ...
1
vote
1answer
200 views

What is this programming style? “Monoid-ic”?

In a moderately old blog post, Conal Elliot makes an interesting (if less than serious) argument that C is a purely functional language, by drawing a parallel between the combination of the C ...
1
vote
2answers
228 views

Why does a monad use “return” or “unit” rather than “lift”?

This is partly genuine curiosity, and partly a check on my understanding. I'm probably missing the point. In Haskell, why does a monad use operations called return or unit to describe putting a type ...
3
votes
2answers
120 views

Why doesn't monad take `(M a -> M b)`?

All apologies -- I'm still very much on the outside of Haskell looking in. Why does the bind for a monad have this signature: M a -> (a -> M b) -> M b and not M a -> (M a -> M b) -> M b ...
2
votes
1answer
269 views

Is this a monad in Java? (part 2)

My first try was on stackoverflow. I'm picking up on the answer there to improve my monad: StackOverflow - Is this a monad in Java? My goal is to write an example of a monad. I'm not trying to solve ...
0
votes
1answer
226 views

Either Monad and Exceptional Circumstances [duplicate]

I have a function returning an Either such as GetUserFromDb(int id). If the database is offline, should I catch the error in the function and wrap it in a failure / Left case or should I let it ...
2
votes
1answer
134 views

Non-trivial functions that operate on any monad [closed]

I'm looking for examples of interesting methods that take an arbitrary monad and do something useful with it. Monads are extremely general, so methods that operate on monads are widely applicable. On ...
7
votes
1answer
879 views

Why is the Scala Option type not called Maybe, just as in Haskell?

Why is the Scala Option type not called Maybe, just as in Haskell? Maybe makes a lot more "semantic sense" to me, but maybe Option has different behaviour I am not aware of. Is there any particular ...
8
votes
1answer
385 views

Better to use error monad with validation in your monadic functions, or implement your own monad with validation directly in your bind?

I'm wondering what's better design wise for usability/maintainability, and what's better as far as fitting with the community. Given the data model: type Name = String data Amount = Out | Some | ...
7
votes
1answer
374 views

What monad is the opposite of the error monad in haskell

In the error monad, the first failure halts any execution further just carrying the fault through any following binds. What monad halts on success only carrying forward successes, and basically ...
8
votes
1answer
478 views

Futures/Monads vs Events

In an application framework when performance impact can be ignored (10-20 events per second at max), what is more maintainable and flexible to use as a preferred medium for communication between ...
40
votes
5answers
3k views

Critique of the IO monad being viewed as a state monad operating on the world

The IO monad in Haskell is often explained as a state monad where the state is the world. So a value of type IO a monad is viewed as something like worldState -> (a, worldState). Some time ago I ...
21
votes
3answers
2k views

Different ways to see a monad

While learning Haskell I have faced a lot of tutorials trying to explain what are monads and why monads are important in Haskell. Each of them used analogies so it would be easier to catch the ...
6
votes
1answer
486 views

How Does The Maybe Monad Relate To The Option Type?

I was doing a presentation on F# and was discussing the Option type when someone in the audience asked me if the Option type is F#'s implementation of the maybe monad. I know that's not the case but ...
9
votes
6answers
2k views

Maybe monad vs exceptions

I wonder what are the advantages of Maybe monad over exceptions? It looks like Maybe is just explicit (and rather space-consuming) way of try..catch syntax. update Please note that I'm intentionally ...
3
votes
2answers
501 views

are f# computational expressions a form of aspect oriented programming?

are monads, or more specifically f# computational expressions, a form of aspect oriented programming? Update: f# workflow builders have methods other than bind and unit. They have hooks for lots of ...
9
votes
6answers
1k views

As a practitioner, why should I care about Haskell? What is a monad and why do I need it? [closed]

I just do not get what problem they solve.