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,273
    • Issues 4,273
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 413
    • Merge Requests 413
  • 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
  • #18238

Closed
Open
Opened May 26, 2020 by Sebastian Graf@sgraf812Developer

Explore alternatives to the state hack

The state hack (-fstate-hack, on by default, see Note [The state-transformer hack] in G.C.O.Arity) is a smart hack without which efficient compilation of IO wouldn't be possible. But fixes such as 69c0e16e made me thinking: Now that we have GHC.Magic.oneShot, can we get by without?

Suppose we define (in ghc-prim:GHC.Types):

newtype IO a = IONoEta (State# RealWorld -> (# State# RealWorld, a #))

pattern IO m <- IONoEta m
  where
    IO m = IONoEta (oneShot m)

Similarly for ST. I hope that we can get rid of the state hack this way. That would also fix #14596.

Another advantage to this is that we can use IONoEta on a use by use basis, rather than having the rather unobtrusive {-# OPTIONS_GHC -fno-state-hack #-} at the top of the module, disconnected from its usage.

Edited May 26, 2020 by Sebastian Graf
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#18238