Created
June 7, 2018 00:49
-
-
Save joelburget/40a94ff803c93ee2ebe27fdf7e32701e to your computer and use it in GitHub Desktop.
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
import Data.Vinyl | |
-- import Data.Vinyl.Functor | |
type LifeForm a = | |
"name" ::: String | |
: "age" ::: Int | |
: "sleeping" ::: Bool | |
: a | |
type LifeForm' a = FieldRec (LifeForm a) | |
jon :: LifeForm' '[] | |
jon = #name =: "jon" | |
:& #age =: 23 | |
:& #sleeping =: False | |
:& RNil | |
tucker :: LifeForm' '["master" ::: LifeForm' '[]] | |
tucker = #name =: "tucker" | |
:& #age =: 9 | |
:& #sleeping =: True | |
:& #master =: jon | |
:& RNil | |
wakeUp | |
:: HasField record "sleeping" fs Bool | |
=> record ElField fs | |
-> record ElField fs | |
wakeUp = rputf #sleeping False | |
jon' :: LifeForm' '[] | |
jon' = wakeUp jon | |
tucker' :: LifeForm' '["master" ::: LifeForm' '[]] | |
tucker' = wakeUp tucker |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment