Should be straight forwardsimplest example is...
class A a
data D = D1
instance A D
fine.D is declared to be a member of type class A
what about.
class A a
type T = (forall x.Num x=x)
instance A T
error!...
Illegal polymorphic or qualified type: forall x. (Num x) = x
class A a
type T = (forall x.Num x=x)
instance A T
type declares a synonym, like #define in C - but working only on types. So,
essentially, you wrote
instance A (forall x.Num x = x)
which is not very Haskelly.
I am simply trying to state that all members of typeclass Num are of
typeclass
On Jan 10, 2008 1:03 PM, Nicholls, Mark [EMAIL PROTECTED] wrote:
Should be straight forwardsimplest example is...
class A a
data D = D1
instance A D
fine.D is declared to be a member of type class A
what about.
class A a
type T = (forall x.Num x=x)
instance A T
on?
-Original Message-
From: Luke Palmer [mailto:[EMAIL PROTECTED]
Sent: 10 January 2008 13:14
To: Nicholls, Mark
Cc: haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] confusion about 'instance'
On Jan 10, 2008 1:03 PM, Nicholls, Mark [EMAIL PROTECTED] wrote:
Should be straight forward
Hello Mark,
Thursday, January 10, 2008, 4:25:20 PM, you wrote:
instance Num a = A a
Mean the same thing as
instance A (forall a.Num a=a)
programmers going from OOP world always forget that classes in Haskell
doesn't the same as classes in C++. *implementation* of this instance
require to
class A a
type T = (forall x.Num x=x)
instance A T
type declares a synonym, like #define in C - but working only on
types.
So, essentially, you wrote
Yep that's fine..
instance A (forall x.Num x = x)
Yep
which is not very Haskelly.
Hmmm...
I am simply trying to
On Jan 10, 2008 1:25 PM, Nicholls, Mark [EMAIL PROTECTED] wrote:
Thanks for your response, I think you helped me on one of my previous
abberations.
Hmmmthis all slightly does my head inon one hand we have
typesthen type classes (which appear to be a relation defined on
-Original Message-
From: Bulat Ziganshin [mailto:[EMAIL PROTECTED]
Sent: 10 January 2008 13:36
To: Nicholls, Mark
Cc: Luke Palmer; haskell-cafe@haskell.org
Subject: Re[2]: [Haskell-cafe] confusion about 'instance'
Hello Mark,
Thursday, January 10, 2008, 4:25:20 PM, you
On Jan 10, 2008 2:04 PM, Nicholls, Mark [EMAIL PROTECTED] wrote:
I can translate OO into mathematical logic pretty easily, I was trying
to do the same thing (informally of course) with Haskellbut things
are not quite what they appearnot because of some OO hang up (which
I probably have
Thanks for your response, I think you helped me on one of my
previous
abberations.
Hmmmthis all slightly does my head inon one hand we have
typesthen type classes (which appear to be a relation defined on
types)then existential types...which now appear not to be
treated
Nicholls, Mark wrote:
Thanks for your response, I think you helped me on one of my previous
abberations.
Hmmmthis all slightly does my head inon one hand we have
typesthen type classes (which appear to be a relation defined on
types)then existential types...which now appear not
On Jan 10, 2008 1:36 PM, Bulat Ziganshin [EMAIL PROTECTED] wrote:
Hello Mark,
Thursday, January 10, 2008, 4:25:20 PM, you wrote:
instance Num a = A a
Mean the same thing as
instance A (forall a.Num a=a)
programmers going from OOP world always forget that classes in Haskell
doesn't
Nicholls, Mark wrote:
My confusion is not between OO classes and Haskell classes, but exactly
are the members of a Haskell type class...I'd naively believed them to
be types (like it says on the packet!)...but now I'm not so sure.
Which packet?
Classes are not types.
Classes are groups of
-Original Message-
From: Jules Bean [mailto:[EMAIL PROTECTED]
Sent: 10 January 2008 14:22
To: Nicholls, Mark
Cc: Bulat Ziganshin; haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] confusion about 'instance'
Nicholls, Mark wrote:
My confusion is not between OO classes
]: [Haskell-cafe] confusion about 'instance'
On Jan 10, 2008 2:04 PM, Nicholls, Mark [EMAIL PROTECTED]
wrote:
I can translate OO into mathematical logic pretty easily, I was
trying
to do the same thing (informally of course) with Haskellbut
things
are not quite what they appear
Nicholls, Mark wrote:
I only have 1 type.
If I say my name is mark twice, it doesn't mean I belong to set of
objects called Mark twice
Typeclasses define not only sets of types, but a common interface for
these types, too. An analogy would be to say:
I have a name, and it is Marc.
On Thu, 10 Jan 2008, Nicholls, Mark wrote:
Existential:
newtype Numeric = forall a. Num a = Numeric a
My compiler doesn't like this A newtype constructor cannot have an
existential context,
Universal:
newtype Numeric' = Numeric' (forall a. Num a = a)
Not so sure I understand
Nicholls, Mark wrote:
Classes are groups of types. Sets of types. Classifications of types.
I had them down as an n-ary relation on typessomeone's said
something somewhere that's made me question that...but I think I
misinterpreted themso I may default back to n-ary relation.
Yes,
If I say my name is mark twice, it doesn't mean I belong to set of
objects called Mark twice
Yes, but instance declaration doesn't only state that some type
belongs to some class. It also provides some operations on this type.
___
Haskell-Cafe
On 10 Jan 2008, at 6:04 AM, Nicholls, Mark wrote:
-Original Message-
From: Bulat Ziganshin [mailto:[EMAIL PROTECTED]
Sent: 10 January 2008 13:36
To: Nicholls, Mark
Cc: Luke Palmer; haskell-cafe@haskell.org
Subject: Re[2]: [Haskell-cafe] confusion about 'instance'
Hello Mark
20 matches
Mail list logo