Skip to content

Instantly share code, notes, and snippets.

@zetavg
Last active March 16, 2019 16:21
Show Gist options
  • Save zetavg/7368c7725bd93ec6d7cb71804334d8ce to your computer and use it in GitHub Desktop.
Save zetavg/7368c7725bd93ec6d7cb71804334d8ce to your computer and use it in GitHub Desktop.
fix = \f -> let r = f r in r -- retuns f (f (f (f (f ...)))), sounds like infinile loop?
data D = D {
a :: Int,
b :: Int,
c :: Int
} deriving (Show)
d = (\self -> D 1 (a self + 1) (a self + b self)) -- Can reference itself!
-- ^ ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^
-- a b=a+1 c=a+b
fix d -- => D {a = 1, b = 2, c = 3}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment