-- Is it true that instances must exists before we can run function
or
make subclasses?
instance C1 Person where
instance C1 Employee where
You can *call* class methods only for types which are instances of
that
class.
But you can certain *write* functions that make use of the class
m
Patrick Browne wrote:
Hi,
I am studying the Haskell type class system as part of a language
comparison thesis. At this point I am looking at how default function
definitions are handled in classes. Functions are usually defined in
instances, not classes. I appreciate that the code below may not b
On Jul 24, 2010, at 10:59 AM, Patrick Browne wrote:
class C1 c1 where
age :: c1 -> Integer
-- add default impl, can this be defined only once at class level?
-- Can this function be redefined in a *class* lower down the
heirarchy?
age(c1) = 1
Yes, but keep in mind that the hierarchy is o
On Saturday 24 July 2010 19:59:26, Patrick Browne wrote:
>
> module A where
> data Person = Person String Integer deriving Show
> data Employee = Employee String Integer deriving Show
>
> class C1 c1 where
> age :: c1 -> Integer
> -- add default impl, can this be defined only once at class level
Hi,
I am studying the Haskell type class system as part of a language
comparison thesis. At this point I am looking at how default function
definitions are handled in classes. Functions are usually defined in
instances, not classes. I appreciate that the code below may not be an
appropriate way to