-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Easy REPL driven development using ComponentM
--   
--   This library enhances the componentm with auto-reloading capabilites
--   for your application, allowing to ensure cleanup of resources when
--   doing REPL driven development, or when using ghcid
@package componentm-devel
@version 0.0.0.2

module Control.Monad.Component.Development

-- | Represents the construction of a Component in your application,
--   components may be composed using a <a>Monad</a> or <a>Applicative</a>
--   interface.
data ComponentM a

-- | Similar to <tt>runComponentM1</tt>, when running for the first time,
--   it creates an application in the REPL environment, subsequent
--   invocations will teardown the and build up the application again.
--   
--   All <a>ComponentM</a> characteristics are driven by this particular
--   use-case given:
--   
--   <ul>
--   <li>It will print out the time spent on initialization and
--   teardown</li>
--   <li>It guarantees that teardown operations are as robust as
--   possible</li>
--   <li>It documents your application components to pin-point quickly
--   errors in your reloading logic</li>
--   </ul>
runComponentDevel :: (ComponentEvent -> IO ()) -> Text -> ComponentM a -> (a -> IO b) -> IO ()

-- | Exception thrown by the <tt>runComponentM</tt> family of functions
data ComponentError

-- | Failure raised when the Application Callback given to a
--   <tt>runComponentM</tt> function throws an exception
ComponentRuntimeFailed :: !SomeException -> !TeardownResult -> ComponentError

-- | Exception that was originally thrown by the Application Callback
[componentErrorOriginalException] :: ComponentError -> !SomeException

-- | Result from the execution allocated resources teardown
[componentErrorTeardownResult] :: ComponentError -> !TeardownResult

-- | Failure raised when execution of <a>ComponentM</a> throws an exception
ComponentBuildFailed :: ![ComponentBuildError] -> !TeardownResult -> ComponentError

-- | Exceptions thrown by <a>IO</a> sub-routines used when constructing
--   <a>ComponentM</a> values (e.g. <tt>buildComponent</tt>)
[componentErrorBuildErrors] :: ComponentError -> ![ComponentBuildError]

-- | Result from the execution allocated resources teardown
[componentErrorTeardownResult] :: ComponentError -> !TeardownResult

-- | Exception raised on the execution of <a>IO</a> sub-routines used when
--   constructing <a>ComponentM</a> values (e.g. <tt>buildComponent</tt>)
data ComponentBuildError

-- | Failure thrown when using the same component key on a Component
--   composition
DuplicatedComponentKeyDetected :: !Description -> ComponentBuildError

-- | Failure thrown when the allocation sub-routine of a Component fails
--   with an exception
ComponentAllocationFailed :: !Description -> !SomeException -> ComponentBuildError

-- | Failure thrown when calling the <a>throwM</a> when composing
--   <a>ComponentM</a> values
ComponentErrorThrown :: !SomeException -> ComponentBuildError

-- | Failure thrown when calling <a>liftIO</a> fails with an exception
ComponentIOLiftFailed :: !SomeException -> ComponentBuildError

-- | An event record used to trace the execution of an application
--   initialization and teardown
data ComponentEvent
ComponentBuilt :: !BuildResult -> ComponentEvent
ComponentReleased :: !TeardownResult -> ComponentEvent
ComponentErrorDetected :: !ComponentError -> ComponentEvent

-- | Contains metadata about the build of a resource from a
--   <a>ComponentM</a> value
data Build

-- | Elasped time in the allocation of a component resource
buildElapsedTime :: Build -> NominalDiffTime

-- | Error thrown in the allocation of a component resource
buildFailure :: Build -> Maybe SomeException

-- | Wraps a collection of <a>Build</a> records
data BuildResult
toBuildList :: BuildResult -> [Build]
