Skip to content

Instantly share code, notes, and snippets.

@ktvoelker
Created April 27, 2011 23:19
Show Gist options
  • Save ktvoelker/945452 to your computer and use it in GitHub Desktop.
Save ktvoelker/945452 to your computer and use it in GitHub Desktop.
Some record types
data Foo = Foo { a :: Int, b :: Int }
data Bar = Bar { x :: Foo, y :: Foo }
one = modify $ \bar -> bar { x = (x bar) { a = 1 } }
one = putf (x // a) 1
one = modify $ \foo -> foo { a = 1 }
one' = modify $ \bar -> bar { x = execState one $ x bar, y = execState one $ y bar }
one = putf a 1
one' = enter x one >> enter y one
one' = modify $ \bar -> bar { x = x { a = 1 }, y = y { a = 1 } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment