3

私はタイプを持っています

ActionT TL.Text (ReaderT T.Text IO)

私はこのための MonadReader インスタンスを作成しようとしていますので、尋ねる必要はありませんが、常に取得します

 (All instance types must be of the form (T a1 ... an)
  where a1 ... an are *distinct type variables*,
  and each type variable appears at most once in the instance head.
  Use -XFlexibleInstances if you want to disable this)

以下のいくつかのインスタンスタイプを試しましたが、常に上記のエラーが発生します

instance MonadReader T.Text (ActionT TL.Text (ReaderT T.Text IO))    

instance MonadReader r (ActionT TL.Text (ReaderT r IO))

instance (ScottyError e, MonadReader r m) => MonadReader r (ActionT e (ReaderT r m))

インスタンスで基本的な何かが欠けているように感じます。理解していると思いますFlexibleInstancesが、それがここでどのように適用されるかわかりません。

インスタンスタイプに関するヘルプをいただければ幸いです。実装askしたいとlocal思います。主な目標は学習です。

ありがとう。

アップデート

私はそれを使って動作させましFlexibleInstances, MultiParamTypeClasses, UndecidableInstances

instance  (ScottyError e, Monad m, MonadReader r m) => MonadReader r (ActionT e m) where
  ask = lift ask

まだローカルの実装に取り​​組んでいます。私もUndecidableInstances悪いと思いますか?

更新 2

私は本当に必要なものだと思います。

instance  (ScottyError e, Monad m, MonadReader r m) => MonadReader r (ActionT e (ReaderT r m)) where

しかし、私はまだ理解できませんlocal

4

2 に答える 2