[GHC] #9250: let makes function too much specific

#9250: let makes function too much specific --------------------------+------------------------------------------------ Reporter: | Owner: KommuSoft | Status: new Type: bug | Milestone: Priority: low | Version: 7.6.3 Component: | Operating System: Unknown/Multiple Compiler | Type of failure: Incorrect result at runtime Keywords: | Test Case: Architecture: x86_64 | Blocking: (amd64) | Difficulty: | Unknown | Blocked By: | Related Tickets: | --------------------------+------------------------------------------------ Say you define a `myadd` function: let myadd x y = x + y Then the type is `Num a => a -> a -> a`. If on the other hand, you define the method using currying: let myadd2 \x -> \y -> x + y The type is more specific: `Integer -> Integer -> Integer`. Strangely enough `:t \x -> \y -> x + y` returns the more general form. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9250 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9250: let makes function too much specific ------------------------------------------------+-------------------------- Reporter: KommuSoft | Owner: Type: bug | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Incorrect result at runtime | (amd64) Test Case: | Difficulty: Blocking: | Unknown | Blocked By: | Related Tickets: ------------------------------------------------+-------------------------- Description changed by KommuSoft: Old description:
Say you define a `myadd` function:
let myadd x y = x + y
Then the type is `Num a => a -> a -> a`. If on the other hand, you define the method using currying:
let myadd2 \x -> \y -> x + y
The type is more specific: `Integer -> Integer -> Integer`. Strangely enough `:t \x -> \y -> x + y` returns the more general form.
New description: Say you define a `myadd` function: let myadd x y = x + y Then the type is `Num a => a -> a -> a`. If on the other hand, you define the method using currying: let myadd2 \x -> \y -> x + y The type is more specific: `Integer -> Integer -> Integer`. Strangely enough `:t \x -> \y -> x + y` returns the more general form. URL: http://stackoverflow.com/questions/24481024/why-does-currying- anonymous-functions-change-haskells-type-inference-from-num-t -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9250#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9250: let makes function too much specific ------------------------------------------------+-------------------------- Reporter: KommuSoft | Owner: Type: bug | Status: closed Priority: low | Milestone: Component: Compiler | Version: 7.6.3 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Incorrect result at runtime | (amd64) Test Case: | Difficulty: Blocking: | Unknown | Blocked By: | Related Tickets: ------------------------------------------------+-------------------------- Changes (by simonpj): * status: new => closed * resolution: => invalid Comment: There are good answers on !StackOverflow. I believe, though you do not say so, that you are describing GHCi. `let` does generalisation, subject to the monomorphism restriction (like all top level bindings); `:type` ignores the monomorphism restriction (it isn't a top level binding). Do re-open if you think there is a bug here. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9250#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC