[Haskell-beginners] Program reliability and multiple data constructors; polymorphism

umptious umptious at gmail.com
Wed Apr 18 18:50:04 CEST 2012

And in partially answering my own question I forgot to add that this gives
you a less queasy-making way of identifying the cstr used to create a

--Also, the {} pattern can be used for matching a constructor regardless of
> the datatype elements even if you don't use records in the data declaration:
> data Foo = Bar | Baz Int
> g :: Foo -> Bool
> g Bar {} = True
> g Baz {} = False

Regarding my comments on the lack of good Haskell books, I just checked
LYAHFAGG and RWH and neither of them covered either the problem, or the two
mechanisms used for a solution. This is very poor, given that the problem
is such an obvious one and the solutions are such general mechanisms. I'm
pretty sure that Hutton doesn't cover this either - in fact "record syntax"
isn't even in the index.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120418/cad71a0d/attachment.htm>

More information about the Beginners mailing list