Created
May 31, 2015 16:48
-
-
Save lotz84/2b5833d3fb3f92bddac3 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
{-# 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