Re: [Haskell] Forcing Type Class Equality

2006-06-29 Thread Gerrit van den Geest

Hi John,


NB

the essence what I am trying to do is to define a proxy class Foo for 
class Ba1 I would have thought that something as simple as the 
following would have worked ??


class Ba1 a where
  dosomething :: a - IO ()

ba1 :: Ba1 a = a - IO ()
ba1 x = dosomething x

instance Ba1 Int where
  dosomething x = print x

instance Ba1 Char where
  dosomething x = print x

what I wish to do is declare another function



If you implement the proxy function like below, it should work:

class Ba1 a = Foo a where
 proxy :: a - IO ()
 proxy = ba1

I've made Foo a subclass of Ba1 with a member function proxy and a 
default implementation. I hope this will help you further..


Grt

PS Use the haskell-cafe list next time for this kind of questions.

___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


RE: [Haskell] Forcing Type Class Equality

2006-06-28 Thread john lask

NB

the essence what I am trying to do is to define a proxy class Foo for class 
Ba1 I would have thought that something as simple as the following would 
have worked ??


class Ba1 a where
  dosomething :: a - IO ()

ba1 :: Ba1 a = a - IO ()
ba1 x = dosomething x

instance Ba1 Int where
  dosomething x = print x

instance Ba1 Char where
  dosomething x = print x

what I wish to do is declare another function

class Foo a
instance Foo a = Ba1 a

proxy :: Foo a = a - IO ()
proxy x = ba1 x

_
realestate.com.au: the biggest address in property   
http://ninemsn.realestate.com.au


___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell