Skip to content

Instantly share code, notes, and snippets.

@lotz84
Created May 31, 2015 16:48
Show Gist options
  • Save lotz84/2b5833d3fb3f92bddac3 to your computer and use it in GitHub Desktop.
Save lotz84/2b5833d3fb3f92bddac3 to your computer and use it in GitHub Desktop.
{-# LANGUAGE DeriveGeneric, TemplateHaskell #-}
import GHC.Generics
import Control.Lens
data Score = Score
{ _english :: Int
, _math :: Int
} deriving (Generic, Show)
data Person = Person
{ _name :: String
, _score :: Score
} deriving (Generic, Show)
makeLenses ''Score
makeLenses ''Person
person :: Person
person = Person "lotz" (Score 50 60)
main = do
print $ person ^.name
print $ person ^.score.math
print $ person &score.math.~ 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment