Skip to content

Instantly share code, notes, and snippets.



Created Jul 15, 2013
What would you like to do?
Lens example using Mario
{-# 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
You can’t perform that action at this time.