[Haskell-cafe] Help with triple stack monad

Christopher Howard ch.howard at zoho.com
Wed Jun 22 01:12:19 UTC 2016


This doesn't seem to work for me, but I'm using 7.6.3 from Debian
Jessie. I'm curious what the difference is. What extensions and modules
do you import? I get error

ReaderStateRandom.hs:19:73:
    No instance for (MonadRandom (ReaderT r (StateT s (Rand g))))
      arising from the 'deriving' clause of a data type declaration
    Possible fix:
      add an instance declaration for
      (MonadRandom (ReaderT r (StateT s (Rand g))))
      or use a standalone 'deriving instance' declaration,
           so you can specify the instance context yourself
    When deriving the instance for (MonadRandom
                                      (ReaderStateRandom r s g))

On 06/21/2016 09:33 AM, Daniel Bergey wrote:
> On 2016-06-21 at 02:12, Christopher Howard <ch.howard at zoho.com> wrote:
>> However, it seems that I must implement MonadRandom myself, as there is
>> no instance for this sort of arrangement already.
> 
> Deriving the class also works, at least with GHC-7.10.3:
> 
> newtype ReaderStateRandom r s g a = RSR {
>   rSR :: ReaderT r (StateT s (Rand g)) a
>   } deriving (Functor, Applicative, Monad, MonadReader r, MonadState s,
>   MonadRandom)
> 
> bergey
> 

-- 
http://justonemoremathproblem.com
To protect my privacy, please use PGP encryption. It's free and easy
to use! My public key ID is 0x340EA95A (pgp.mit.edu).



More information about the Haskell-Cafe mailing list