Ticket #6022 (new bug)
GHC infers over-general types
| Reported by: | simonpj | Owned by: | simonpj |
|---|---|---|---|
| Priority: | high | Milestone: | 7.8.1 |
| Component: | Compiler | Version: | 7.4.1 |
| Keywords: | Cc: | hackage.haskell.org@… | |
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | None/Unknown | Difficulty: | Unknown |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: |
Description
Consider
f x = x + head
GHC will (with no flags) will compile this almost-certainly-wrong program, giving f the type
f :: forall a. Num ([a] -> a) => ([a] -> a) -> [a] -> a
There's nothing wrong with that type, and in principle someone might later define a suitable instance of Num, but (a) it's not Haskell 98, and (b) it's unlikely to be right, so we've deferred a type error from the definition site of f to the (perhaps much later) call site.
I think GHC should complain, and require a type signature if that's what you really want. This came up on Stackoverflow
Change History
Note: See
TracTickets for help on using
tickets.
