[GHC] #9177: Suggest Int when user uses int

#9177: Suggest Int when user uses int ------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #1388 | ------------------------------------+------------------------------------- This ticket is a fork of #1388. We already give suggestions when the user mispells names, based on edit distance. But this does not cross the boundaries between different kind of names. It would be helpful if {{{Not in scope: type variable `int'}}} would also say {{{Did you mean the type constructor `Int'}}}? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9177 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9177: Suggest Int when user uses int -------------------------------------+------------------------------------ Reporter: nomeata | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #1388 -------------------------------------+------------------------------------ Comment (by simonpj): Good idea. Want to implement it? Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9177#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9177: Suggest Int when user uses int -------------------------------------+------------------------------------ Reporter: nomeata | Owner: nomeata Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #1388 -------------------------------------+------------------------------------ Changes (by nomeata): * owner: => nomeata Comment: Almost done, this is my ZuriHac warm up ticket :-) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9177#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9177: Suggest Int when user uses int -------------------------------------+------------------------------------ Reporter: nomeata | Owner: nomeata Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #1388 -------------------------------------+------------------------------------ Comment (by nomeata): I have two variants: One that suggests `Integer` when `integer` is typed, and one that suggests even `Integer` if `integerr` is typed (using the same edit distance metric stuff). I’ll push the first, followed by the second, so that one can easily revert. Of course there is no limit on how smart the error message can be. In `type Foo = eq`, one cannot mean `Eq` (as it is a class), but that is not available on the level of `OccNames`. But I guess the suggestion is still an improvement. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9177#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9177: Suggest Int when user uses int -------------------------------------+------------------------------------ Reporter: nomeata | Owner: nomeata Type: feature request | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #1388 -------------------------------------+------------------------------------ Changes (by nomeata): * status: new => patch Comment: Another example of this logic leading the user into a direction that will cause a different error: {{{ Prelude> let foo = () Prelude> let g = Foo -- good suggestion <interactive>:5:9: Not in scope: data constructor ‘Foo’ Perhaps you meant variable ‘foo’ (line 2) Prelude> let f (Foo x) = x -- bad suggestion <interactive>:3:8: Not in scope: data constructor ‘Foo’ Perhaps you meant variable ‘foo’ (line 2) }}} Anyways, I pushed it to `wip/T9177` for review (but will likely push to master in the next days; people can still complain afterwards). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9177#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9177: Suggest Int when user uses int -------------------------------------+------------------------------------ Reporter: nomeata | Owner: nomeata Type: feature request | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #1388 -------------------------------------+------------------------------------ Comment (by simonpj): Sounds good to me. Do get someone at Zurihac to look it over and then push to master. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9177#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9177: Suggest Int when user uses int
-------------------------------------+------------------------------------
Reporter: nomeata | Owner: nomeata
Type: feature request | Status: patch
Priority: normal | Milestone:
Component: Compiler | Version: 7.8.2
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture: Unknown/Multiple
Type of failure: None/Unknown | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets: #1388
-------------------------------------+------------------------------------
Comment (by Joachim Breitner

#9177: Suggest Int when user uses int
-------------------------------------+------------------------------------
Reporter: nomeata | Owner: nomeata
Type: feature request | Status: patch
Priority: normal | Milestone:
Component: Compiler | Version: 7.8.2
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture: Unknown/Multiple
Type of failure: None/Unknown | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets: #1388
-------------------------------------+------------------------------------
Comment (by Joachim Breitner

#9177: Suggest Int when user uses int
-------------------------------------+------------------------------------
Reporter: nomeata | Owner: nomeata
Type: feature request | Status: patch
Priority: normal | Milestone:
Component: Compiler | Version: 7.8.2
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture: Unknown/Multiple
Type of failure: None/Unknown | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets: #1388
-------------------------------------+------------------------------------
Comment (by Joachim Breitner

#9177: Suggest Int when user uses int -------------------------------------+------------------------------------ Reporter: nomeata | Owner: nomeata Type: feature request | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #1388 -------------------------------------+------------------------------------ Changes (by nomeata): * status: patch => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9177#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

I have two variants: One that suggests `Integer` when `integer` is typed, and one that suggests even `Integer` if `integerr` is typed (using
#9177: Suggest Int when user uses int -------------------------------------+------------------------------------ Reporter: nomeata | Owner: nomeata Type: feature request | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #1388 -------------------------------------+------------------------------------ Comment (by goldfire): Replying to [comment:3 nomeata]: the same edit distance metric stuff). I’ll push the first, followed by the second, so that one can easily revert.
Of course there is no limit on how smart the error message can be. In
`type Foo = eq`, one cannot mean `Eq` (as it is a class), but that is not available on the level of `OccNames`. But I guess the suggestion is still an improvement. In case anyone is inspired to make this smarter, I'll note that `type Foo = Eq` is perfectly reasonable, in the presence of !ConstraintKinds. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9177#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9177: Suggest Int when user uses int -------------------------------------+------------------------------------ Reporter: nomeata | Owner: nomeata Type: feature request | Status: closed Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.8.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #1388 -------------------------------------+------------------------------------ Changes (by hvr): * milestone: => 7.10.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9177#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC