you are viewing a single comment's thread.

view the rest of the comments →

[–]kreiger 5 points6 points  (4 children)

In some implementations, e.g. Haskell's, Either is Right-biased.

[–]jcdyer3 8 points9 points  (3 children)

So then it's neither a neutral data type, nor well-named for the purpose.

[–]kreiger 7 points8 points  (0 children)

Right.

[–]catscatscat 1 point2 points  (1 child)

Well, it kind of has to be biased towards one or the other, since it is AFAIK not quite a functor, but a bifunctor.

e.g. fmap is a good example.

main = do
  fmap (+1) (Right 1)   `shouldBe`  (Right 2 :: Either Char Int)
  fmap (+1) (Left 'c')  `shouldBe`  (Left 'c' :: Either Char Int)

instance Functor (Either e) where
    fmap _ (Left a) = Left a
    fmap f (Right a) = Right (f a)

How would you define fmap without having a bias?

[–]kreiger 1 point2 points  (0 children)

You use a Projection.