haskell - 有免费的代理变压器吗?

标签 haskell monad-transformers free-monad

你认为免费的代理变压器是可能的吗?就像是

data FreePT f p a' a b' b m r = ....

instance (Proxy p,Functor f) => Proxy (FreePT f p) where
    ....

instance (Functor f) => ProxyTrans (FreePT f) where
    ....

这不仅是好奇心,我实际上会发现这很有用。

最佳答案

这不是答案,但不适合评论。

我也想要一个类似的功能。我怀疑内部类型将如下所示:

-- The same `FreeF` type from the `free` package in `Control.Monad.Trans.Free`
data FreeF f a x = Pure a | Free (f x)

newtype FreeP f p a' a b' b m r
    = FreeP { unFreeP ::
        p a'
          (FreeF f a (FreeP f p a' a b' b m r))
          b'
          (FreeF f b (FreeP f p a' a b' b m r))
          m
          (FreeF f r (FreeP f p a' a b' b m r)) }

此外,目前现有的机器可能无法实现,但没关系。例如,咨询 StateP代理转换器,它依赖于 thread_P来自 ProxyInternal .类似于 thread_P可能需要实现 FreeP .

关于haskell - 有免费的代理变压器吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16592395/

相关文章:

haskell - 理解 Haskell 中的 $

haskell - Haskell 中的延迟操作

scala - 免费 ~> 蹦床 : recursive program crashes with OutOfMemoryError

Haskell理解流程

haskell - 绑定(bind)FFI和DSL

haskell - 相当于 attoparsecs `inClass` 的秒差距

haskell - FoldMap 采用错误类型的参数?

haskell - 通常说来,monad变压器是否由附加条件产生?

haskell - 扩大 ocaml 中的类型

Scala Cats FreeMonad - 为什么我的解释器中需要 asInstanceOf[Id[A]]?