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
2 changes: 2 additions & 0 deletions docs/Data/Either.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ instance foldableEither :: Foldable (Either a)
instance bifoldableEither :: Bifoldable Either
instance traversableEither :: Traversable (Either a)
instance bitraversableEither :: Bitraversable Either
instance semiringEither :: (Semiring b) => Semiring (Either a b)
instance semigroupEither :: (Semigroup b) => Semigroup (Either a b)
```

#### `either`
Expand Down
9 changes: 9 additions & 0 deletions src/Data/Either.purs
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,12 @@ instance bitraversableEither :: Bitraversable Either where
bitraverse _ g (Right b) = Right <$> g b
bisequence (Left a) = Left <$> a
bisequence (Right b) = Right <$> b

instance semiringEither :: (Semiring b) => Semiring (Either a b) where
one = Right one
mul x y = mul <$> x <*> y
zero = Right zero
add x y = add <$> x <*> y

instance semigroupEither :: (Semigroup b) => Semigroup (Either a b) where
append x y = append <$> x <*> y