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.