Created
May 12, 2018 03:34
-
-
Save russmatney/8d79256662fa34eacd75d15382d6b2a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
composedViewExamples :: IO () | |
composedViewExamples = do | |
let | |
bob = User (UserName "bob") 42 Nothing HM.empty | |
fitzgerald = Pet (PetName "Fitzgerald") | |
jeff = User (UserName "jeff") 42 (Just fitzgerald) HM.empty | |
print "Bob's pet's name is: " | |
print $ preview (pet . _Just . petName) bob | |
-- Nothing | |
print $ bob ^? pet . _Just . petName | |
-- Nothing | |
print "Jeff's pet's name is: " | |
print $ preview (pet . _Just . petName) jeff | |
-- Just (PetName "Fitzgerald") | |
print $ jeff ^? pet . _Just . petName | |
-- Just (PetName "Fitzgerald") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment