Haskell Language Role Representational Role

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

An example of a parametric parameter of a type function:

data List a = Nil | Cons a (List a)

type family DoNotInspect x
type instance DoNotInspect x = List x

Here x is parametric because to determine the outcome of applying DoNotInspect to a type argument, the type function do not need to inspect x.

In this case, the role of x is representational. We can declare the role explicitly with the RoleAnnotations extension:

type role DoNotInspect representational


Got any Haskell Language Question?