[Haskell-beginners] Pattern matching is actually about matching constructors??

Kim-Ee Yeoh ky3 at atamo.com
Tue Dec 22 05:08:22 UTC 2015


On Tue, Dec 22, 2015 at 1:56 AM, Olumide <50295 at web.de> wrote:

> Is the operator :-: a constructor? I'm confused because the definition of
> :-: is not prefixed by the data keyword?


The confusion is that the pattern-matching for append, i.e. (.++), is done
infix style:

Empty .++ ys = ys
(x :-: xs) .++ ys = x :-: (xs .++ ys)

This defines (.++).

It doesn't define (:-:).

The definition of (.++) pattern matches on (:-:) in (.++)-infix style to do
the job.

-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20151222/ea8999fc/attachment.html>


More information about the Beginners mailing list