How much is applicative really about applying, rather than “combining”?

后端 未结 1 1311
眼角桃花
眼角桃花 2020-12-10 14:19

For an uncertainty-propagating Approximate type, I\'d like to have instances for Functor through Monad. This however doesn\'t work because I need a

相关标签:
1条回答
  • 2020-12-10 14:42

    As I understand it (as a non---category theorist), the fundamental operation is zip :: f a -> f b -> f (a, b) (mapping a pair of effectful computations to an effectful computation resulting in a pair).

    You can then define

    • fx <*> fy = uncurry ($) <$> zip fx fy
    • liftA2 g fx fy = uncurry g <$> zip fx fy

    See this post by Edward Yang, which I found via the Typeclassopedia.

    0 讨论(0)
提交回复
热议问题