Skip to content

Instantly share code, notes, and snippets.

@russmatney
Created May 12, 2018 03:35
Show Gist options
  • Save russmatney/aa17ebbaf0c0435062d50ed20eb92a34 to your computer and use it in GitHub Desktop.
Save russmatney/aa17ebbaf0c0435062d50ed20eb92a34 to your computer and use it in GitHub Desktop.
setExamples :: IO ()
setExamples = do
let bob = User (UserName "bob") 0 Nothing HM.empty
print "Bob, with an updated score"
print $ set score 42 bob
-- User {_userName = UserName "bob", _userScore = 42, _userPet = Nothing, _userInventory = fromList []}
print $ (score .~ 42) bob
-- User {_userName = UserName "bob", _userScore = 42, _userPet = Nothing, _userInventory = fromList []}
-- print bob with score set to 42
print $ bob & score .~ 42
-- User {_userName = UserName "bob", _userScore = 42, _userPet = Nothing, _userInventory = fromList []}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment