When is it OK to use an IORef?

State and its relative ST both produce `monolithic’ stateful computations which may be run as units. They basically treat the mutable state as intermediate data, which is needed to produce a result, but should not, in and of itself, be of interest to the rest of the programme. On the other hand, what one puts … Read more

Why is the bind operator (>>=) defined as it is?

Could someone explain the reasoning behind this choice of definition for bind? Sure, and it’s almost exactly the same reasoning you have. It’s just… we wanted a more general application operator, not a more general composition operator. If you’ve done much (any) point-free programming, you’ll immediately recognize why: point-free programs are hard to write, and … Read more

Is there a monad that doesn’t have a corresponding monad transformer (except IO)?

I’m with @Rhymoid on this one, I believe all Monads have two (!!) transformers. My construction is a bit different, and far less complete. I’d like to be able to take this sketch into a proof, but I think I’m either missing the skills/intuition and/or it may be quite involved. Due to Kleisli, every monad … Read more

Monads with Join() instead of Bind()

Without plumbing the depths of metaphor, might I suggest to read a typical monad m as “strategy to produce a”, so the type m value is a first class “strategy to produce a value”. Different notions of computation or external interaction require different types of strategy, but the general notion requires some regular structure to … Read more

Monads vs. Arrows

There are two excellent papers by Lindley, Wadler & Yallop (discussed at LTU here). The most important thing to understand is that there are more things which are arrows than there are things which are monads. Conversely, monads are strictly more powerful than arrows (the second paper above specifies precisely in which fashion). In particular, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)