[Haskell-cafe] Pattern matching does not work like this?

Luke Palmer lrpalmer at gmail.com
Wed Jul 15 07:22:55 EDT 2009


On Wed, Jul 15, 2009 at 3:08 AM, Hans Aberg <haberg at math.su.se> wrote:

> On 15 Jul 2009, at 12:25, Eugene Kirpichov wrote:
>
>  If ++ could be pattern matched, what should have been the result of
>> "let (x++y)=[1,2,3] in (x,y)"?
>>
>
> It will branch. In terms of unification, you get a list of substitutions.


f :: [a] -> ([a],[a])
f (x ++ y) = (x,y)

If this pattern branches, it could hardly be considered a *function *which
takes lists and returns pairs.  It would have to return something else.

Luke
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090715/9e46ee6d/attachment.html


More information about the Haskell-Cafe mailing list