Closed t-c-acc closed 2 months ago
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.
empty
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
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...
In the code
But
empty
is not a right identity:Left example <|> empty == empty
.So it is not a monoid under
<|>
...P.S. Sorry for the spam on 5 year old youtube project: insomnia...