[Haskell] Views in Haskell

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Fri Jan 26 11:45:30 EST 2007

Simon Marlow <simonmarhaskell at gmail.com> wrote:

> > To add to the bikeshed discussion of syntax, did you consider and
> > reject the obvious use of '<-' rather than '->'
> note that while the right arrow
> syntax looks  confusing when used on the left of a case alternative:
>     case e of
>        (regexp "[a-z]*" -> (name,rest)) -> ...
> the left arrow syntax looks strange when used in a statement:
>     do
>        ((name,rest) <- regexp "[a-z]*") <- readFile "foo"
>        ...

Actually, I don't really find either of those examples confusing - the
sense seems to flow nicely.  E.g. "first read the file, then apply the
regex, then match the resulting pair".  What would perhaps be more
confusing would be if the arrows were contrary to each other, e.g.

      do (regexp "[a-z]*" -> (name,rest)) <- readFile "foo"

Now that is ugly!

> Personally I remain to be convinced by view patterns.

Me too.  It is a nice observation of a particular point in the design
space, but it is so similar to pattern guards that I would not want to
have both in the language.  Pattern guards win for me, because there is
no implicit Maybe, and computation sharing is explicit.


More information about the Haskell mailing list