@@ -9,7 +9,7 @@ module Either where
9@docs either, isLeft, isRight
9@docs either, isLeft, isRight
11# Eithers and Lists
11# Eithers and Lists
12−@docs lefts, rights, partition, consLeft, consRight, consEither
12+@docs lefts, rights, partition
@@ -25,7 +25,7 @@ error messages are stored on the left, and the correct values
25data Either a b = Left a | Right b
25data Either a b = Left a | Right b
27{-| Apply the first function to a `Left` and the second function to a `Right`.
27{-| Apply the first function to a `Left` and the second function to a `Right`.
28− This allows the extraction of a value from an `Either`.
28+This allows the extraction of a value from an `Either`.
30either : (a -> c) -> (b -> c) -> Either a b -> c
30either : (a -> c) -> (b -> c) -> Either a b -> c
31either f g e = case e of { Left x -> f x ; Right y -> g y }
31either f g e = case e of { Left x -> f x ; Right y -> g y }
@@ -47,13 +47,13 @@ rights : [Either a b] -> [b]
47rights es = List.foldr consRight [] es
47rights es = List.foldr consRight [] es
49{-| Split into two lists, lefts on the left and rights on the right. So we
49{-| Split into two lists, lefts on the left and rights on the right. So we
50− have the equivalence: `(partition es == (lefts es, rights es))`
50+have the equivalence: `(partition es == (lefts es, rights es))`
52partition : [Either a b] -> ([a],[b])
52partition : [Either a b] -> ([a],[b])
53partition es = List.foldr consEither ([],[]) es
53partition es = List.foldr consEither ([],[]) es
55{-| If `Left`, add the value to the front of the list.
55{-| If `Left`, add the value to the front of the list.
56− If `Right`, return the list unchanged
56+If `Right`, return the list unchanged
58consLeft : Either a b -> [a] -> [a]
58consLeft : Either a b -> [a] -> [a]
59consLeft e vs =
59consLeft e vs =
@@ -62,7 +62,7 @@ consLeft e vs =
62 Right _ -> vs
62 Right _ -> vs
64{-| If `Right`, add the value to the front of the list.
64{-| If `Right`, add the value to the front of the list.
65− If `Left`, return the list unchanged.
65+If `Left`, return the list unchanged.
67consRight : Either a b -> [b] -> [b]
67consRight : Either a b -> [b] -> [b]
68consRight e vs =
68consRight e vs =
@@ -71,7 +71,7 @@ consRight e vs =
71 Right v -> v::vs
71 Right v -> v::vs
73{-| If `Left`, add the value to the left list.
73{-| If `Left`, add the value to the left list.
74− If `Right`, add the value to the right list.
74+If `Right`, add the value to the right list.
76consEither : Either a b -> ([a], [b]) -> ([a], [b])
76consEither : Either a b -> ([a], [b]) -> ([a], [b])
77consEither e (ls,rs) =
77consEither e (ls,rs) =