Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,394
    • Issues 4,394
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 377
    • Merge Requests 377
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #8113

Closed
Open
Opened Aug 03, 2013 by duncan@trac-duncan

Cannot override ghci builtin commands with :def[!]

In cabal we have a feature called "cabal repl" where it loads ghci with all the appropriate flags for the package or sandbox.

One of the nice things we want to do is extend the :reload (and related :add, :load) so that it calls out to cabal to run any pre-processors (e.g. hsc2hs, happy, alex etc).

Unfortunately the :def! command does not override builtin ghc commands. It looks like it works (:def reports the thing) but then the builtin command is still used, e.g.:

:def! reload (\_ -> print "yay" >> return "")
:def
the following macros are defined:
reload
:reload
Ok, modules loaded: none.

Related to this overriding, is that we also want a way to run the original (the builtin). Technically speaking it's possible using :undef, but then it's rather tricky to define again. You have to do something like define reload to call out to cabal, :undef reload, :reload, :def reload .... The tricky part is that last, we have to tie the knot, because that is the definition of :reload so it has to be able to access it's own code, tricky but not impossible (can load it from a file, but ugly).

So ideally we'd have something like :builtin [cmd] [args] that bypasses macros and executes the builtin command. Then we could define:

:def! reload :! cabal repl --reload ${other_stuff_here}
:builtin :reload

And similarly for the others :add, :load etc.

Trac metadata
Trac field Value
Version 7.6.3
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component GHCi
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Assignee
Assign to
7.8.1
Milestone
7.8.1 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#8113