Skip to content

Instantly share code, notes, and snippets.

@Icelandjack
Created October 3, 2020 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Icelandjack/3ba65595f6ec78b5c4ff28df745f4caf to your computer and use it in GitHub Desktop.
Save Icelandjack/3ba65595f6ec78b5c4ff28df745f4caf to your computer and use it in GitHub Desktop.
Tree instance for Ap and Biap
instance (Applicative f, Treey tree) => Treey (Ap f tree) where
leaf :: Int -> Ap f tree
leaf = pure . leaf
(¦) :: Ap f tree -> Ap f tree -> Ap f tree
(¦) = liftA2 (¦)
instance (Biapplicative bi, Treey tree1, Treey tree2) => Treey (Biap bi tree1 tree2) where
leaf :: Int -> Biap bi tree1 tree2
leaf = liftA2 bipure leaf leaf
(¦) :: Biap bi tree1 tree2 -> Biap bi tree1 tree2 -> Biap bi tree1 tree2
(¦) = biliftA2 (¦) (¦)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment