diff --git a/CHANGELOG.d/feature_make-quote-work-on-more-kinds.md b/CHANGELOG.d/feature_make-quote-work-on-more-kinds.md new file mode 100644 index 0000000000..7346df247d --- /dev/null +++ b/CHANGELOG.d/feature_make-quote-work-on-more-kinds.md @@ -0,0 +1 @@ +* Make `Prim.TypeError`'s `Quote` work on all kinds, not just kind `Type`. diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index ba0e3b1591..7f0b556ed7 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -149,6 +149,7 @@ If you would prefer to use different terms, please use the section below instead | [@mhmdanas](https://github.com/mhmdanas) | Mohammed Anas | [MIT license](http://opensource.org/licenses/MIT) | | [@kl0tl](https://github.com/kl0tl) | Cyril Sobierajewicz | [MIT license](http://opensource.org/licenses/MIT) | | [@PureFunctor](https://github.com/PureFunctor) | Justin Garcia | [MIT license](http://opensource.org/licenses/MIT) | +| [@xgrommx](https://github.com/xgrommx) | Denis Stoyanov | [MIT license](http://opensource.org/licenses/MIT) | ### Contributors using Modified Terms diff --git a/lib/purescript-cst/src/Language/PureScript/Environment.hs b/lib/purescript-cst/src/Language/PureScript/Environment.hs index 0e7e5731c0..db3dcdcd97 100644 --- a/lib/purescript-cst/src/Language/PureScript/Environment.hs +++ b/lib/purescript-cst/src/Language/PureScript/Environment.hs @@ -429,7 +429,7 @@ primTypeErrorTypes = , (primSubName C.typeError "Fail", (kindDoc -:> kindConstraint, ExternData [Nominal])) , (primSubName C.typeError "Warn", (kindDoc -:> kindConstraint, ExternData [Nominal])) , (primSubName C.typeError "Text", (kindSymbol -:> kindDoc, ExternData [Phantom])) - , (primSubName C.typeError "Quote", (kindType -:> kindDoc, ExternData [Phantom])) + , (primSubName C.typeError "Quote", (tyForall "k" kindType $ tyVar "k" -:> kindDoc, ExternData [Phantom])) , (primSubName C.typeError "QuoteLabel", (kindSymbol -:> kindDoc, ExternData [Phantom])) , (primSubName C.typeError "Beside", (kindDoc -:> kindDoc -:> kindDoc, ExternData [Phantom, Phantom])) , (primSubName C.typeError "Above", (kindDoc -:> kindDoc -:> kindDoc, ExternData [Phantom, Phantom])) diff --git a/src/Language/PureScript/Errors.hs b/src/Language/PureScript/Errors.hs index 14c7798476..7d5752f982 100644 --- a/src/Language/PureScript/Errors.hs +++ b/src/Language/PureScript/Errors.hs @@ -1861,7 +1861,7 @@ toTypelevelString (TypeLevelString _ s) = Just . Box.text $ decodeStringWithReplacement s toTypelevelString (TypeApp _ (TypeConstructor _ f) x) | f == primSubName C.typeError "Text" = toTypelevelString x -toTypelevelString (TypeApp _ (TypeConstructor _ f) x) +toTypelevelString (TypeApp _ (KindApp _ (TypeConstructor _ f) _) x) | f == primSubName C.typeError "Quote" = Just (typeAsBox maxBound x) toTypelevelString (TypeApp _ (TypeConstructor _ f) (TypeLevelString _ x)) | f == primSubName C.typeError "QuoteLabel" = Just . line . prettyPrintLabel . Label $ x diff --git a/tests/purs/failing/ProgrammablePolykindedTypeErrorsTypeString.out b/tests/purs/failing/ProgrammablePolykindedTypeErrorsTypeString.out new file mode 100644 index 0000000000..4968c73575 --- /dev/null +++ b/tests/purs/failing/ProgrammablePolykindedTypeErrorsTypeString.out @@ -0,0 +1,18 @@ +Error found: +in module Main +at tests/purs/failing/ProgrammablePolykindedTypeErrorsTypeString.purs:23:7 - 23:17 (line 23, column 7 - line 23, column 17) + + A custom type error occurred while solving type class constraints: + + Don't want to show Just @Type String because. + + +while checking that type Fail (Beside (Beside (Text "Don\'t want to show ") (... ...)) (Text " because.")) => String + is at least as general as type String +while checking that expression someString + has type String +in value declaration main + +See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information, +or to contribute content related to this error. + diff --git a/tests/purs/failing/ProgrammablePolykindedTypeErrorsTypeString.purs b/tests/purs/failing/ProgrammablePolykindedTypeErrorsTypeString.purs new file mode 100644 index 0000000000..575251c093 --- /dev/null +++ b/tests/purs/failing/ProgrammablePolykindedTypeErrorsTypeString.purs @@ -0,0 +1,23 @@ +-- @shouldFailWith NoInstanceFound + +module Main where + +import Prelude +import Prim.TypeError +import Effect (Effect) +import Effect.Console (log) + +data Maybe :: forall k. k -> Type +data Maybe a + +foreign import data Nothing :: forall k. Maybe k +foreign import data Just :: forall k. k -> Maybe k + +someString :: Fail (Text "Don't want to show " <> Quote (Just String) <> Text " because.") => String +someString = "someString" + +infixl 6 type Beside as <> + +main :: Effect Unit +main = do + log someString