[GHC] #12020: Error message on use of != should suggest use of /=

#12020: Error message on use of != should suggest use of /= -------------------------------------+------------------------------------- Reporter: mhoermann | 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: -------------------------------------+------------------------------------- Currently when one uses != instead of /= it comes up with this error message {{{ Not in scope: ‘!=’ Perhaps you meant one of these: ‘Map.!’ (imported from Data.Map), ‘>=’ (imported from Prelude), ‘==’ (imported from Prelude) }}} Considering != is very common for unequal in other languages there should be a more helpful hint to use /= instead of or in addition to the current generic symbol error. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12020 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12020: Error message on use of != should suggest use of /= -------------------------------------+------------------------------------- Reporter: mhoermann | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 Resolution: | Keywords: 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 nomeata): This is a good idea, but it immediately leads towards implementing a more general concept, where with any name you can list “common misspellings” that are in scope with the original name, and are consulted if something is not in scope. How would that be implemented. How about a pragma like this? {{{ `(!=)` :: a -> a -> Bool {-# MISSPELLINGS (!=), (<>) #-} }}} Naturally, if such a symbol is properly in scope, then the misspelling should be ignored. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12020#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12020: Error message on use of != should suggest use of /= -------------------------------------+------------------------------------- Reporter: mhoermann | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 Resolution: | Keywords: 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): Replying to [comment:1 nomeata]: I like it, comments: Do you have more motivational examples, I have a feeling this would mostly be used for operators. Would it appear in `:info (/=)` output? What about `:info (!=)` whether or not it's defined. Would it be attached to the definition or definable in a separate module? Adding a custom error message. I take it that the first definition was supposed to be `(/=) :: a -> a -> Bool`: {{{#!hs class Eq a where (==) :: a -> a -> Bool (/=) :: a -> a -> Bool {-# MISSPELLINGS (/=) AS (!=) "‘Not equal to’ is (/=), syntactically emulating the the math symbol ≠" #-} class Eq a => Bits a where (.&.) :: a -> a -> a {-# MISSPELLINGS (.&.) AS (&) "Bitwise and is (.&.)." #-} (.|.) :: a -> a -> a {-# MISSPELLINGS (.|.) AS (|) "Bitwise or is (.|.)." #-} ... shiftL :: a -> Int -> a {-# MISSPELLINGS shiftL AS (<<) "Left shift" #-} }}} `(|)` doesn't parse but oh well {{{ ghci> 4 != 10 _--_ It looks like you're trying Ö Ö ,- to code. ‘Not equal to’ is (/=), syntactically || | ' emulating the the math symbol ≠. Try writing |\_|/ ‘4 /= 10’ instead. \_/ }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12020#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12020: Error message on use of != should suggest use of /= -------------------------------------+------------------------------------- Reporter: mhoermann | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 Resolution: | Keywords: 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 isn't a misspelling, so maybe it could suggest any alternate name: {{{#!hs and :: Foldable t => t Bool -> Bool {-# MISSPELLINGS and AS every "Determines whether every element of the structure is True." #-} or :: Foldable t => t Bool -> Bool {-# MISSPELLINGS or AS some "Determines whether some element of the structure is True." #-} }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12020#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC