[Haskell] View patterns in GHC: Request for feedback

Stefan O'Rear stefanor at cox.net
Mon Jul 23 10:37:18 EDT 2007

On Mon, Jul 23, 2007 at 05:09:01AM -0400, Dan Licata wrote:
> Hi everyone,
> Simon PJ and I are implementing view patterns, a way of pattern matching
> against abstract datatypes, in GHC.  Our design is described here:
> http://hackage.haskell.org/trac/ghc/wiki/ViewPatterns
> If you have any comments or suggestions about this design, we'd love to
> hear them.  You can respond to this list (and we can take it to
> haskell-cafe if the thread gets long) or, if you prefer, directly to me.

Great work!

Two comments:

1. It might be better if zenary => used Bool rather than Maybe ().  This
   would allow existing Bool functions to be used as views; eg:

   foo (isUpper =>) = ...
   foo ((< 3) =>) = ...
   foo (ioErrors => (isEOFError =>)) = ...

2. This does introduce another point of infinite lookahead into the
   grammar.  Consider (long text... - after seeing the (, we might be
   seeing a parenthetized patern (back to pat*) or a expression for a
   view guard (go to exp).  Won't affect implementations that already
   mix the two (Language.Haskell.Parser, thus probably GHC too).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell/attachments/20070723/fc2c0fac/attachment.bin

More information about the Haskell mailing list