Skip to content

Instantly share code, notes, and snippets.

@shigemk2
Created August 19, 2015 12:12
Show Gist options
  • Save shigemk2/176cb68110565d0ab65a to your computer and use it in GitHub Desktop.
Save shigemk2/176cb68110565d0ab65a to your computer and use it in GitHub Desktop.
import Data.Monoid
main = do
print $ Nothing `mappend` Just "andy"
print $ Just LT `mappend` Nothing
print $ Just (Sum 3) `mappend` Just (Sum 4)
print $ getFirst $ First (Just 'a') `mappend` First (Just 'b')
print $ getFirst $ First Nothing `mappend` First (Just 'b')
print $ getFirst $ First (Just 'a') `mappend` First Nothing
print $ getFirst . mconcat . map First $ [Nothing, Just 9, Just 10]
print $ getLast . mconcat . map Last $ [Nothing, Just 9, Just 10]
print $ getLast $ Last (Just "one") `mappend` Last (Just "two")
-- 先のほうの引数を優先
print $ First (Just "one") `mappend` First (Just "two")
-- 後のほうの引数を優先
print $ Last (Just "one") `mappend` Last (Just "two")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment