[Haskell-beginners] Type constructors sharing a common field
Benjamin Edwards
edwards.benj at gmail.com
Tue Apr 29 10:45:00 UTC 2014
In addition to the comments made by Daniel, as a general rule, you don’t
want a sum type with selectors functions as your example stands, because
you can end up with compiling programs like this:
module Main where
main :: IO ()main =
let p = Child 10
age = adultAge p
in print age
this craps out with an error at runtime.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140429/83a79eb8/attachment.html>
More information about the Beginners
mailing list