Anders Miltner
Anders Miltner

Reputation: 263

Can you not use DataKinds inside Associated Data Types?

I have the following type class

class BoolHolding h where
  data MyBool b :: 'Bool

However, I keep getting the error: Not in scope: data constructor ‘Bool’. Does Haskell not permit this for some reason, or is there away to include the data constructor? If not, why not?

Upvotes: 1

Views: 113

Answers (1)

Anders Miltner
Anders Miltner

Reputation: 263

Ok, there are 2 issues with what I did.

1: DataKinds only requires lifting the constructors, not the data types. So, the 'Bool needs only be Bool.

2: Kind signatures for data must have a return kind of *. I can insert data into the kind, but after all the applications have been done, I must eventually have a type. I did not have this.

For 2, all I had to do was change data to type and this restriction is no longer present.

Upvotes: 3

Related Questions