{-# LANGUAGE FlexibleContexts #-}
module AWS.Lambda.Runtime (
pureRuntime,
pureRuntimeWithContext,
fallibleRuntime,
fallibleRuntimeWithContext,
ioRuntime,
ioRuntimeWithContext,
readerTRuntime,
mRuntimeWithContext
) where
import AWS.Lambda.Combinators (withIOInterface,
withFallibleInterface,
withPureInterface,
withoutContext,
withInfallibleParse)
import AWS.Lambda.Context (LambdaContext(..), HasLambdaContext(..), runReaderTLambdaContext)
import qualified AWS.Lambda.Runtime.Value as ValueRuntime
import Control.Monad.Catch (MonadCatch)
import Control.Monad.IO.Class (MonadIO)
import Control.Monad.Reader (MonadReader, ReaderT)
import Data.Aeson (FromJSON, ToJSON)
mRuntimeWithContext :: (HasLambdaContext r, MonadCatch m, MonadReader r m, MonadIO m, FromJSON event, ToJSON result) =>
(event -> m result) -> m ()
mRuntimeWithContext :: (event -> m result) -> m ()
mRuntimeWithContext = (Value -> m result) -> m ()
forall r (m :: * -> *) result.
(HasLambdaContext r, MonadCatch m, MonadReader r m, MonadIO m,
ToJSON result) =>
(Value -> m result) -> m ()
ValueRuntime.mRuntimeWithContext ((Value -> m result) -> m ())
-> ((event -> m result) -> Value -> m result)
-> (event -> m result)
-> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (event -> m result) -> Value -> m result
forall a b. FromJSON a => (a -> b) -> Value -> b
withInfallibleParse
readerTRuntime :: (FromJSON event, ToJSON result) =>
(event -> ReaderT LambdaContext IO result) -> IO ()
readerTRuntime :: (event -> ReaderT LambdaContext IO result) -> IO ()
readerTRuntime = ReaderT LambdaContext IO () -> IO ()
forall (m :: * -> *) a. ReaderT LambdaContext m a -> m a
runReaderTLambdaContext (ReaderT LambdaContext IO () -> IO ())
-> ((event -> ReaderT LambdaContext IO result)
-> ReaderT LambdaContext IO ())
-> (event -> ReaderT LambdaContext IO result)
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (event -> ReaderT LambdaContext IO result)
-> ReaderT LambdaContext IO ()
forall r (m :: * -> *) event result.
(HasLambdaContext r, MonadCatch m, MonadReader r m, MonadIO m,
FromJSON event, ToJSON result) =>
(event -> m result) -> m ()
mRuntimeWithContext
ioRuntimeWithContext :: (FromJSON event, ToJSON result) =>
(LambdaContext -> event -> IO (Either String result)) -> IO ()
ioRuntimeWithContext :: (LambdaContext -> event -> IO (Either String result)) -> IO ()
ioRuntimeWithContext = (event -> ReaderT LambdaContext IO result) -> IO ()
forall event result.
(FromJSON event, ToJSON result) =>
(event -> ReaderT LambdaContext IO result) -> IO ()
readerTRuntime ((event -> ReaderT LambdaContext IO result) -> IO ())
-> ((LambdaContext -> event -> IO (Either String result))
-> event -> ReaderT LambdaContext IO result)
-> (LambdaContext -> event -> IO (Either String result))
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (LambdaContext -> event -> IO (Either String result))
-> event -> ReaderT LambdaContext IO result
forall c (m :: * -> *) b a.
(MonadReader c m, MonadIO m) =>
(c -> b -> IO (Either String a)) -> b -> m a
withIOInterface
ioRuntime :: (FromJSON event, ToJSON result) =>
(event -> IO (Either String result)) -> IO ()
ioRuntime :: (event -> IO (Either String result)) -> IO ()
ioRuntime = (event -> ReaderT LambdaContext IO result) -> IO ()
forall event result.
(FromJSON event, ToJSON result) =>
(event -> ReaderT LambdaContext IO result) -> IO ()
readerTRuntime ((event -> ReaderT LambdaContext IO result) -> IO ())
-> ((event -> IO (Either String result))
-> event -> ReaderT LambdaContext IO result)
-> (event -> IO (Either String result))
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (LambdaContext -> event -> IO (Either String result))
-> event -> ReaderT LambdaContext IO result
forall c (m :: * -> *) b a.
(MonadReader c m, MonadIO m) =>
(c -> b -> IO (Either String a)) -> b -> m a
withIOInterface ((LambdaContext -> event -> IO (Either String result))
-> event -> ReaderT LambdaContext IO result)
-> ((event -> IO (Either String result))
-> LambdaContext -> event -> IO (Either String result))
-> (event -> IO (Either String result))
-> event
-> ReaderT LambdaContext IO result
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (event -> IO (Either String result))
-> LambdaContext -> event -> IO (Either String result)
forall a b. a -> b -> a
withoutContext
fallibleRuntimeWithContext :: (FromJSON event, ToJSON result) =>
(LambdaContext -> event -> Either String result) -> IO ()
fallibleRuntimeWithContext :: (LambdaContext -> event -> Either String result) -> IO ()
fallibleRuntimeWithContext = (event -> ReaderT LambdaContext IO result) -> IO ()
forall event result.
(FromJSON event, ToJSON result) =>
(event -> ReaderT LambdaContext IO result) -> IO ()
readerTRuntime ((event -> ReaderT LambdaContext IO result) -> IO ())
-> ((LambdaContext -> event -> Either String result)
-> event -> ReaderT LambdaContext IO result)
-> (LambdaContext -> event -> Either String result)
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (LambdaContext -> event -> Either String result)
-> event -> ReaderT LambdaContext IO result
forall c (m :: * -> *) b a.
MonadReader c m =>
(c -> b -> Either String a) -> b -> m a
withFallibleInterface
fallibleRuntime :: (FromJSON event, ToJSON result) =>
(event -> Either String result) -> IO ()
fallibleRuntime :: (event -> Either String result) -> IO ()
fallibleRuntime = (event -> ReaderT LambdaContext IO result) -> IO ()
forall event result.
(FromJSON event, ToJSON result) =>
(event -> ReaderT LambdaContext IO result) -> IO ()
readerTRuntime ((event -> ReaderT LambdaContext IO result) -> IO ())
-> ((event -> Either String result)
-> event -> ReaderT LambdaContext IO result)
-> (event -> Either String result)
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (LambdaContext -> event -> Either String result)
-> event -> ReaderT LambdaContext IO result
forall c (m :: * -> *) b a.
MonadReader c m =>
(c -> b -> Either String a) -> b -> m a
withFallibleInterface ((LambdaContext -> event -> Either String result)
-> event -> ReaderT LambdaContext IO result)
-> ((event -> Either String result)
-> LambdaContext -> event -> Either String result)
-> (event -> Either String result)
-> event
-> ReaderT LambdaContext IO result
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (event -> Either String result)
-> LambdaContext -> event -> Either String result
forall a b. a -> b -> a
withoutContext
pureRuntimeWithContext :: (FromJSON event, ToJSON result) =>
(LambdaContext -> event -> result) -> IO ()
pureRuntimeWithContext :: (LambdaContext -> event -> result) -> IO ()
pureRuntimeWithContext = (event -> ReaderT LambdaContext IO result) -> IO ()
forall event result.
(FromJSON event, ToJSON result) =>
(event -> ReaderT LambdaContext IO result) -> IO ()
readerTRuntime ((event -> ReaderT LambdaContext IO result) -> IO ())
-> ((LambdaContext -> event -> result)
-> event -> ReaderT LambdaContext IO result)
-> (LambdaContext -> event -> result)
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (LambdaContext -> event -> result)
-> event -> ReaderT LambdaContext IO result
forall c (m :: * -> *) b a.
MonadReader c m =>
(c -> b -> a) -> b -> m a
withPureInterface
pureRuntime :: (FromJSON event, ToJSON result) => (event -> result) -> IO ()
pureRuntime :: (event -> result) -> IO ()
pureRuntime = (event -> ReaderT LambdaContext IO result) -> IO ()
forall event result.
(FromJSON event, ToJSON result) =>
(event -> ReaderT LambdaContext IO result) -> IO ()
readerTRuntime ((event -> ReaderT LambdaContext IO result) -> IO ())
-> ((event -> result) -> event -> ReaderT LambdaContext IO result)
-> (event -> result)
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (LambdaContext -> event -> result)
-> event -> ReaderT LambdaContext IO result
forall c (m :: * -> *) b a.
MonadReader c m =>
(c -> b -> a) -> b -> m a
withPureInterface ((LambdaContext -> event -> result)
-> event -> ReaderT LambdaContext IO result)
-> ((event -> result) -> LambdaContext -> event -> result)
-> (event -> result)
-> event
-> ReaderT LambdaContext IO result
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (event -> result) -> LambdaContext -> event -> result
forall a b. a -> b -> a
withoutContext