class Cls c where
type Ret c :: (Bar *) = * -- or a better name
foo :: c - Ret c
which isn't legal Haskell.
OK, that's exactly the same thing I've met when developing
compose-trans. I needed guarantees that something is a Monad.
My way of doing that was to make Bar (Monad in my case)
You can require the associated type to have a particular instance, like
this:
class (Bar (Ret c)) = Cls c where
type Ret c
foo :: c - Ret c
Another option is to use existential types:
data HasBar = forall a. Bar a = HasBar a
class Cls c where
foo :: c - HasBar
You then have to wrap
I think
instance Bar (Ret c) = Foo c where
...
will do what you are asking.
Alex
On Tue, Sep 29, 2009 at 10:25 PM, DNM dnme...@gmail.com wrote:
Dan, thanks again for the response.
I changed my code to use type families to let each Cls instance (actually a
more complicated instance in my
N.B. I'm a newbie to Haskell, and this problem is a bit complex, so
bear with me.
I'm using typeclasses to implement a sort of common interface for all
things -- call them things of type 'Cls' -- that can be expected to
implement a set of functions -- an 'interface' in OOP-speak. (Yes,
yes, I'm
Dan, thanks again for the response.
I changed my code to use type families to let each Cls instance (actually a
more complicated instance in my code) determine which Bar instance type it
will return, but this didn't seem to work. The problem is that the client
of the typeclass instance methds