[GHC] #11967: Custom message when showing functions, comparing functions, ...

#11967: Custom message when showing functions, comparing functions, ... -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: feature | Status: new request | Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- One of the [https://ghc.haskell.org/trac/ghc/wiki/Proposal/CustomTypeErrors#Examples examples] of type errors: {{{#!hs instance TypeError (Text "Cannot 'Show' functions." :$$: Text "Perhaps there is a missing argument?") => Show (a -> b) where showsPrec = error "unreachable" }}} We already have [https://hackage.haskell.org/package/base-4.8.2.0/docs/src/Text.Show.Function... Text.Show.Functions], is there a place in `base` for this along with `Ord (a -> b)` instances and co. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11967 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11967: Custom message when showing functions, comparing functions, ... -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 7.10.3 Resolution: | Keywords: | CustomTypeErrors Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * keywords: => CustomTypeErrors * cc: ekmett (added) * component: Compiler => Core Libraries Comment: Maybe the Core Libraries Committee can answer your question. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11967#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11967: Custom message when showing functions, comparing functions, ... -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 7.10.3 Resolution: | Keywords: | CustomTypeErrors Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Iceland_jack): This can be considered a more general question: would any of the core libraries benefit from custom type errors? I doubt it is only useful for EDSLs. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11967#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11967: Custom message when showing functions, comparing functions, ... -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 7.10.3 Resolution: | Keywords: | CustomTypeErrors Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Iceland_jack): I'll put this here, from a [https://twitter.com/paf31/status/734566028483657729 tweet] {{{#!hs instance TypeError (Text "Lists are not numbers!" :$$: Text "Use (++) or (Data.Monoid.<>) instead!") => Num [a] }}} {{{ ghci> "Hello" + " " + "World!" <interactive>:91:1: error: • Lists are not numbers! Use (++) or (Data.Monoid.<>) instead! • In the expression: "Hello" + " " + "World!" In an equation for ‘it’: it = "Hello" + " " + "World!" }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11967#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC