Title: Is `moveQuantifiersToFront` still needed? · Issue #4495 · purescript/purescript · GitHub
Open Graph Title: Is `moveQuantifiersToFront` still needed? · Issue #4495 · purescript/purescript
X Title: Is `moveQuantifiersToFront` still needed? · Issue #4495 · purescript/purescript
Description: Description For context, see #4487 (comment) Previously, type classes with type variables in the class member must have been introduced either via a forall on the type class member type signature or via a type variable from the type clas...
Open Graph Description: Description For context, see #4487 (comment) Previously, type classes with type variables in the class member must have been introduced either via a forall on the type class member type signature o...
X Description: Description For context, see #4487 (comment) Previously, type classes with type variables in the class member must have been introduced either via a forall on the type class member type signature o...
Opengraph URL: https://github.com/purescript/purescript/issues/4495
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Is `moveQuantifiersToFront` still needed?","articleBody":"## Description\r\n\r\nFor context, see https://github.com/purescript/purescript/issues/4487#issuecomment-1648314157\r\n\r\nPreviously, type classes with type variables in the class member must have been introduced either via a `forall` on the type class member type signature or via a type variable from the type class head.\r\n\r\n```purs\r\nclass Foo tyVarFromClassHead where\r\n foo :: forall tyVarFromMemberSig. tyVarFromMemberSig -> tyVarFromClassHead -> invalidTyVar\r\n```\r\n\r\nWith the advent of VTAs, we can stop using `Proxy` args to indicate to the compiler which type class instance to use to solve a type class constraint. This further enables us to define type classes with type parameters in the class head that do not appear within a class member's type signature. \r\n\r\n```purs\r\nclass Foo tyVarFromClassHead where\r\n foo :: Int\r\n```\r\n\r\nHowever, this decision also allows the type variables introduced at the member's type signature to shadow the ones introduced in the type class head:\r\n\r\n```purs\r\nclass Foo a where\r\n foo \r\n :: forall a\r\n . a -- 'a' here refers to member's 'a', not class head 'a'\r\n -> Int\r\n```\r\n\r\nThe full type signature of `foo` is then:\r\n```purs\r\nfoo :: forall @a. Foo a => (forall a. a -> Int)\r\nfoo = -- \u003cinstance implementation>\r\n```\r\n\r\nA long time ago (i.e. `purs@0.5.5`-era), the `moveQuantifiersToFront` function was added to fix #376. However, this function does not appear to respect scope and seems to incorrectly convert the above type signature into:\r\n```purs\r\nfoo :: forall @a a. Foo a => a -> Int\r\nfoo = -- \u003cinstance implementation>\r\n```\r\n\r\nWhen coupled with [`addVisibility`](https://github.com/purescript/purescript/blob/master/src/Language/PureScript/Types.hs#L553-L562), the type signature further deteriorates by copying the type variable visibility of the class head's `a` into the member signature's `a`:\r\n```purs\r\nfoo :: forall @a @a. Foo a => a -> Int\r\nfoo = -- \u003cinstance implementation>\r\n```\r\n\r\nSo, should `moveQuantifiersToFront` be removed? Or is it still needed?\r\n\r\n## PureScript version\r\n\r\n0.15.10 (if `UnusedDeclaration` error is removed from that version via #4494)\r\n","author":{"url":"https://github.com/JordanMartinez","@type":"Person","name":"JordanMartinez"},"datePublished":"2023-07-24T23:03:02Z","url":"https://github.com/purescript/purescript/issues/4495"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d2a07023-e829-5186-4528-e897c5195622 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 80E0:29FFA9:815DB8:A57442:6B00E752 |
| html-safe-nonce | a4b897bd57303d7dfb066b5725cf3f2dd633e462b7d2886c06cb63b2c1bae88b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MEUwOjI5RkZBOTo4MTVEQjg6QTU3NDQyOjZCMDBFNzUyIiwidmlzaXRvcl9pZCI6IjQwMjY2NDk2OTE0MDI4NTYyNzQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9b9985dfefc5c832d7663c9e1e39731ca4f96e0fdbdbe69a75da978a09e4005d |
| hovercard-subject-tag | issue:1819272041 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/purescript/purescript/4495/issue_layout |
| twitter:image | https://opengraph.githubassets.com/dd675cdba57e5e2964baa3c7e086b0dfa607b50679c8b1382c61803a8551ad49/purescript/purescript/issues/4495 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/dd675cdba57e5e2964baa3c7e086b0dfa607b50679c8b1382c61803a8551ad49/purescript/purescript/issues/4495 |
| og:image:alt | Description For context, see #4487 (comment) Previously, type classes with type variables in the class member must have been introduced either via a forall on the type class member type signature o... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JordanMartinez |
| hostname | github.com |
| expected-hostname | github.com |
| None | 27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14 |
| turbo-cache-control | no-preview |
| go-import | github.com/purescript/purescript git https://github.com/purescript/purescript.git |
| octolytics-dimension-user_id | 6556677 |
| octolytics-dimension-user_login | purescript |
| octolytics-dimension-repository_id | 13206906 |
| octolytics-dimension-repository_nwo | purescript/purescript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 13206906 |
| octolytics-dimension-repository_network_root_nwo | purescript/purescript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 624179fb8b88d26ba5bba08894eb60a1c5a1d93d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width