Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"package.json"
],
"dependencies": {
"purescript-foldable-traversable": "^2.0.0"
"purescript-foldable-traversable": "^2.0.0",
"purescript-prelude": "^2.4.0"
}
}
6 changes: 6 additions & 0 deletions src/Data/Either.purs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import Control.Extend (class Extend)
import Data.Bifoldable (class Bifoldable)
import Data.Bifunctor (class Bifunctor)
import Data.Bitraversable (class Bitraversable)
import Data.Eq (class Eq1)
import Data.Foldable (class Foldable)
import Data.Functor.Invariant (class Invariant, imapF)
import Data.Monoid (mempty)
import Data.Ord (class Ord1)
import Data.Traversable (class Traversable)

-- | The `Either` type is used to represent a choice between two types of value.
Expand Down Expand Up @@ -164,13 +166,17 @@ instance showEither :: (Show a, Show b) => Show (Either a b) where
-- | types the `Either` can contain.
derive instance eqEither :: (Eq a, Eq b) => Eq (Either a b)

instance eq1Either :: Eq a => Eq1 (Either a) where eq1 = eq

-- | The `Ord` instance allows `Either` values to be compared with
-- | `compare`, `>`, `>=`, `<` and `<=` whenever there is an `Ord` instance for
-- | both types the `Either` can contain.
-- |
-- | Any `Left` value is considered to be less than a `Right` value.
derive instance ordEither :: (Ord a, Ord b) => Ord (Either a b)

instance ord1Either :: Ord a => Ord1 (Either a) where compare1 = compare

instance boundedEither :: (Bounded a, Bounded b) => Bounded (Either a b) where
top = Right top
bottom = Left bottom
Expand Down