on master help sign in
Add type annotations to Either.
90304e6evancz
core-elm/Either.elm+10
@@ -1,12 +1,22 @@
1
1
2data Either a b = Left a | Right b
2data Either a b = Left a | Right b
3
3
4+either : (a -> c) -> (b -> c) -> Either a b -> c
4either f g e = case e of { Left x -> f x ; Right y -> g y }
5either f g e = case e of { Left x -> f x ; Right y -> g y }
5
6
7+
8+isLeft : Either a b -> Bool
6isLeft e = case e of { Left _ -> True ; _ -> False }
9isLeft e = case e of { Left _ -> True ; _ -> False }
10+
11+isRight : Either a b -> Bool
7isRight e = case e of { Right _ -> True ; _ -> False }
12isRight e = case e of { Right _ -> True ; _ -> False }
8
13
14+
15+lefts : [Either a b] -> [a]
9lefts = Elm.List.filter isLeft
16lefts = Elm.List.filter isLeft
17+
18+rights : [Either a b] -> [b]
10rights = Elm.List.filter isRight
19rights = Elm.List.filter isRight
11
20
21+partition : [Either a b] -> ([a],[b])
12partition = Elm.List.partition isLeft
22partition = Elm.List.partition isLeft