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
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
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
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
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
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