"InvalidInstanceHead" error when instance contains class of "Row Type"

Simple example:

class CCC :: Row Type -> Constraint
class CCC a

instance CCC (a::String)

error:

  Type class instance head is invalid due to use of type

    ( a :: String
    )

Why does this error occur? What does this error mean?
Please tell me some detailed information, thanks.

2 Likes

You need to go through RowList when defining instances for row types:

import Prim.RowList

class CCC :: Row Type -> Constraint
class CCC a

instance RowToList r (Cons "a" String Nil) => CCC r

compiles for me. I asked once for explanation for this, see this reddit thread.

2 Likes

I get it, thank you!