summaryrefslogtreecommitdiff
path: root/fig-frontend/src/Fig/Frontend/State.hs
diff options
context:
space:
mode:
Diffstat (limited to 'fig-frontend/src/Fig/Frontend/State.hs')
-rw-r--r--fig-frontend/src/Fig/Frontend/State.hs41
1 files changed, 0 insertions, 41 deletions
diff --git a/fig-frontend/src/Fig/Frontend/State.hs b/fig-frontend/src/Fig/Frontend/State.hs
deleted file mode 100644
index 6053105..0000000
--- a/fig-frontend/src/Fig/Frontend/State.hs
+++ /dev/null
@@ -1,41 +0,0 @@
-{-# Language TemplateHaskell #-}
-
-module Fig.Frontend.State where
-
-import Control.Lens.TH (makeLensesFor)
-import Control.Lens ((<>=))
-import Control.Monad.State (runStateT)
-
-import Fig.Prelude
-
-import qualified Data.IORef as IORef
-
-newtype State = State
- { buffer :: Text
- }
-makeLensesFor [("buffer", "buffer")] ''State
-
-defaultState :: State
-defaultState = State
- { buffer = ""
- }
-
-type StateRef = IORef.IORef State
-
-stateRef :: IO StateRef
-stateRef = IORef.newIORef defaultState
-
-withState ::
- MonadIO m' =>
- StateRef ->
- (forall m. (MonadIO m, MonadState State m) => m a) ->
- m' a
-withState ref f = do
- s <- liftIO $ IORef.readIORef ref
- (res, s') <- liftIO $ runStateT f s
- liftIO $ IORef.writeIORef ref s'
- pure res
-
-sayHi :: StateRef -> IO ()
-sayHi ref = withState ref do
- buffer <>= "hi"