fs-sim-0.3.0.1: Simulated file systems
Safe HaskellSafe-Inferred
LanguageHaskell2010

System.FS.Sim.Prim

Description

Mocked, monad transformer-based implementation of the HasFS interface.

Synopsis

Documentation

data FSSimT m a Source #

Monad transformer that extends a monad m with pure features: (i) MockFS state, and (ii) throwing/catching FsErrors.

Instances

Instances details
Monad m => MonadError FsError (FSSimT m) Source # 
Instance details

Defined in System.FS.Sim.Prim

Methods

throwError :: FsError -> FSSimT m a #

catchError :: FSSimT m a -> (FsError -> FSSimT m a) -> FSSimT m a #

Monad m => MonadState MockFS (FSSimT m) Source # 
Instance details

Defined in System.FS.Sim.Prim

Methods

get :: FSSimT m MockFS #

put :: MockFS -> FSSimT m () #

state :: (MockFS -> (a, MockFS)) -> FSSimT m a #

Monad m => Applicative (FSSimT m) Source # 
Instance details

Defined in System.FS.Sim.Prim

Methods

pure :: a -> FSSimT m a #

(<*>) :: FSSimT m (a -> b) -> FSSimT m a -> FSSimT m b #

liftA2 :: (a -> b -> c) -> FSSimT m a -> FSSimT m b -> FSSimT m c #

(*>) :: FSSimT m a -> FSSimT m b -> FSSimT m b #

(<*) :: FSSimT m a -> FSSimT m b -> FSSimT m a #

Functor m => Functor (FSSimT m) Source # 
Instance details

Defined in System.FS.Sim.Prim

Methods

fmap :: (a -> b) -> FSSimT m a -> FSSimT m b #

(<$) :: a -> FSSimT m b -> FSSimT m a #

Monad m => Monad (FSSimT m) Source # 
Instance details

Defined in System.FS.Sim.Prim

Methods

(>>=) :: FSSimT m a -> (a -> FSSimT m b) -> FSSimT m b #

(>>) :: FSSimT m a -> FSSimT m b -> FSSimT m b #

return :: a -> FSSimT m a #

PrimMonad m => PrimMonad (FSSimT m) Source # 
Instance details

Defined in System.FS.Sim.Prim

Associated Types

type PrimState (FSSimT m) #

Methods

primitive :: (State# (PrimState (FSSimT m)) -> (# State# (PrimState (FSSimT m)), a #)) -> FSSimT m a #

type PrimState (FSSimT m) Source # 
Instance details

Defined in System.FS.Sim.Prim

type PrimState (FSSimT m) = PrimState (StateT MockFS (ExceptT FsError m))

runFSSimT :: FSSimT m a -> MockFS -> m (Either FsError (a, MockFS)) Source #

primHasMockFS :: PrimMonad m => HasFS (FSSimT m) HandleMock Source #

Mocked, monad transformer-based implementation of the HasFS interface.

This implementation is pure when running in a monad m that is ST.

This implementation runs in a primitive monad m extended with an FSSimT monad transformer. It is recommended to use simHasFS or simErrorHasFS instead because they hide the monad transformer. The caveat is that m should be IO-like.