script-monad-0.0.3: Stack of error, reader, writer, state, and prompt monad transformers

Copyright2018 Automattic Inc.
LicenseBSD3
MaintainerNathan Bloomfield (nbloomf@gmail.com)
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Data.MockIO

Contents

Description

A fake IO monad for testing.

Synopsis

MockIO

data MockIO s a Source #

A state monad over MockWorld.

Constructors

MockIO 

Fields

Instances
Monad (MockIO s) Source # 
Instance details

Defined in Data.MockIO

Methods

(>>=) :: MockIO s a -> (a -> MockIO s b) -> MockIO s b #

(>>) :: MockIO s a -> MockIO s b -> MockIO s b #

return :: a -> MockIO s a #

fail :: String -> MockIO s a #

Functor (MockIO s) Source # 
Instance details

Defined in Data.MockIO

Methods

fmap :: (a -> b) -> MockIO s a -> MockIO s b #

(<$) :: a -> MockIO s b -> MockIO s a #

Applicative (MockIO s) Source # 
Instance details

Defined in Data.MockIO

Methods

pure :: a -> MockIO s a #

(<*>) :: MockIO s (a -> b) -> MockIO s a -> MockIO s b #

liftA2 :: (a -> b -> c) -> MockIO s a -> MockIO s b -> MockIO s c #

(*>) :: MockIO s a -> MockIO s b -> MockIO s b #

(<*) :: MockIO s a -> MockIO s b -> MockIO s a #

Show (MockIO s a) Source # 
Instance details

Defined in Data.MockIO

Methods

showsPrec :: Int -> MockIO s a -> ShowS #

show :: MockIO s a -> String #

showList :: [MockIO s a] -> ShowS #

Arbitrary a => Arbitrary (MockIO s a) Source # 
Instance details

Defined in Data.MockIO

Methods

arbitrary :: Gen (MockIO s a) #

shrink :: MockIO s a -> [MockIO s a] #

getMockWorld :: MockIO s (MockWorld s) Source #

Retrieve the current MockWorld.

putMockWorld :: MockWorld s -> MockIO s () Source #

Replace the current MockWorld.

modifyMockWorld :: (MockWorld s -> MockWorld s) -> MockIO s () Source #

Mutate the current MockWorld strictly.

incrementTimer :: Int -> MockIO s () Source #

Bump the timer by a given number of microseconds.

MockWorld

data MockWorld s Source #

Just enough state to mock out a basic filesystem and HTTP server.

Instances
Eq s => Eq (MockWorld s) Source # 
Instance details

Defined in Data.MockIO

Methods

(==) :: MockWorld s -> MockWorld s -> Bool #

(/=) :: MockWorld s -> MockWorld s -> Bool #

Show s => Show (MockWorld s) Source # 
Instance details

Defined in Data.MockIO

Arbitrary s => Arbitrary (MockWorld s) Source # 
Instance details

Defined in Data.MockIO

Methods

arbitrary :: Gen (MockWorld s) #

shrink :: MockWorld s -> [MockWorld s] #

CoArbitrary s => CoArbitrary (MockWorld s) Source # 
Instance details

Defined in Data.MockIO

Methods

coarbitrary :: MockWorld s -> Gen b -> Gen b #

newtype MockServer s Source #

Type representing the internal state of an HTTP server.

Constructors

MockServer 

Fields

Instances
Eq s => Eq (MockServer s) Source # 
Instance details

Defined in Data.MockIO

Methods

(==) :: MockServer s -> MockServer s -> Bool #

(/=) :: MockServer s -> MockServer s -> Bool #

Show s => Show (MockServer s) Source # 
Instance details

Defined in Data.MockIO

epoch :: UTCTime Source #

1970-01-01 00:00:00

basicMockWorld :: s -> MockWorld s Source #

Empty filesystem and trivial HTTP responses

MockNetwork

data MockNetwork s a Source #

State monad representing network interaction.

Instances
Monad (MockNetwork s) Source # 
Instance details

Defined in Data.MockIO

Methods

(>>=) :: MockNetwork s a -> (a -> MockNetwork s b) -> MockNetwork s b #

(>>) :: MockNetwork s a -> MockNetwork s b -> MockNetwork s b #

return :: a -> MockNetwork s a #

fail :: String -> MockNetwork s a #

Functor (MockNetwork s) Source # 
Instance details

Defined in Data.MockIO

Methods

fmap :: (a -> b) -> MockNetwork s a -> MockNetwork s b #

(<$) :: a -> MockNetwork s b -> MockNetwork s a #

Applicative (MockNetwork s) Source # 
Instance details

Defined in Data.MockIO

Methods

pure :: a -> MockNetwork s a #

(<*>) :: MockNetwork s (a -> b) -> MockNetwork s a -> MockNetwork s b #

liftA2 :: (a -> b -> c) -> MockNetwork s a -> MockNetwork s b -> MockNetwork s c #

(*>) :: MockNetwork s a -> MockNetwork s b -> MockNetwork s b #

(<*) :: MockNetwork s a -> MockNetwork s b -> MockNetwork s a #

Show (MockNetwork s a) Source # 
Instance details

Defined in Data.MockIO

Methods

showsPrec :: Int -> MockNetwork s a -> ShowS #

show :: MockNetwork s a -> String #

showList :: [MockNetwork s a] -> ShowS #

Arbitrary a => Arbitrary (MockNetwork s a) Source # 
Instance details

Defined in Data.MockIO

Methods

arbitrary :: Gen (MockNetwork s a) #

shrink :: MockNetwork s a -> [MockNetwork s a] #

getMockServer :: MockNetwork s s Source #

Retrieve the internal state of the fake HTTP server.

putMockServer :: s -> MockNetwork s () Source #

Replace the internal state of the fake HTTP server.

modifyMockServer :: (s -> s) -> MockNetwork s () Source #

Mutate the internal state of the fake HTTP server (strictly).

Responses

_200ok :: ByteString -> HttpResponse Source #

Status 200; no headers

_400badRequest :: ByteString -> HttpResponse Source #

Status 400; no headers

_404notFound :: ByteString -> HttpResponse Source #

Status 404; no headers

_408requestTimeout :: ByteString -> HttpResponse Source #

Status 408; no headers