[Haskell-beginners] Using a monad function inside the monad transfomer variant

Moritz Tacke moritz.tacke at gmail.com
Fri Feb 1 14:14:32 UTC 2019


Hi,

I am running into difficulties regarding the use of monad
transformers. The situation is as follows: I implemented some
functions returning "RVar" results. Now, in a different part of the
program, I am using STUArrays. Therefore my idea was to create a monad
transformer stack which would have this type:

someFunction::  a -> b  -> RVarT (ST s) (STUArray s Int Double)

I still want to use the functions that return RVars, so eg.

rvarDouble :: RVar Double

and then the definition of the transformer function would be:

someFunction a b =
    do ...
         the_double <- rvarDouble
         ....

This does not compile, complaining that;

   • Couldn't match type ‘Data.Functor.Identity.Identity’ with ‘ST s’
      Expected type: RVarT (ST s) Double
        Actual type: RVar Double

How can I re-user the RVar function in the RVarT monad transformer?
Sincerely yours,

           Moritz


More information about the Beginners mailing list