[GHC] #12782: Type inference shows (Num (a -> a), Num a)

#12782: Type inference shows (Num (a -> a), Num a) -------------------------------------+------------------------------------- Reporter: ciupakabra | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 (Type checker) | Keywords: | Operating System: Linux Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Defining f and g as:
f x = x + 1 g x y = x + y
Entering :t f . g gives: f . g :: (Num (a -> a), Num a) => a -> a -> a Formally, it is correct, since Num (a -> a) is never going to be a number. Though me and my tutor thought it might be a bug, and f . g shouldn't be recognised as a well-formed expression. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12782 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12782: Type inference shows (Num (a -> a), Num a) -------------------------------------+------------------------------------- Reporter: ciupakabra | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | Resolution: invalid | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by nomeata): * status: new => closed * resolution: => invalid Comment:
Num (a -> a) is never going to be a number.
It could be. Someone just has to give an `instance Num (a -> b)`. The compiler cannot assume that no such instance will ever be around. It seems to me that the compiler behaviour is ok and desired as is. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12782#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC