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,260
    • Issues 4,260
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 401
    • Merge Requests 401
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #9966

Closed
Open
Opened Jan 08, 2015 by Eric Seidel@gridaphobeReporter

Allow switching to different monads in GHCi

GHCi can evaluate individual IO actions, e.g.

ghci> writeFile "foo.txt" "bar"
ghci> readFile "foo.txt"
bar

but, as far as I know, this doesn't extend to other monads. Instead you have to compose an entire computation and then run it with the standard eliminators, e.g.

ghci> evalState 0 (put 1 >> get)
1

It would be quite nice if we could tell GHCi to temporarily jump into a different top-level monad, e.g.

-- we start in IO as usual
ghci> :monad runState 0
-- now we're in `State Int` with the initial state set to 0
ghci> put 1
-- we can evaluate individual State actions without the ceremony of `runState`,
-- and having to track the updated state ourselves between actions
ghci> get
1
ghci> :monad IO
-- now we're back in IO

I'm not sure how feasible this is (it seems tricky), but it would provide a very nice UX for GHCi in the context of larger Haskell applications.

Trac metadata
Trac field Value
Version 7.11
Type FeatureRequest
TypeOfFailure OtherFailure
Priority low
Resolution Unresolved
Component GHCi
Test case
Differential revisions
BlockedBy
Related
Blocking
CC hvr
Operating system
Architecture
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#9966