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

#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

#9748: Disambiguate IO actions in GHCi with :set +t -------------------------------------+------------------------------------- Reporter: | Owner: Iceland_jack | Status: new Type: feature | Milestone: request | Version: 7.8.2 Priority: low | Keywords: Component: GHCi | Architecture: Unknown/Multiple Resolution: | Difficulty: Easy (less than 1 Operating System: | hour) Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by Iceland_jack): *showing the incorrect type for the given expression, the type of `it` is correct. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9748#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9748: Disambiguate IO actions in GHCi with :set +t -------------------------------------+------------------------------------- Reporter: | Owner: Iceland_jack | Status: new Type: feature | Milestone: request | Version: 7.8.2 Priority: low | Keywords: Component: GHCi | Architecture: Unknown/Multiple Resolution: | Difficulty: Easy (less than 1 Operating System: | hour) Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by hvr): I've been wishing something like that myself, however I don't like {{{#!hs it :: Char <- return 'a' :: IO Char }}} as it's too noisy IMO by the redundantly repeated value's type I'd rather like to see something like {{{#!hs it :: {- IO -} Char }}} that doesn't need to repeat the type, and still give an indication about evaluated result stored in `it` having resulted from an `IO`-action -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9748#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9748: Disambiguate IO actions in GHCi with :set +t -------------------------------------+------------------------------------- Reporter: | Owner: Iceland_jack | Status: new Type: feature | Milestone: request | Version: 7.8.2 Priority: low | Keywords: Component: GHCi | Architecture: Unknown/Multiple Resolution: | Difficulty: Easy (less than 1 Operating System: | hour) Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by simonpj): Moreover we ''really'' don't want to repeat the expression being evaluated, which might be large! Way too noisy. I quite like Herert's suggestion. Or {{{ Prelude> return 'a' Running IO action... 'a' it :: Char }}} or {{{ Prelude> return 'a' it :: Char -- After running the IO action }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9748#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9748: Disambiguate IO actions in GHCi with :set +t -------------------------------------+------------------------------------- Reporter: | Owner: zudov Iceland_jack | Status: new Type: feature | Milestone: request | Version: 7.8.2 Priority: low | Keywords: Component: GHCi | Architecture: Unknown/Multiple Resolution: | Difficulty: Easy (less than 1 Operating System: | hour) Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by zudov): * owner: => zudov -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9748#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9748: Disambiguate IO actions in GHCi with :set +t -------------------------------------+------------------------------------- Reporter: | Owner: zudov Iceland_jack | Status: new Type: feature | Milestone: request | Version: 7.8.2 Priority: low | Keywords: Component: GHCi | Architecture: Unknown/Multiple Resolution: | Difficulty: Easy (less than 1 Operating System: | hour) Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by hvr): Replying to [comment:3 simonpj]:
I quite like Herert's suggestion. Or {{{ Prelude> return 'a' Running IO action... 'a' it :: Char }}}
This has the risk of interleaving with other side-effected output the `IO` action may produce
or {{{ Prelude> return 'a' it :: Char -- After running the IO action }}}
This has the issue of introducing an English sentence which may require translation to other language (should GHCi ever be i18n'ed), as well as using up precious horizontal space for a boilerplate expression. I'd rather avoid adding natural language in places where a more terse annotation would suffice -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9748#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9748: Disambiguate IO actions in GHCi with :set +t -------------------------------------+------------------------------------- Reporter: | Owner: zudov Iceland_jack | Status: new Type: feature | Milestone: request | Version: 7.8.2 Priority: low | Keywords: Component: GHCi | Architecture: Unknown/Multiple Resolution: | Difficulty: Easy (less than 1 Operating System: | hour) Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by thomie): I like Herbert's suggestion too. See #7727 for a user report which could have been prevented if this feature got implemented. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9748#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by zudov): * owner: zudov => -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9748#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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 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 Iceland_jack): [https://www.reddit.com/r/haskell/comments/5me65b/is_haskells_sequence_safe/ Strikes again]. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9748#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC