[Haskell-beginners] pattern matching on a common element

Daniel Trstenjak daniel.trstenjak at gmail.com
Fri Nov 25 17:18:21 UTC 2016


Hi Brian,

> interestingly in my journeys through the intertubes I have not found a
> single mention of using the "()" syntax in place of the
> "{fieldname=value, ...}" syntax as the generator.

The '()' isn't part of the 'data constructor' (the usual term for A1/A2/A3),
but sometimes needed to help the compiler to make an unambiguous parsing of the expression.

These are all valid expressions:

    i $ A1 "foo" 3.2   -- '$' is often used to get rid of parentheses

    let a1 = A1 "foo" 3.2 in i a1

Greetings,
Daniel


More information about the Beginners mailing list