Created
February 22, 2015 00:26
-
-
Save gallais/6c7c23fe3da69ef1bd71 to your computer and use it in GitHub Desktop.
Unfold of a Fix
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
module Unfold where | |
newtype Fix f = InFix { outFix :: f (Fix f) } | |
unfoldFix :: Functor f => (s -> f s) -> s -> Fix f | |
unfoldFix node = go | |
where go = InFix . fmap go . node | |
data ListF a r = LNil | LCons a r | |
data TreeF a r = TNil | TLeaf a | TBranch r r | |
type List a = Fix (ListF a) | |
type Tree a = Fix (TreeF a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment