[GHC] #11994: ghci not applying defaulting when showing type

#11994: ghci not applying defaulting when showing type -------------------------------------+------------------------------------- Reporter: j.waldmann | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- This does not look right: {{{ Prelude> :set +t Prelude> 1e1000 Infinity it :: Fractional t => t }}} because the type actually is (defaulted to) `Double`? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11994 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11994: ghci not applying defaulting when showing type -------------------------------------+------------------------------------- Reporter: j.waldmann | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by j.waldmann: @@ -11,0 +11,8 @@ + + (but is it really? I don't see default rules for `Fractional` + in the ghc docs + https://downloads.haskell.org/~ghc/latest/docs/html/users_guide + /interactive-evaluation.html#extended-default-rules or in the language + standard https://www.haskell.org/onlinereport/decls.html#sect4.3.4 ) + + How can I find the defaulted type in `ghci`? New description: This does not look right: {{{ Prelude> :set +t Prelude> 1e1000 Infinity it :: Fractional t => t }}} because the type actually is (defaulted to) `Double`? (but is it really? I don't see default rules for `Fractional` in the ghc docs https://downloads.haskell.org/~ghc/latest/docs/html/users_guide /interactive-evaluation.html#extended-default-rules or in the language standard https://www.haskell.org/onlinereport/decls.html#sect4.3.4 ) How can I find the defaulted type in `ghci`? -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11994#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11994: ghci not applying defaulting when showing type -------------------------------------+------------------------------------- Reporter: j.waldmann | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by kanetw): Fractional implies Num, and Num can default. I don't know if `:set +t` should show the defaulted or polymorphic type. I always interpreted it as "show the expression's :t afterwards" -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11994#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11994: ghci not applying defaulting when showing type -------------------------------------+------------------------------------- Reporter: j.waldmann | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by aavogt): You could (ab)use do notation to get the defaulted type: {{{
:set +t Prelude> x <- return $ 1+1 x :: Integer }}}
The `it` variable is actually generalized, so the reported type is right. After all this works: {{{ Prelude> :set +t Prelude> 1+1 2 it :: Num a => a Prelude> (it :: Int, it :: Double) (2,2.0) it :: (Int, Double) }}} `-XMonoLocalBinds` keeps let from being generalized in files (ie. `let x = 1 in (x::Int,x::Integer)` becomes a type error), so I thought it might make a difference with respect to generalizing `it`. But it has no effect in ghci, not even for the `let x = ...` expression above. At least Richard Eisenberg seems to have said that `MonoLocalBinds` is irrelevant for ghci in a slightly different scenario: <https://mail.haskell.org/pipermail/ghc- devs/2015-August/009636.html>). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11994#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11994: ghci not applying defaulting when showing type -------------------------------------+------------------------------------- Reporter: j.waldmann | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): I don't think `-XMonoLocalBinds` is at issue here. That extension is implied by `-XTypeFamilies` and `-XGADTs` but is not on by default. What is at issue is the Dreaded Monomorphism Restriction, which is disabled by default in GHCi. If you want defaulting in GHCi, you may wish to see #10963. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11994#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11994: ghci not applying defaulting when showing type -------------------------------------+------------------------------------- Reporter: j.waldmann | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by j.waldmann):
if you want defaulting ...
This is not about changing the defaulting rules. It's just about the output of `:set +t`, which looked misleading to me. https://mail.haskell.org/pipermail/ghc-devs/2016-April/011958.html I did not realize that `it` is actually polymorphic. So the output is correct. But then the type of `it` is not the type of the value that is being printed - which is again strange. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11994#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC