[Haskell-beginners] Question: Data Type for user selection
Ertugrul Soeylemez
es at ertes.de
Tue Aug 16 09:54:52 CEST 2011
Brandon Allbery <allbery.b at gmail.com> wrote:
> I think what you're reaching for here is a GADT:
>
> > data BasicSelect a where
> > SelectionNum :: Num a => a -> BasicSelect a
> > SelectionStr :: Show a => a -> BasicSelect a
>
> I think you otherwise end up with a typeclass or with existentials;
> both introduce complexity, and I think the existentials solution still
> allows anything to be stuffed into it, whereas you want to limit it to
> SelectionNum or SelectionStr. (Typeclasses at least require an
> instance to be defined first; but they don't prohibit people from
> doing so, if that's what you're after.)
That's a bit of a contradiction, because you are using existentials
yourself in your GADT.
Greets,
Ertugrul
--
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://ertes.de/
More information about the Beginners
mailing list