Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: Question: Data Type for user selection (Brent Yorgey)
2. Re: Question: Data Type for user selection (Ertugrul Soeylemez)
----------------------------------------------------------------------
Message: 1
Date: Tue, 16 Aug 2011 10:29:51 -0400
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] Question: Data Type for user
selection
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Tue, Aug 16, 2011 at 09:54:52AM +0200, Ertugrul Soeylemez wrote:
> Brandon Allbery <[email protected]> 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.
No, he isn't.
data BasicSelect a where
SelectionNum :: Num a => a -> BasicSelect a
SelectionStr :: Show a => a -> BasicSelect a
'a' shows up in the result type of both constructors, so there is no
existential quantification going on here.
-Brent
------------------------------
Message: 2
Date: Tue, 16 Aug 2011 16:44:15 +0200
From: Ertugrul Soeylemez <[email protected]>
Subject: Re: [Haskell-beginners] Question: Data Type for user
selection
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII
Brent Yorgey <[email protected]> wrote:
> > That's a bit of a contradiction, because you are using existentials
> > yourself in your GADT.
>
> No, he isn't.
>
> data BasicSelect a where
> SelectionNum :: Num a => a -> BasicSelect a
> SelectionStr :: Show a => a -> BasicSelect a
>
> 'a' shows up in the result type of both constructors, so there is no
> existential quantification going on here.
Oh, right. How would one express this as an ADT? Seems impossible to
me.
Greets,
Ertugrul
--
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://ertes.de/
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 38, Issue 32
*****************************************