[Haskell-cafe] Monads with "The" contexts?

oleg at okmij.org oleg at okmij.org
Thu Jul 19 09:33:31 CEST 2012

> http://en.pk.paraiso-lang.org/Haskell/Monad-Gaussian
> What do you think? Will this be a good approach or bad?

I don't think it is a Monad (or even restricted monad, see
below). Suppose G a is a `Gaussian' monad and n :: G Double is a
random number with the Gaussian (Normal distribution).  Then 
	(\x -> x * x) `fmap` n 
is a random number with the chi-square distribution (of
the degree of freedom 1). Chi-square is _not_ a normal
distribution. Perhaps a different example is clearer:

	(\x -> if x > 0 then 1.0 else 0.0) `fmap` n

has also the type G Double but obviously does not have the normal
distribution (since that random variable is discrete).

There are other problems

> Let's start with some limitation; we restrict ourselves to Gaussian
> distributions and assume that the standard deviations are small
> compared to the scales we deal with.

That assumption is not stated in types and it is hard to see how can
we enforce it. Nothing prevents us from writing
	liftM2 n n
in which case the variance will no longer be small compared with the

Just a technical remark: The way G a is written, it is a so-called
restricted monad, which is not a monad (the adjective `restricted' is
restrictive here). 

More information about the Haskell-Cafe mailing list