[Haskell] insufficiently laziness@pattern -- more counterintuitive stuff

S. Alexander Jacobson alex at i2x.com
Tue Mar 30 12:01:00 EST 2004


Thanks for the ~ syntax, but my question is really
why you need it?  What benefit do you get from
"refutable patterns"?

Alternatively, would anything break if a future
Haskell just treated all patterns as irrefutable?

-Alex-

_________________________________________________________________
S. Alexander Jacobson                  mailto:me at alexjacobson.com
tel:917-770-6565                       http://alexjacobson.com


On Tue, 30 Mar 2004, Martin [ISO-8859-1] Sj=F6gren wrote:

> tis 2004-03-30 klockan 17.30 skrev S. Alexander Jacobson:
> > I would assume that this function:
> >
> >   foo list@(h:t) =3D list
> >
> > is equivalent to
> >
> >   foo list =3D list
> >      where (h:t)=3Dlist
> >
> > But passing [] to the first generates an error
> > even though h and t are never used!  Passing [] to
> > the second works just fine.
>
> You can write this as
>
> > foo' list@(~(h:t)) =3D list
>
> foo' [] will evaluate to []. The H98 report calls it an "irrefutable
> pattern", IIRC.
>
>
> Regards,
> Martin
>



More information about the Haskell mailing list