Skip to content

Disambiguate IO actions in GHCi with :set +t

Currently GHCi's :set +t displays the same type for the following:

% 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:

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:

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:

Prelude> :set -XScopedTypeVariables 
Prelude> a :: Char <- return 'a' :: IO Char
a :: Char
Trac metadata
Trac field Value
Version 7.8.2
Type FeatureRequest
TypeOfFailure OtherFailure
Priority low
Resolution Unresolved
Component GHCi
Test case
Differential revisions
BlockedBy
Related
Blocking
CC hvr
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information