Skip to content

Instantly share code, notes, and snippets.

@russmatney
Created May 12, 2018 03:38
Show Gist options
  • Save russmatney/279870df8f143a2ae4a10ab532803182 to your computer and use it in GitHub Desktop.
Save russmatney/279870df8f143a2ae4a10ab532803182 to your computer and use it in GitHub Desktop.
hasGotchaIx :: IO ()
hasGotchaIx = do
let bob = User (UserName "bob") 42 Nothing HM.empty
print "Has bob gold in his inventory?"
print $ has (inventory . ix "gold") bob
-- False
let richBob = User (UserName "bob") 42 Nothing
$ HM.fromList [("gold", Item 10 10)]
print "Has bob gold in his inventory?"
print $ has (inventory . ix "gold") richBob
-- True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment