Re: [Haskell-cafe] default function definitions

2010-07-25 Thread Malcolm Wallace
-- 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

[Haskell-cafe] default function definitions

2010-07-24 Thread Patrick Browne
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

Re: [Haskell-cafe] default function definitions

2010-07-24 Thread Daniel Fischer
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? --

Re: [Haskell-cafe] default function definitions

2010-07-24 Thread Alexander Solla
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

Re: [Haskell-cafe] default function definitions

2010-07-24 Thread Andrew Coppin
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