Last active
December 19, 2017 10:59
-
-
Save edwardgeorge/c5d00b0a0cb03c7d8902660f04443c47 to your computer and use it in GitHub Desktop.
effectful generalised hylomorphism
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ghyloM | |
:: forall w f m n a b. (Comonad w, Traversable f, Monad m, Monad n) | |
=> (forall x. f (w x) -> w (f x)) | |
-> (forall x. m (f x) -> f (m x)) | |
-> (forall x. w (n x) -> n (w x)) | |
-> (forall x. m (n x) -> n (m x)) | |
-> (f (w b) -> n b) | |
-> (a -> n (f (m a))) | |
-> a | |
-> n b | |
ghyloM distfw distmf distwn distmn fwalg fmcoalg = fmap extract . go . pure | |
where | |
go :: m a -> n (w b) | |
go = join . fmap j . distmn . fmap fmcoalg | |
h :: f (w (w b)) -> n (w b) | |
h = distwn . fmap fwalg . distfw | |
i :: m (m a) -> n (w (w b)) | |
i = fmap duplicate . go . join | |
j :: m (f (m a)) -> n (w b) | |
j = join . fmap h . traverse i . distmf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment