Create a gist now

Instantly share code, notes, and snippets.

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