tsoding/haskell-json

Either ParserError should not be an Alternative

Closed this issue · 1 comments

In the code

instance Alternative (Either ParserError) where
  empty = Left $ ParserError 0 "empty"
  Left _ <|> e2 = e2
  e1 <|> _ = e1

But empty is not a right identity: Left example <|> empty == empty.

So it is not a monoid under <|>...

class Applicative f => Alternative (f :: Type -> Type) where

A monoid on applicative functors.

[ ... ]

empty :: f a

The identity of <|>
empty <|> a == a
a <|> empty == a

P.S. Sorry for the spam on 5 year old youtube project: insomnia...

Ok, I assume you "pretend" all Left values are "the same" and their contents are just for logging errors...