Skip to content

Kinds update#157

Open
MatthijsBlom wants to merge 5 commits into
learnyouahaskell:mainfrom
MatthijsBlom:kinds-update
Open

Kinds update#157
MatthijsBlom wants to merge 5 commits into
learnyouahaskell:mainfrom
MatthijsBlom:kinds-update

Conversation

@MatthijsBlom
Copy link
Copy Markdown
Collaborator

GHC 9.6.7 (currently recommended by GHCup) uses GHC2021 as the default language, which includes PolyKinds.
This renders the :kind output shown in the book out of date.

I include an additional section on :k Functor because I feel it helps ground the rest of the discussion. With it, Functor's requirements are no longer only to be inferred, but also plain to see in the output of :k.

The [Char]String change is included because GHCi gives the latter (because string literals are used in the input).

Copy link
Copy Markdown
Collaborator

@pierluc-codes pierluc-codes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small detail to fix. thank you!

Woot, that works!
We see two new things here.
First, `Constraint` is the kind of constraints, i.e. the things that appear to the left of the `=>` in type signatures.
The `Ord Int` instance, for instance, has kind `Constraint`.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little bit imprecise: the instance is the implementation that satisfies the constaints. It's Ord Int itself that has kind Constraint, not the instance.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course 🤦

I think I confused myself by thinking of the implicitly passed dictionary, and by considering constraints singleton 'types'.

Now, to make this type a part of `Functor` we have to partially apply the first two type parameters so that we're left with `* -> *`.
That means that the start of the instance declaration will be: `instance Functor (Barry a b) where`.
Now, to make this type a part of `Functor` we have to fill the first two parameters so that we're left with `* -> *`.
That means that the start of the instance declaration will be: `instance Functor (Barry … …) where`.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for the ellipsis?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same names a and b are used for something else in the very next sentence. Justification for using c and d instead would come only after this sentence, which felt a bit weird, and without justification it would be arbitrary. Using something felt too heavy / noisy. I considered using _, but that being valid syntax might lead to some confusion. In the end I figured I'd try and see how reviewers would feel about . It's the shape of the instance type that is the point; arbitrary variable names need no drawing attention to.

@MatthijsBlom
Copy link
Copy Markdown
Collaborator Author

MatthijsBlom commented May 4, 2026

( Lemme squash the feedback commits before merging please. )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants