Simple following code
import Control.Monad import Control.Monad.Random psum :: (MonadRandom r) => Int -> r Double -> r Double psum nx = fmap sum $ replicateM nx
gives an error:
Could not deduce (Functor r) arising from a use of `fmap' from the context (MonadRandom r)
This is strange to me because of
class (Monad m) => MonadRandom m where ...
in the Control.Monad.Random.Class
source file, and since monads are functors, GHC should have deduced that r
is a functor in my context. I also tried importing Control.Monad.Random.Class
without success.
Manually adding Functor
constraints on r
works, but I find it pretty ugly.
What am I missing here?
source share