Skip to content

Instantly share code, notes, and snippets.

@tomlokhorst
Forked from sebastiaanvisser/tyingtheknot.hs
Created December 27, 2010 18:46
Show Gist options
  • Save tomlokhorst/756407 to your computer and use it in GitHub Desktop.
Save tomlokhorst/756407 to your computer and use it in GitHub Desktop.
{-# LANGUAGE
TypeOperators
, TemplateHaskell
#-}
module Tie where
import Prelude hiding ((.), id)
import Control.Category
import Data.Record.Label
-- Simple test.
data Person = Person
{ _name :: String
, _job :: Job
}
data Job = Job
{ _title :: String
, _who :: Person
}
$(mkLabels [''Person])
$(mkLabels [''Job])
me :: Person
me = setL job myJob (Person "Tom" myJob)
myJob :: Job
myJob = setL who me (Job "Software Engineer" me)
test :: String
test = getL (title . job . who . job . who . job . who . job) me
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment