monad-ste-0.1.0.0: ST monad with efficient explicit errors

Safe HaskellTrustworthy
LanguageHaskell2010

Control.Monad.STE

Synopsis

Documentation

data STE e s a Source

Instances

Monad (STE e s) Source 
Functor (STE e s) Source 
MonadFix (STE e s) Source 
Applicative (STE e s) Source 
(~) * SomeException err => MonadThrow (STE err s) Source 
PrimMonad (STE e s) Source 
PrimBase (STE e s) Source 
type PrimState (STE e s) = s Source 

runSTE :: (forall s. STE e s a) -> (Either e a -> b) -> b Source

runSTE is the workhorse of the STE monad. Runs an STE computation, and also does the toplevel handling of the abortive throwSTE operator. The naive way to handle errors is to simply write handleSTE id md. runSTE does not and cannot (by design) handle pure or async exceptions.

throwSTE :: forall e s a. e -> STE e s a Source

throwSTE is the STE sibling of throwIO, and its argument must match the e parameter in STE e s a. There is also no Exception e constraint. throwSTE should be thought of as an "abort" operation which is guaranteed to be caught/handled by runSTE.

handleSTE :: (Either e a -> b) -> (forall s. STE e s a) -> b Source

handleSTE is a flipped convenience function version of runSTE