gpt4 book ai didi

haskell - “加入”申请?

转载 作者:行者123 更新时间:2023-12-03 10:30:37 31 4
gpt4 key购买 nike

我正在寻找以下功能:
Applicative f => f (f a) -> f a
Hoogle给我看join :

>:t join
join :: Monad m => m (m a) -> m a

是否有与我想要的签名相匹配的功能?

最佳答案

稍微扩展一下 Carl's answer , 如果有 join 这样的东西,但对于应用程序:

class Applicative f => ApplicativeWithJoin f where
join' :: f (f a) -> f a

然后你会自动拥有一个 monad:
instance ApplicativeWithJoin m => Monad m where
return = pure
x >>= f = join' (f <$> x)

关于haskell - “加入”申请?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29113360/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com