Merge pull request #523 from mb64/hasio-statet

Implement HasIO for StateT
This commit is contained in:
Niklas Larsson 2020-08-18 14:02:02 +02:00 committed by GitHub
commit 84ae9d7c6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -58,6 +58,10 @@ implementation (Monad f, Alternative f) => Alternative (StateT st f) where
empty = lift empty
(ST f) <|> (ST g) = ST (\st => f st <|> g st)
public export
implementation HasIO m => HasIO (StateT stateType m) where
liftIO io = ST $ \s => liftIO $ io_bind io $ \a => pure (a, s)
||| Apply a function to modify the context of this computation
public export
modify : MonadState stateType m => (stateType -> stateType) -> m ()