Opened 8 years ago

Last modified 22 months ago

#3452 new feature request

Show type of most recent expression in GHCi

Reported by: ozy Owned by:
Priority: lowest Milestone:
Component: GHCi Version: 6.10.4
Keywords: Cc: leroux@…, hvr
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

Currently, any expression resulting in a value with no Show instance results in an error message. This is confusing for new users (especially if they don't yet understand typeclasses) and overly verbose for experienced users. Instead, the REPL should simply display the type of the expression, as if the user had used :t.

Change History (22)

comment:1 Changed 8 years ago by igloo

difficulty: Unknown
Milestone: 6.12 branch

Thanks for the suggestion.

comment:2 Changed 8 years ago by igloo

Milestone: 6.12 branch6.12.3

comment:3 Changed 7 years ago by igloo

Milestone: 6.12.36.14.1
Priority: normallow

comment:4 Changed 7 years ago by igloo

Milestone: 7.0.17.0.2

comment:5 Changed 7 years ago by igloo

Milestone: 7.0.27.2.1

comment:6 Changed 6 years ago by igloo

Milestone: 7.2.17.4.1

comment:7 Changed 6 years ago by igloo

Milestone: 7.4.17.6.1
Priority: lowlowest

comment:8 Changed 5 years ago by igloo

Milestone: 7.6.17.6.2

comment:9 Changed 4 years ago by hvr

Type of failure: None/Unknown

What should the output be in case :set +t was active?

comment:10 Changed 4 years ago by osa1

I'm a new contributor(preparing my first patch) and I'm working on this, currently my patch is this: https://github.com/osa1/ghc/commit/d542b418d913b4aba04e497fb63b70108b058f48

This is probably far from being finished, I'm looking for reviews/comments on this. I'm not very happy with the way it is implemented but for now this is only way I could think.

If someone point me a batter way to do I'll happily change my patch.

Here's an example output: https://gist.github.com/osa1/6201852

One thing I didn't like about this output is the _it_ part, to me it's not user friendly enough. I think we need to tell user that his value isn't showable so only it's type is shown.

comment:11 Changed 4 years ago by osa1

Status: newpatch

comment:12 Changed 4 years ago by goldfire

I'm a little confused by the output generated in your gist. Is the t option assumed now? You don't seem to set it, but you do unset it. And, I think the output should be more explicit about that it's changing behavior based on the lack of a Show instance. Having the output sometimes be a value and sometimes be a type is confusing!

In another direction, should we maybe promote the use of :force? This allows us to see the value of certain structures that don't have a Show instance.

comment:13 Changed 4 years ago by osa1

Sorry for confusion, +t was enabled by default(specified in my .ghci).

comment:14 Changed 4 years ago by leroux

Instead of completely removing the following error.

λ: id

<interactive>:2:1:
    No instance for (Show (a0 -> a0)) arising from a use of `print'
    Possible fix: add an instance declaration for (Show (a0 -> a0))
    In a stmt of an interactive GHCi command: print it

I think it would be saner and possibly better to just append the :t of it to the preceding error message.

comment:15 Changed 4 years ago by leroux

Cc: leroux@… added

comment:16 Changed 4 years ago by carter

its worth pointing out that a beginner friendly ghci doesn't need to be baked into ghc, see http://hackage.haskell.org/package/ghci-ng for how to make your own ghci

there may be value in having a "beginners-ghci" that is self contained / a client of ghc apis

comment:17 Changed 4 years ago by thoughtpolice

Cc: hvr added
Status: patchnew

Taking out of 'patch' status as a bit of work/discussion is still needed.

comment:18 Changed 3 years ago by thoughtpolice

Milestone: 7.6.27.10.1

Moving to 7.10.1.

comment:19 Changed 3 years ago by thoughtpolice

Milestone: 7.10.17.12.1

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:20 Changed 3 years ago by thoughtpolice

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:21 Changed 2 years ago by thoughtpolice

Milestone: 7.12.18.0.1

Milestone renamed

comment:22 Changed 22 months ago by thomie

Milestone: 8.0.1
Note: See TracTickets for help on using tickets.