class constraint in data kind definition

92 Views Asked by At

I couldn't make the following compile:

class Typeable f => Foo f where
    data Bar :: Typeable

In other words, I wanted to define a class Foo, which have an associated type that must be an instance of Typeable.

It looks like I can define the same thing with FunctionalDependencies:

class (Typeable b,Typeable f) => Foo f b | f -> b where

So how can I do the same thing with TypeFamilies?

1

There are 1 best solutions below

0
On BEST ANSWER

I haven't checked it, but I believe this should work:

class (Typeable f, Typeable (Bar f)) => Foo f where data Bar f :: *