"不允许使用类型同义词实例"即使我有一个newtype monad变换器

时间:2017-04-18 10:39:49

标签: typeclass monad-transformers purescript newtype type-synonyms

我已经定义了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 - 实例时,我得到了同样的错误。

1 个答案:

答案 0 :(得分:1)

gb的评论:当然MonadAsk有两个参数,第一个Env是罪犯。

相关问题