Re: [Haskell-cafe] Can subclass override its super-class' default implementation of a function?

2009-04-28 Thread david48
On Mon, Apr 27, 2009 at 11:00 PM, siki wrote: > > I'm not sure if this is possible at all. I'd like to do something like this: > > class A a where >    foo :: a -> Double > >    foo a = 5.0 > > > class (A a) => B a where >    foo a = 7.0 I probably don't understand the question properly, but I do

Re: [Haskell-cafe] Can subclass override its super-class' default implementation of a function?

2009-04-27 Thread Donn Cave
Quoth siki , > The actual problem is quite similar to the one that I provided or to the one > in the description of the proposed extension that you linked. > > Someone on another forum suggested record functions but I'm not sure I > understood correctly how that would work around this problem. An

Re: [Haskell-cafe] Can subclass override its super-class' default implementation of a function?

2009-04-27 Thread siki
The actual problem is quite similar to the one that I provided or to the one in the description of the proposed extension that you linked. Someone on another forum suggested record functions but I'm not sure I understood correctly how that would work around this problem. Any suggestion is greatl

Re: [Haskell-cafe] Can subclass override its super-class' default implementation of a function?

2009-04-27 Thread Ryan Ingram
No, but functionality similar to this has been proposed several times, under the name "Class Aliases" [1]. The big problem is in the definition of B: class (A a) => B a where ... In this case, you must make something an instance of A before it can be an instance of B, and, in order to make som

Re: [Haskell-cafe] Can subclass override its super-class' default implementation of a function?

2009-04-27 Thread Martijn van Steenbergen
siki wrote: I'm not sure if this is possible at all. I'd like to do something like this: class A a where foo :: a -> Double foo a = 5.0 class (A a) => B a where foo a = 7.0 This is currently not possible in Haskell. It's been proposed, though: http://haskell.org/haskellwik

[Haskell-cafe] Can subclass override its super-class' default implementation of a function?

2009-04-27 Thread siki
I'm not sure if this is possible at all. I'd like to do something like this: class A a where foo :: a -> Double foo a = 5.0 class (A a) => B a where foo a = 7.0 data Blah = Blah data Bar = Bar instance A Blah instance B Bar let blah = Blah bar = Bar foo blah -- should