Skip to content

Instantly share code, notes, and snippets.

@queertypes
Created February 18, 2015 20:41
Show Gist options
  • Save queertypes/2ea9b69bea946cb93e95 to your computer and use it in GitHub Desktop.
Save queertypes/2ea9b69bea946cb93e95 to your computer and use it in GitHub Desktop.
Record partial application in Haskell
> data Thing = Thing {a :: Int, b :: Int, c :: Int} deriving Show
> :t
Thing :: Int -> Int -> Int -> Thing
> Thing {a = 10}
<interactive>:13:1: Warning:
Fields of ‘Thing’ not initialised: b, c
In the expression: Thing {a = 10}
In an equation for ‘it’: it = Thing {a = 10}
<interactive>:13:1: Warning:
Fields of ‘Thing’ not initialised: b, c
In the expression: Thing {a = 10}
In an equation for ‘it’: it = Thing {a = 10}
Thing {a = 10, b = *** Exception: <interactive>:13:1-14: Missing field in record construction Ghci4.b
> Thing {c = 10} {a = 5} {b = 2}
<interactive>:14:1: Warning:
Fields of ‘Thing’ not initialised: a, b
In the expression: Thing {c = 10}
In the expression: (Thing {c = 10}) {a = 5}
In the expression: ((Thing {c = 10}) {a = 5}) {b = 2}
<interactive>:14:1: Warning:
Fields of ‘Thing’ not initialised: a, b
In the expression: Thing {c = 10}
In the expression: (Thing {c = 10}) {a = 5}
In the expression: ((Thing {c = 10}) {a = 5}) {b = 2}
Thing {a = 5, b = 2, c = 10}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment