[GHC] #6022: GHC infers over-general types
GHC
cvs-ghc at haskell.org
Wed Oct 10 20:50:55 CEST 2012
#6022: GHC infers over-general types
---------------------------------+------------------------------------------
Reporter: simonpj | Owner:
Type: bug | Status: new
Priority: high | Milestone: 7.6.2
Component: Compiler | Version: 7.4.1
Keywords: | Os: Unknown/Multiple
Architecture: Unknown/Multiple | Failure: None/Unknown
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: |
---------------------------------+------------------------------------------
Comment(by carter):
While this is likely wrong code, it is perfectly reasonable to have vector
function num instances! (its not overly general, its just not
pedagogically helpful for new people starting in haskell)
eg given Num a , the instance Num (Vector a -> a), has a perfectly
natural (and useful) definition. and thus a Num instance for [a]-> a is
reasonable too!
however, maybe an alternative approach would be add a suppressable warning
for when a type class constraint is used which has no known instances?
here are example "similar ways" to write the same function, and their
respective types, in ghci 7.6.1
Prelude> let g x = (+) x $ head
Prelude> :t g
g :: Num ([a] -> a) => ([a] -> a) -> [a] -> a
Prelude> let h x y = x + head y
Prelude> :t h
h :: Num a => a -> [a] -> a
Prelude> let q x = (x +) . head
Prelude> :t q
q :: Num c => c -> [c] -> c
so it seems that the core of the issue in the case of the bad example in
this ticket is a syntactical one of making the intended composition.
Likewise, I think this isn't a bug, the type checker is giving a type that
the user can look at and see is "wrong" for their code!
i think rejecting code with that Num instance constraint would be bad.
Unless someone has a counter point, I think this issue should be closed.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/6022#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list