Wolfgang Jeltsch g9ks157k at acme.softbase.org
Fri Jul 17 10:21:29 EDT 2009

```Am Freitag, 10. Juli 2009 23:41 schrieben Sie:
> On Jul 10, 2009, at 4:35 AM, Wolfgang Jeltsch wrote:
> > I fear that this instance doesn’t satisfy required laws. As far as
> > I know, the following equalities should hold:
> >
> >     (*>) = (>>)
> >
> >     f *> empty = empty
> >
> >     empty <|> g = g
> >
> > This implies the following:
> >
> >     (f >> empty) <|> g = g
> >
> > But this wouldn’t hold with your instance. (f >> empty) <|> g would
> > cause the side effects of f and of g, while g would (obviously) only cause
> > the side effects of g.
>
> I think the third equality you provide is too strong (which isn't to
> say that it might not be the law that people have documented and
> expect). Lots of useful alternative instances fail it, not least any
> parser combinator library (such as Parsec) without automatic
> backtracking.

Really? The third equality is required since Alternative instances have to be
monoids with empty as the neutral element and (<|>) as composition.

> […]

> Additionally, the second equality you provide is just wrong.
>
> f *> empty = empty is no more true than f *> g = g,

I don’t understand this. The equation f *> g = g is much more general than
f *> empty = empty. (<|>) usually denotes non-determinism and empty should be
the neutral element of non-determinism, which is failing. This leads me to
f *> empty = empty.

> […]

Best wishes,
Wolfgang
```