Opened 9 years ago

Closed 8 years ago

Last modified 4 years ago

#4929 closed task (fixed)

Support all top-level declarations in GHCi

Reported by: simonmar Owned by: simonmar
Priority: high Milestone: 7.4.1
Component: GHCi Version: 7.0.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


I thought we had a ticket for this, but I can't find it so I'm creating one.

In GHCi there's no reason in principle that we can't allow any declaration that you can write at the top-level of a source file, at the interactive prompt. Many people have asked for this over the years.

  • data/type/newtype declarations
  • class declarations
  • instance declarations
  • foreign declarations (exception foreign export)
  • deriving
  • default???

Change History (5)

comment:1 Changed 8 years ago by nomeata

Shouln’t this be closed now, as of (I’m not sure about the correct bug workflow, so I’m not doing it myself.)

comment:2 Changed 8 years ago by simonmar

Milestone: _|_7.4.1
Owner: set to simonmar
Priority: normalhigh

I have a pending patch to add support for foreign declarations. Also we still have to add documentation (somehow I let Daniel leave without writing docs, how careless!). I'll close the ticket when those tasks are done.

comment:3 Changed 8 years ago by marlowsd@…

commit 25de0abf5416da898ce7c5e7999b3563ce4a1c49

Author: Simon Marlow <>
Date:   Thu Oct 6 12:29:55 2011 +0100

    Documentation for type/class declarations in GHCi (#4929)

 docs/users_guide/ghci.xml |  176 +++++++++++++++++++++++++++++++++-----------
 1 files changed, 132 insertions(+), 44 deletions(-)

comment:4 Changed 8 years ago by simonmar

Resolution: fixed
Status: newclosed

comment:5 Changed 4 years ago by Ben Gamari <ben@…>

In e809ef5/ghc:

ghci: fixity declarations for infix data constructors (#10018)

Declaring a custom fixity for an infix data constructor should work:

    Prelude> data Infix a b = a :@: b; infixl 4 :@:

This is a followup to #2947, which handled fixity declarations in ghci
statements (e.g. let add = (+); infixl 6 `add`).

Support for declarations (data, type, newtype, class, instance,
deriving, and foreign) was added to GHCi in #4929.

Reviewers: simonpj, austin, thomie

Subscribers: thomie, bgamari

Differential Revision:

GHC Trac Issues: #10018
Note: See TracTickets for help on using tickets.