Opened 6 years ago

Closed 4 years ago

Last modified 4 years ago

#8353 closed feature request (fixed)

Easy way to defer type errors

Reported by: goldfire Owned by:
Priority: normal Milestone: 8.0.1
Component: GHCi Version: 7.6.3
Keywords: newcomer Cc: hvr, bgamari
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: ghci/scripts/T8353
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D960
Wiki Page:


A number of comments I've heard recently have focused on the joy of -fdefer-type-errors, especially for newcomers to Haskell. However, in GHCi, one has to

  1. be aware that -fdefer-type-errors exists
  2. know the :set ... syntax to turn it on, and then
  3. is stuck with this setting on until they turn it off

Instead, I propose new :load! and :reload! commands (abbreviated to :l! and :r!) which turn on -fdefer-type-errors just for that one command. When a load or reload fails, the error message could suggest these alternate forms.

Change History (11)

comment:1 Changed 5 years ago by thomie

Cc: hvr added

Can you explain the "joy" of using '-fdefer-type-errors'? What is the intention of this ticket?

Once #9497 is fixed, there will also be '-fdefer-typed-holes'. Would that change this ticket in any way?

comment:2 Changed 5 years ago by goldfire

Keywords: newcomer added

Though I originally encountered my desire for this feature in a teaching setting, it happens in my own work, too.

Say I have a big file with lots of definitions. Somewhere, there is a type error. To fix the type error, I need to check the types of other definitions in my file. But, I can't use GHCi to query my definitions, because the file has a type error. Urgh. So, today, I have to enable -fdefer-type-errors, load the file, see my type warnings, and then query the definitions I need to fix everything up. A big annoyance of this workflow is that, now, -fdefer-type-errors is on and stays on until I reboot GHCi.

None of this is the end of anybody's world, but I just think it would be easier for everyone -- particularly newcomers to Haskell -- if there were just a way to "force" loading, by enabling deferred type errors for one compilation. That's the proposal here.

comment:3 Changed 5 years ago by simonpj

You can say :set -fno-defer-type-errors. You don't need to reboot GHCi, do you?

comment:4 in reply to:  3 Changed 5 years ago by goldfire

Replying to simonpj:

You can say :set -fno-defer-type-errors. You don't need to reboot GHCi, do you?

Oops. Of course. I still think this would be a nice feature.

comment:5 Changed 5 years ago by triple

Differential Rev(s): Phab:D960
Status: newpatch

comment:6 Changed 5 years ago by thomie

Cc: bgamari added

Moving design discussion to Trac, so it gets some more attention.

bgamari asks in Phab:D960:

Is there consensus that we want to expand the use of the ! suffix on GHCi commands? It seems to me like we might want to consider a slightly less cryptic (albeit more verbose) flag structure to expose this sort of functionality.

Currently we have:

:ctags[!] [<file>]          create tags file for Vi (default: "tags")
                               (!: use regex instead of line number)
:info[!] [<name> ...]       display information about the given names
                               (!: do not filter instances)
:kind[!] <type>             show the kind of <type>
                               (!: also print the normalised type)

The patch in D960 adds:

:load[!] [*]<module> ...    load module(s) and their dependents
                               (!: defer type errors)
:reload[!]                  reload the current module set
                               (!: defer type errors)

Seems all rather inconsistent, but not a huge problem either.

comment:7 Changed 4 years ago by simonpj

It'd be good to get this one finished. I have no strong feelings. The user manual should document whatever happens though.

comment:8 Changed 4 years ago by goldfire

For whatever it's worth, I haven't changed my mind about wanting this feature, nor the choice of concrete syntax. Thanks for putting together a patch!

comment:9 Changed 4 years ago by Thomas Miedema <thomasmiedema@…>

In 5d48e67fac952f7188fc9ebcfbf6e3ccb9b75705/ghc:

Easy way to defer type errors (implements #8353)

Added load! and reload! commands, effectively setting
"-fdefer-type-errors" before loading a file and
unsetting it after loading if it has not been set before.

Differential Revision:

comment:10 Changed 4 years ago by thomie

Milestone: 7.12.1
Resolution: fixed
Status: patchclosed
Test Case: ghci/scripts/T8353

Thanks Benjamin. Hope to see you tackle another ticket soon.

comment:11 Changed 4 years ago by thoughtpolice


Milestone renamed

Note: See TracTickets for help on using tickets.