Re: [Haskell-cafe] Re: Existencial quantification and polymorphic datatypes (actually, components...)

2009-01-21 Thread Jake McArthur
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Gleb Alexeyev wrote: | Mauricio wrote: | | data SomeNum = SN (forall a. a) | | [...] | | you cannot do anything to the value you extract Maybe. Say you construct (SN x). If you later extract x, you can observe that it terminates (using seq,

Re: [Haskell-cafe] Re: Existencial quantification and polymorphic datatypes (actually, components...)

2009-01-21 Thread Jonathan Cast
On Wed, 2009-01-21 at 13:38 -0600, Jake McArthur wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Gleb Alexeyev wrote: | Mauricio wrote: | | data SomeNum = SN (forall a. a) | | [...] | | you cannot do anything to the value you extract Maybe. Say you construct (SN x). If you

Re: [Haskell-cafe] Re: Existencial quantification and polymorphic datatypes (actually, components...)

2009-01-21 Thread Jake McArthur
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Jonathan Cast wrote: | I think you meant to quote the definition | | data SomeNum = forall a. SN a Quite so. Thanks for clearing that up. - - Jake -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla -

[Haskell-cafe] Re: Existencial quantification and polymorphic datatypes (actually, components...)

2009-01-20 Thread Mauricio
4294967296 :: Integer (...) In the above you can see the polymorphism of the return type of fromInteger, it returns a Int8 or a Int32. You can see the polymorphism of the argument of show, it takes an Int8 or Int32 or Integer. The latest ghc-6.10.1 also allows avoiding use of SomeNum, see

[Haskell-cafe] Re: Existencial quantification and polymorphic datatypes (actually, components...)

2009-01-20 Thread Gleb Alexeyev
Mauricio wrote: But how is this: data SomeNum = forall a. SN a different from: data SomeNum = SN (forall a. a) In the first case the constructor SN can be applied to the monomorphic value of any type, it effectively hides the type of the argument. For example, you can have a list like

[Haskell-cafe] Re: Existencial quantification and polymorphic datatypes (actually, components...)

2009-01-20 Thread Gleb Alexeyev
I just thought that the shorter explanation could do better: the difference is in the types of the constructor functions. Code: {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE RankNTypes #-} data SomeNum1 = forall a. SN1 a data SomeNum2 = SN2 (forall a. a) ghci session: *Main :t

[Haskell-cafe] Re: Existencial quantification and polymorphic datatypes (actually, components...)

2009-01-20 Thread ChrisK
Great, thanks! I'm enlightened :) And no one had to hit you with a stick first! But how is this: data SomeNum = forall a. SN a different from: data SomeNum = SN (forall a. a) ? At a glance they look the same to me — but only the first is accepted by ghc. There is also the GADT syntax:

[Haskell-cafe] Re: Existencial quantification and polymorphic datatypes (actually, components...)

2009-01-20 Thread Mauricio
But how is this: data SomeNum = forall a. SN a different from: data SomeNum = SN (forall a. a) At a glance they look the same to me — but only the first is accepted by ghc. Following the link you pointed in the last message, I found this at 8.8.4.1: data T a = T1 (forall b. b - b - b) a If

Re: [Haskell-cafe] Re: Existencial quantification and polymorphic datatypes (actually, components...)

2009-01-20 Thread David Menendez
On Tue, Jan 20, 2009 at 2:51 PM, Mauricio briqueabra...@yahoo.com wrote: But how is this: data SomeNum = forall a. SN a different from: data SomeNum = SN (forall a. a) At a glance they look the same to me — but only the first is accepted by ghc. Following the link you pointed in the last

Re: [Haskell-cafe] Re: Existencial quantification and polymorphic datatypes (actually, components...)

2009-01-20 Thread Luke Palmer
On Tue, Jan 20, 2009 at 1:14 PM, David Menendez d...@zednenem.com wrote: On Tue, Jan 20, 2009 at 2:51 PM, Mauricio briqueabra...@yahoo.com wrote: But how is this: data SomeNum = forall a. SN a different from: data SomeNum = SN (forall a. a) At a glance they look the same to me — but