Skip to content

Instantly share code, notes, and snippets.

@sleexyz
Created June 23, 2016 19:29
Show Gist options
  • Save sleexyz/a904af56e49758d6fa315ca8e1978400 to your computer and use it in GitHub Desktop.
Save sleexyz/a904af56e49758d6fa315ca8e1978400 to your computer and use it in GitHub Desktop.
Fixed point combinator derived without knot-tying, via recursive types
newtype Self t = Fold { unfold :: Self t -> t}
fix :: (a -> a) -> a
fix f = unroll . Fold $ f . unroll
unroll :: Self t -> t
unroll e = unfold e e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment