Vote count:
0
I have a RWST
Monad, and have some generic functions to interact with the Writer
part of it.
For reference, RWST
is like this:
newtype RWST r w s m a = RWST {runRWST :: r -> s -> m (a, s, w)}
instance (Monoid w, Monad m) => Monad (RWST r w s m)
instance Functor m => Functor (RWST r w s m)
instance (Monoid w, MonadFix m) => MonadFix (RWST r w s m)
instance (Monoid w, MonadPlus m) => MonadPlus (RWST r w s m)
instance Monoid w => MonadTrans (RWST r w s)
instance (Monoid w, MonadIO m) => MonadIO (RWST r w s m)
instance (Monoid w, Monad m) => MonadWriter w (RWST r w s m)
instance (Monad m, Monoid w) => MonadState s (RWST r w s m)
instance (Monad m, Monoid w) => MonadReader r (RWST r w s m)
instance (Monoid w, Monad m) => MonadRWS r w s (RWST r w s m)
So I had a data Definition
that is like this:
type Definition = RWS SapphireReader DefWriter DefState
Where the DefWriter
is just type DefWriter = Seq Error
(Error is defined by me, not the Control.Monad.Error
one).
I had a working function:
tellPError :: Position -> ParseError -> Definition ()
tellPError posn err = tell (singleton $ PError posn err)
Now I need a new RWST and wish to have a generic tellPError
, I tried removing the signature, loading the file in ghci and doing :t tellPError
.
λ :t tellPError
tellPError :: MonadWriter (Seq Error.Error) m => Position -> ParseError -> m ()
I try giving my function that signature in the code, it won't compile:
Non type-variable argument
in the constraint: MonadWriter (Seq Error) m
(Use -XFlexibleContexts to permit this)
In the type signature for `tellPError':
tellPError :: MonadWriter (Seq Error) m =>
Position -> ParseError -> m ()
Do I really need this flag? I tried it and it did compile but wouldn't work.
asked 35 secs ago
What can I do to make this ghci infereced signature to compile
Aucun commentaire:
Enregistrer un commentaire