[Haskell-cafe] Prolog-style patterns

Roman Cheplyaka roma at ro-che.info
Tue Apr 9 14:20:40 CEST 2013


* Daniel Trstenjak <daniel.trstenjak at gmail.com> [2013-04-09 13:01:07+0200]
> 
> Hi Roman,
> 
> > In fact, lots of Haskell newcomers are surprised that
> > 
> >   f 10 = 42
> > 
> > is not the same as
> > 
> >   n = 10
> >   f n = 42
> 
> Well, yes, at the beginning I've been also surprised about this.
> 
> But allowing this seems to be even more error prone, because now you
> could "bind" function arguments to values by just importing a module.

Oh, don't get me wrong — I'd never actually suggest that semantics.

Just saying that allowing one and not other would confuse the newcomers
about how pattern matching actually works. So I prefer to stay on the
simple and consistent side.

Roman



More information about the Haskell-Cafe mailing list