Created
February 14, 2015 23:24
-
-
Save dysinger/382fc0babc7d18a23307 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| data Person = Person { _name :: String } | |
| data Status a b = New b | Old a b | |
| deriving (Functor,Foldable,Traversable) | |
| type PersonWithStatus = Status Int Person | |
| sumNewFolks :: [PersonWithStatus] -> Int | |
| sumNewFolks = foldr go 0 | |
| where go (New _) b = b + 1 | |
| go _ b = b | |
| uniqOldFolksIds :: [PersonWithStatus] -> Data.Set.Set Int | |
| uniqOldFolksIds = foldr go Data.Set.empty | |
| where go (Old oldId _) b = Data.Set.insert oldId b | |
| go _ b = b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment