How do I do logging in Haskell?

First, a quick disclaimer: “logging” doesn’t usually make sense in general Haskell code, because it assumes some sort of sequential execution that may or may not be meaningful. Make sure you distinguish between logging how the program executes and logging what values are computed. In strict imperative languages these are mostly the same, but in … Read more

Has anyone ever encountered a Monad Transformer in the wild?

The Haskell community is split on this issue. John Hughes reports that he finds it easier to teach monad transformers than to teach monads, and that his students do better with a “transformers first” approach. The GHC developers generally avoid monad transformers, preferring to roll up their own monads which integrate all the features they … Read more

Haskell pre-monadic I/O

Before the IO monad was introduced, main was a function of type [Response] -> [Request]. A Request would represent an I/O action like writing to a channel or a file, or reading input, or reading environment variables etc.. A Response would be the result of such an action. For example if you performed a ReadChan … Read more

Is Future in Scala a monad?

A summary first Futures can be considered monads if you never construct them with effectful blocks (pure, in-memory computation), or if any effects generated are not considered as part of semantic equivalence (like logging messages). However, this isn’t how most people use them in practice. For most people using effectful Futures (which includes most uses … Read more

Simplest non-trivial monad transformer example for “dummies”, IO+Maybe

This is available here as a .lhs file. The MaybeT transformer will allow us to break out of a monad computation much like throwing an exception. I’ll first quickly go over some preliminaries. Skip down to Adding Maybe powers to IO for a worked example. First some imports: import Control.Monad import Control.Monad.Trans import Control.Monad.Trans.Maybe Rules … Read more

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