Skip to content

Instantly share code, notes, and snippets.

@supermario
Created October 15, 2015 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save supermario/5c54e07bf461c280794b to your computer and use it in GitHub Desktop.
Save supermario/5c54e07bf461c280794b to your computer and use it in GitHub Desktop.
lens + maybe
data Box = Box { _value :: Integer }
data World = World { _box :: Maybe Box }
makeLenses ''Box
makeLenses ''World
steps :: StateT World IO ()
steps = do
box.value %= succ
-- Couldn't match type ‘Box’ with ‘Maybe Box’
-- Expected type: (Integer -> f Integer)
-- -> Maybe Box -> f (Maybe Box)
-- Actual type: (Integer -> f Integer) -> Box -> f Box
-- In the second argument of ‘(.)’, namely ‘pose’
-- In the expression: robot . pose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment