Deprecate and eventually remove IsSymbol in favor of the Reflectable type class · Issue #4314 · purescript/purescript · GitHub
Skip to content

Deprecate and eventually remove IsSymbol in favor of the Reflectable type class #4314

Open

Description

@purefunctor

Proposal

The type-level integers PR (#4207) introduced a poly-kinded type class for type reflection, aptly named Reflectable. Similarly, we plan to replace Symbol with String (#3103), similar to how type-level integers are kinded with the Int type. This proposal aims to deprecate the IsSymbol type class in favor of Reflectable, before eventually being removed in a v1 release of the compiler.

Examples

Any occurrence of IsSymbol can be substituted with Reflectable, and the same can be done with reflectSymbol into reflectType:

xs :: forall s. IsSymbol s => Proxy s -> String
xs = reflectSymbol

xs' :: forall s. Reflectable s String => Proxy s -> String
xs' = reflectType

We can add a Warn-ing to any consumers of the IsSymbol type class to use Reflectable instead.

Activity

  1. JordanMartinez commented on May 11, 2022

    @JordanMartinez
    Contributor

    👍 from me.

    However, I think a question to resolve is how this affects Prim.Docs. Something I noticed recently is that there isn't a kind Int there. And if there was, it has a conflict with the type Int. By renaming Symbol to String, I imagine we would have a similar conflict.

    Also, this issue may be a duplicate of #3103

  2. natefaubion commented on May 11, 2022

    @natefaubion
    Contributor

    Something I noticed recently is that there isn't a kind Int there. And if there was, it has a conflict with the type Int.

    There is no kind Int. The kind and type are the same thing. We should note in the docs that Int exists at the type level as well.

  3. JordanMartinez commented on May 11, 2022

    @JordanMartinez
    Contributor

    I'll open an issue for that. The same can be said for Boolean, right, except it's values aren't true and false because that would (at least currently) clash with type vars with similar names (e.g. foo :: forall true. true -> String).

  4. natefaubion commented on May 11, 2022

    @natefaubion
    Contributor

    true and false are reserved keywords. The identifier rules are the same for term and type level. You can't bind true as a type variable. There's no reason the true and false keywords can't be made available at the type level, it's just kind of weird. At the term level you can almost say they are magic bindings to foreign values, but this doesn't really make sense for type-level names. I don't know if that's a deal breaker though. Honestly, we could have just made the keywords True and False, and avoided all of that.

  5. JordanMartinez commented on May 11, 2022

    @JordanMartinez
    Contributor

    There's no reason the true and false keywords can't be made available at the type level, it's just kind of weird.

    I think it's clearer if we continue to use True/False at the type level...? And wasn't True/False at the value-level avoided because those values aren't actual ADTs?

  6. natefaubion commented on May 11, 2022

    @natefaubion
    Contributor

    And wasn't True/False at the value-level avoided because those values aren't actual ADTs?

    I guess? But we pattern match on them as an ADT, so the distinction seems completely moot to me. Take your pick:

    • true and false are magic, and behave like an ADT in pattern matching.
    • True and False are magic, and behave like an ADT in pattern matching.

    Anyway, I don't think we will be changing that, so it doesn't really matter. If we support other literals at the type level like Int and String, then I don't know why we couldn't support true and false.

  7. f-f commented on May 11, 2022

    @f-f
    Member

    How about adding True and False at the value level too? (while keeping the lowercase ones)

  8. JordanMartinez commented on May 11, 2022

    @JordanMartinez
    Contributor

    How about adding True and False at the value level too? (while keeping the lowercase ones)

    Mm.... I don't think we should do this.

  9. added this to the v0.16.0 milestone on May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions