This recursive definition of T
fails to type-check.
class C a where
type T a :: Type
newtype Compose (f :: Type -> Type) (g :: Type -> Type) (a :: Type) = Compose {getCompose :: f (g a)}
instance C (Maybe a) where
type T (Maybe a) = NP (Compose T Identity) '[a]
Specific error:
• The associated type family ‘T’ should have 1 argument, but has been given none
• In the type instance declaration for ‘T’
In the instance declaration for ‘C (Maybe a)’
|
32 | type T (Maybe a) = NP (Compose T Identity) '[a]
| ^
- Why is GHC unable to do this?
- Is there a workaround?
The real class/instance looks like this:
instance Ema (MultiSite models) where
type RouteFor (MultiSite models) = NP (Compose RouteFor Site) models
This says that "the route for a multisite is an n-ary product of the routes for the individual sites", hence RouteFor
has to be defined recursively.