[GHC] #9748: Disambiguate IO actions in GHCi with :set +t

GHC ghc-devs at haskell.org
Fri Oct 31 04:14:35 UTC 2014


#9748: Disambiguate IO actions in GHCi with :set +t
-------------------------------------+-------------------------------------
       Reporter:  Iceland_jack       |                   Owner:
           Type:  feature request    |                  Status:  new
       Priority:  low                |               Milestone:
      Component:  GHCi               |                 Version:  7.8.2
       Keywords:                     |        Operating System:
   Architecture:  Unknown/Multiple   |  Unknown/Multiple
     Difficulty:  Easy (less than 1  |         Type of failure:
  hour)                              |  None/Unknown
     Blocked By:                     |               Test Case:
Related Tickets:                     |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------
 Currently GHCi's `:set +t` displays the same type for the following:

 {{{#!hs
 % ghci -ignore-dot-ghci
 GHCi, version 7.8.2: http://www.haskell.org/ghc/  :? for help
 Loading package ghc-prim ... linking ... done.
 Loading package integer-gmp ... linking ... done.
 Loading package base ... linking ... done.
 Prelude> :set +t
 Prelude> 'a'
 'a'
 it :: Char
 Prelude> return 'a'
 'a'
 it :: Char
 Prelude> return 'a' :: IO Char
 'a'
 it :: Char
 }}}

 A user at `#haskell-beginners` ran into a problem where they mistook an
 expression that defaulted to IO for a pure expression (`Id . even <$> pure
 5`), `:set +t` was suggested but ended up showing the incorrect type:

 {{{#!hs
 ghci> Id . even <$> pure 5
 Id False
 it :: Id Bool
 }}}

 This is bad for pedagogical reasons, it would be an improvement to display
 the following:

 {{{#!hs
 Prelude> :set +t
 Prelude> 'a'
 'a'
 it :: Char
 Prelude> return 'a'
 'a'
 it :: Char <- return 'a' :: IO Char
 Prelude> return 'a' :: IO Char
 'a'
 it :: Char <- return 'a' :: IO Char
 }}}

 mirroring existing syntax:

 {{{#!hs
 Prelude> :set -XScopedTypeVariables
 Prelude> a :: Char <- return 'a' :: IO Char
 a :: Char
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9748>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list