[GHC] #9173: Better type error messages
GHC
ghc-devs at haskell.org
Thu Jun 5 13:42:13 UTC 2014
#9173: Better type error messages
------------------------------------+-------------------------------------
Reporter: simonpj | Owner:
Type: bug | 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: |
------------------------------------+-------------------------------------
Generating better type-error messages is a hoary chestnut, but Herbert
brought my attention to
[https://pay.reddit.com/r/haskell/comments/26tcrk/curious_with_a_bit_of_beginner_ranting_about_some/
this thread on reddit], which has the following idea.
At the moment, from
{{{
module Foo where
addThree = \x -> x + 3 :: Int
y = addThree $ Just 5
}}}
we get this error:
{{{
Foo.hs:2:20
Couldn't match expected type `Int' with actual type `Maybe a0'
In the return type of a call of `Just'
In the second argument of `($)', namely `Just 5'
In the expression: addThree $ Just 5
}}}
Maybe we could generate this instead
{{{
Foo.hs:2:20
inferred: "Just 5" has type "Maybe a0"
expected: second argument of "($)" must have type "Int"
in the expression: addThree $ Just 5
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9173>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list