Created
May 6, 2020 04:59
-
-
Save steshaw/868c3c474f2094f2f79c272f2e2bbb09 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
data Decl a | |
= TypeSig String a | |
| Law String a a | |
| FunModel String a | |
| TypeModel String a | |
| Import a | |
| Other a | |
deriving (Show) | |
decls = | |
[ TypeSig "Hello" 1, | |
Law "Fred" 1 42, | |
FunModel "Fun" 2, | |
Import 10, | |
Other 99, | |
Law "Be good" 2 3, | |
TypeModel "huh" 0 | |
] | |
partitionThem :: [Decl a] -> ([Decl a], [Decl a], [Decl a], [Decl a]) | |
partitionThem = foldMap pickSlot | |
where | |
pickSlot lw@Law {} = ([lw], mempty, mempty, mempty) | |
pickSlot fm@FunModel {} = (mempty, [fm], mempty, mempty) | |
pickSlot tm@TypeModel {} = (mempty, mempty, [tm], mempty) | |
pickSlot other = (mempty, mempty, mempty, [other]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment