The tag has no usage guidance.

learn more… | top users | synonyms

5
votes
2answers
129 views

Is the benefit of the IO monad pattern for handling side effects purely academic?

Sorry for yet another FP + side effects question, but I couldn't find an existing one which quite answered this for me. My (limited) understanding of functional programming is that state/side effects ...
3
votes
1answer
111 views

How to manage the state in a GUI app with Haskell

I am using wxHaskell to create a simple GUI that has typical components like Buttons, Panels, etc. When some of these components perform an action (like callback), the generic status of the ...
-1
votes
1answer
82 views

How is the UnitOfWork pattern related to Monadic programming?

Looking over the definition of the Unit of Work pattern it seems very much like what a programmer would get if they implemented a Monad such as an IO or Transaction Monad. What makes the unit of work ...
5
votes
1answer
142 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 ...
1
vote
1answer
474 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
268 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 ...
12
votes
2answers
879 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
225 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
446 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
136 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
288 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
301 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 ...
8
votes
1answer
1k 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
487 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
430 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 ...
9
votes
1answer
553 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 ...
41
votes
5answers
4k 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 ...
26
votes
3answers
3k 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
660 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 ...
11
votes
6answers
3k 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 ...
4
votes
2answers
579 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.