我已经定义了monad变换器UlffT
,如下所示。
我正在使用Halogen
,但这不是Halogen
- 问题 - 我只是提供了背景信息。 UlffT
应放在Aff
上,并在HalogenM
中使用。
newtype UlffT m a = UlffT ( ExceptT Error (ReaderT Env m) a )
unUlffT :: forall m. UlffT m ~> ExceptT Error (ReaderT Env m)
unUlffT (UlffT m) = m
derive newtype instance functorUlffT :: Functor m => Functor (UlffT m)
derive newtype instance applyUlffT :: Monad m => Apply (UlffT m)
derive newtype instance applicativeUlffT :: Monad m => Applicative (UlffT m)
derive newtype instance bindUlffT :: Monad m => Bind (UlffT m)
derive newtype instance monadUlffT :: Monad m => Monad (UlffT m)
instance monadTransUlffT
:: MonadTrans UlffT where
lift = UlffT <<< lift <<< lift
instance monadEffUlffT
:: MonadEff eff m
=> MonadEff eff (UlffT m) where
liftEff = lift <<< liftEff
instance monadAffUlffT
:: MonadAff eff m
=> MonadAff eff (UlffT m) where
liftAff = lift <<< liftAff
这里的一切都很好。现在我为MonadAsk
定义明显的实例,如下所示。
instance monadAskUlffT
:: MonadAsk Env (UlffT m) where
ask = UlffT $ lift ask
我收到错误
Type class instances for type synonyms are disallowed.
UlffT
不是类型同义词。我期待有关m
的错误,例如我必须声明Monad m => ...
或Monad (UlffT m) => ...
等约束。
在派生MonadAsk
- 实例时,我得到了同样的错误。
答案 0 :(得分:1)
gb的评论:当然MonadAsk
有两个参数,第一个Env
是罪犯。