Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partially revert #596, give PAlternative (and friends) the correct kinds #606

Merged
merged 3 commits into from
Jun 18, 2024

Commits on Jun 16, 2024

  1. Partially revert TypeAbstractions-related changes in #596

    The changes in #596 cause `singletons-th` to use `TypeAbstractions` to
    explicitly quantify the kind variables of promoted class methods whenever the
    parent class has a standalone kind signature, thereby ensuring that the order
    of kind variables matches the order in which the user wrote them. At least,
    that was the intention. Unfortunately, as #605 reveals, this approach sometimes
    causes `singletons-th` to generate ill-kinded code for promoted class methods,
    and there isn't an obvious way to work around this limitation.
    
    As such, this patch reverts the `TypeAbstractions`-related changes from #596.
    Once again, `singletons-th` now does not make any guarantees about the order of
    kind variables for promoted class methods or their defunctionalization symbols.
    
    On the other hand, this patch _does_ keep the changes from #596 that cause
    `singletons-th` to propagate kind information from the parent class's
    standalone kind signature through to the promoted class methods'
    defunctionalization symbols, as this feature is useful independent of the
    `TypeAbstractions`-related changes. I have taken the opportunity to document
    why we do this in the new `Note [Propagating kind information from class
    standalone kind signatures]` in `D.S.TH.Promote`.
    
    I've removed the `T589` test case, as the functionality it was testing no
    longer exists after reverting the `TypeAbstractions`-related changes. I have
    also added a new `T605` test case that ensures that the regression from #605
    stays fixed. In a subsequent commit, I will add another test case that
    demonstrates that the kind propagation works as intended.
    
    Fixes #605.
    RyanGlScott committed Jun 16, 2024
    Configuration menu
    Copy the full SHA
    cc1c7f6 View commit details
    Browse the repository at this point in the history
  2. README.md: Document constraint limitations more thoroughly

    In particular, make note of the circumstances under which issues like #604.
    There is no way for `singletons-th` to generate code that avoids the problems
    in #604 in all cases, so we instead advise users to be wary when promoting code
    involving classes that are parameterized over higher-kinded type variables
    (e.g., `Alternative`).
    RyanGlScott committed Jun 16, 2024
    Configuration menu
    Copy the full SHA
    e16fecb View commit details
    Browse the repository at this point in the history
  3. Give PAlternative (and friends) the correct kinds

    Previously, `singletons-th` would generalize the kinds of `PAlternative` and
    related classes (e.g., `PMonadPlus`), as well of the kinds of the
    defunctionalization symbols for various classes that are parameterized over a
    higher-kinded type variable. As described in the "Class constraints" section of
    the `README.md`, the recommended workaround for this issue is to give the
    classes in question explicit kinds, so this patch does just that by giving
    `Alternative`, `MonadPlus`, etc. standalone kind signatures.
    
    This causes the code in `singletons-base` to deviate a bit from the original
    code in the `base` library. I have written a new `Note [Using standalone kind
    signatures not present in the base library]` and cited it in all of the places
    where such a deviation occurs.
    
    Fixes #604.
    RyanGlScott committed Jun 16, 2024
    Configuration menu
    Copy the full SHA
    e8cb2aa View commit details
    Browse the repository at this point in the history