# GHC+DH Weekly Update #7, 2023-06-14

**URL:** <https://discourse.haskell.org/t/ghc-dh-weekly-update-7-2023-06-14/6444>\
**Category:** Uncategorized\
**Created:** [June 14, 2023, 2:25pm UTC](https://discourse.haskell.org/t/ghc-dh-weekly-update-7-2023-06-14/6444 "2023-06-14T14:25:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sand-witch](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/sand-witch/32/4505_2.png) [@sand-witch](https://discourse.haskell.org/u/sand-witch)\
**Post date:** [June 14, 2023, 2:25pm UTC](https://discourse.haskell.org/t/ghc-dh-weekly-update-7-2023-06-14/6444/1 "2023-06-14T14:25:06Z")

</div>

This week Vlad and I created individual tickets for all remaining parts of [GHC Proposal #425 “Invisible binders in type declarations”](https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0425-decl-invis-binders.rst):

- [#23501](https://gitlab.haskell.org/ghc/ghc/-/issues/23501) “Wildcard binders in type declarations”
- [#23502](https://gitlab.haskell.org/ghc/ghc/-/issues/23502) “Kind inference for invisible binders in type declarations”
- [#23515](https://gitlab.haskell.org/ghc/ghc/-/issues/23515) “Type/data instances: require that the instantiation is determined by the LHS alone”
- [#23512](https://gitlab.haskell.org/ghc/ghc/-/issues/23512) “Type/data instances: require that variables on the RHS are mentioned on the LHS”
- [#23510](https://gitlab.haskell.org/ghc/ghc/-/issues/23510) “Implement the `-Wimplicit-rhs-quantification` warning”
- [#23514](https://gitlab.haskell.org/ghc/ghc/-/issues/23514) “Remove arity inference in type declarations”

And immediately began to solve them resulting in the following merge requests:

- [!10644](https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10644) “Type/data instances: require that variables on the RHS are mentioned on the LHS”
- [!10638](https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10638) “Implement the `-Wimplicit-rhs-quantification` warning”
- [!10660](https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10660) “Remove arity inference in type declarations”

One of those issues turned out to be more difficult to solve because it involves modifying the type checker ([#23515](https://gitlab.haskell.org/ghc/ghc/-/issues/23515)). I’m currently in the process of debugging a compiler crash caused by my changes

```haskell
No skolem info - we could not find the origin of the following variables
  [(UnkSkol (please report this as a bug)
    Call stack:
        CallStack (from HasCallStack):
          unkSkolAnon, called at compiler/GHC/Tc/Types/Origin.hs:315:42 in ghc-9.7-inplace:GHC.Tc.Types.Origin
          unkSkol, called at compiler/GHC/Tc/Utils/TcType.hs:583:31 in ghc-9.7-inplace:GHC.Tc.Utils.TcType
          vanillaSkolemTvUnk, called at compiler/GHC/Types/Var.hs:1094:56 in ghc-9.7-inplace:GHC.Types.Var,
    [k3])]
This should not happen, please report it as a bug following the instructions at:
https://gitlab.haskell.org/ghc/ghc/wikis/report-a-bug

```

Here is a summary of the changes implemented in the submitted merge requests:

1. Type synonym definitions that rely on outermost kind signatures to bring variables into scope must be rewritten with `@k`-binders:

2. Type and data family instances that rely on outermost kind signatures to bring variables into scope now require either an explicit `forall` or mentioning the variables on the left-hand side.

3. The subtle and fragile arity inference algorithm was removed. Now GHC infers the smallest possible arity making examples like this possible:

Finally, my fix for `-Wterm-variable-capture` was reviewed by Ryan (thank you!) and merged in commit [b84a2900](https://gitlab.haskell.org/ghc/ghc/-/commit/b84a29005ac0b258e0bad04b0acf933b71bd6e98).

* * *

This work is funded by [Serokell](https://serokell.io/)

---

<div class="post-metadata">

**Author:** ![int-index](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/int-index/32/4156_2.png) [@int-index](https://discourse.haskell.org/u/int-index)\
**Post date:** [June 14, 2023, 2:27pm UTC](https://discourse.haskell.org/t/ghc-dh-weekly-update-7-2023-06-14/6444/2 "2023-06-14T14:27:33Z")

</div>

This week I attended ZuriHac and the colocated GHC Workshop, where I had the opportunity to discuss some tricky design issues with other GHC developers.

This resulted in the following proposal amendment to `StandaloneKindSignatures` that aims to reconcile them with `ExtendedForAllScope`:

- [#592](https://github.com/ghc-proposals/ghc-proposals/pull/592) “Scoped kind variables in standalone kind signatures”

The discussion of [#22762](https://gitlab.haskell.org/ghc/ghc/-/issues/22762) “eqType, tcEqType, and foralls” led us to the conclusion that we probably want visibility coercions in Core. A prototype implementation of this idea by Matthew Craven can be found at [!10331](https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10331) “Track visibility in forall-coercions”.

It also turned out that there is a subtle bug that led GHC to unify `forall a. t` with `forall a -> t` if it was hidden underneath another `forall`:

```haskell
type D :: forall j -> forall i. (i -> j) -> Type
data D :: forall j -> forall i -> (i -> j) -> Type
                        -- ^^^
                        -- incorrectly accepted despite different forall visibility flags

```

I submitted a fix for this in [!10656](https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10656) "Check visibility of nested foralls in `can_eq_nc`".

Finally, here’s a fun little story about explicit imports. While working on one of the tickets, I was faced with the following error message:

```haskell
Expected a type, but found something with kind ‘Type’

```

It took me a disproportionally long amount of time figure it out, but it turned out that the `Type` that was in scope simply came from `Language.Haskell.TH.Syntax` instead of `Data.Kind`. As soon as I fixed this with a qualified import, I was able to add standalone kind signatures to `Code` and `TExp` in commit [`a0c27cee2394`](https://gitlab.haskell.org/ghc/ghc/-/commit/a0c27cee239462bb9346c8fdbe7f6fd1e6f265a5).
