Skip to content

Instantly share code, notes, and snippets.

@egonSchiele
Created July 15, 2013 01:41
Show Gist options
  • Save egonSchiele/5996957 to your computer and use it in GitHub Desktop.
Save egonSchiele/5996957 to your computer and use it in GitHub Desktop.
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