[Haskell-cafe] Is there a better way to subtyping?

Erik Hesselink hesselink at gmail.com
Wed Mar 14 11:38:45 CET 2012


However, be aware that aFields, bFields and cFields are now partial
functions that will crash when applied to the wrong constructor. Not
a-okay in my book.

Erik

On Wed, Mar 14, 2012 at 02:24, John Meacham <john at repetae.net> wrote:
> Why not
>
> data Super
>        = SuperA {
>                commonFields :: ()
>                aFields :: ()
>                }
>        | SuperB {
>                commonFields :: ()
>                bFields :: ()
>                }
>        | SuperC {
>                commonFields :: ()
>                cFields :: ()
>                }
>
> reusing the common field names between constructors like this is a-okay.
>
>   John
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list