2 つのモナドを構成する関数があります。
comp :: Monad m => m a -> m b -> m b
そして、 on が an の「内側」にあるようなモナドの 2 つのインスタンスMfunctor
、
ms :: Monad m => m String
ms = undefined
tma :: (Monad m, MFunctor t) => t m a
tma = undefined
今、私が作曲しようとするms
とtma
:
tmas = hoist (\ma -> comp ma ms) tma
このエラーが発生しています:
Could not deduce (a ~ [Char])
from the context (Monad m, MFunctor t)
bound by the inferred type of
comp :: (Monad m, MFunctor t) => t m b
at Coroutine.hs:607:1-40
`a' is a rigid type variable bound by
a type expected by the context: m a -> m a at Coroutine.hs:607:8
Expected type: m a
Actual type: m String
これは、a
inms
が任意の型でなければならないことを示しています: ms :: Monad m => m a
.
これはなぜですかtma
、特定のパラメータのモナドで構成する方法はありますか。
ホイストのシグネチャは次のとおりです。
hoist :: (Monad m, MFunctor t) => (forall a. m a -> n a) -> t m b -> t n b
しかし、それがforall
私がやろうとしていることにどのように影響を与えているかを想像することはできません。