Skip to content

Commit

Permalink
Add documentation to runners.
Browse files Browse the repository at this point in the history
  • Loading branch information
eborden committed Jun 19, 2017
1 parent d8edaa6 commit 19448b2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion graphula-core/src/Graphula.hs
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,20 @@ import Graphula.Internal
type Graph generate log nodeConstraint entity
= FreeT (Sum (Backend generate log) (Frontend nodeConstraint entity))

-- | Interpret a 'Graph' with a given 'Frontend' interpreter, utilizing
-- 'Arbitrary' for node generation.
runGraphula
:: (MonadIO m, MonadCatch m)
=> (Frontend nodeConstraint entity (m a) -> m a) -> Graph Arbitrary NoConstraint nodeConstraint entity m a -> m a
=> (Frontend nodeConstraint entity (m a) -> m a)
-> Graph Arbitrary NoConstraint nodeConstraint entity m a
-> m a
runGraphula frontend f =
flip iterT f $ \case
InR r -> frontend r
InL l -> backendArbitrary l

-- | An extension of 'runGraphula' that logs all json 'Value's to a temporary
-- file on 'Exception' and re-throws the 'Exception'.
runGraphulaLogged
:: (MonadIO m, MonadCatch m)
=> (Frontend nodeConstraint entity (m a) -> m a)
Expand All @@ -115,6 +121,8 @@ runGraphulaLogged
runGraphulaLogged =
runGraphulaLoggedUsing logFailTemp

-- | A variant of 'runGraphulaLogged' that accepts a file path to logged to
-- instead of utilizing a temp file.
runGraphulaLoggedWithFile
:: (MonadIO m, MonadCatch m)
=> FilePath
Expand All @@ -139,6 +147,8 @@ runGraphulaLoggedUsing logFail frontend f = do
InR r -> frontend r
InL l -> backendArbitraryLogged graphLog l

-- | Interpret a 'Graph' with a given 'Frontend' interpreter, utilizing a JSON
-- file for node generation via 'FromJSON'.
runGraphulaReplay
:: (MonadIO m, MonadCatch m)
=> FilePath
Expand Down

0 comments on commit 19448b2

Please sign in to comment.