Lens example using Mario
This file contains 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 TemplateHaskell #-} | |
import Control.Lens | |
data Point = Point { | |
_x :: Double, | |
_y :: Double | |
} deriving (Show) | |
data Mario = Mario { _location :: Point } deriving (Show) | |
makeLenses ''Point | |
makeLenses ''Mario | |
player1 = Mario (Point 0 0) | |
main = print (location.x +~ 10 $ player1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment