{-# LANGUAGE FlexibleContexts #-}
module AWS.Lambda.Runtime (
pureRuntime,
pureRuntimeWithContext,
fallibleRuntime,
fallibleRuntimeWithContext,
ioRuntime,
ioRuntimeWithContext,
readerTRuntime,
mRuntime,
mRuntimeWithContext
) where
import AWS.Lambda.Combinators (withInfallibleParse,
withFallibleParse,
withoutContext)
import AWS.Lambda.Context (LambdaContext(..))
import qualified AWS.Lambda.Runtime.Value as ValueRuntime
import Control.Monad (join)
import Control.Monad.Catch (MonadCatch)
import Control.Monad.IO.Class (MonadIO)
import Control.Monad.Reader (ReaderT)
import Data.Aeson (FromJSON, ToJSON)
mRuntimeWithContext :: (MonadCatch m, MonadIO m, FromJSON event, ToJSON result) => (LambdaContext -> event -> m result) -> m ()
mRuntimeWithContext :: forall (m :: * -> *) event result.
(MonadCatch m, MonadIO m, FromJSON event, ToJSON result) =>
(LambdaContext -> event -> m result) -> m ()
mRuntimeWithContext = (LambdaContext -> Value -> m result) -> m ()
forall (m :: * -> *) result.
(MonadCatch m, MonadIO m, ToJSON result) =>
(LambdaContext -> Value -> m result) -> m ()
ValueRuntime.mRuntimeWithContext ((LambdaContext -> Value -> m result) -> m ())
-> ((LambdaContext -> event -> m result)
-> LambdaContext -> Value -> m result)
-> (LambdaContext -> event -> m result)
-> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((event -> m result) -> Value -> m result)
-> (LambdaContext -> event -> m result)
-> LambdaContext
-> Value
-> m result
forall a b. (a -> b) -> (LambdaContext -> a) -> LambdaContext -> b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (event -> m result) -> Value -> m result
forall a b. FromJSON a => (a -> b) -> Value -> b
withInfallibleParse
mRuntime :: (MonadCatch m, MonadIO m, FromJSON event, ToJSON result) => (event -> m result) -> m ()
mRuntime :: forall (m :: * -> *) event result.
(MonadCatch m, MonadIO m, FromJSON event, ToJSON result) =>
(event -> m result) -> m ()
mRuntime = (Value -> m result) -> m ()
forall (m :: * -> *) result.
(MonadCatch m, MonadIO m, ToJSON result) =>
(Value -> m result) -> m ()
ValueRuntime.mRuntime ((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 :: forall event result.
(FromJSON event, ToJSON result) =>
(event -> ReaderT LambdaContext IO result) -> IO ()
readerTRuntime = (Value -> ReaderT LambdaContext IO result) -> IO ()
forall result.
ToJSON result =>
(Value -> ReaderT LambdaContext IO result) -> IO ()
ValueRuntime.readerTRuntime ((Value -> ReaderT LambdaContext IO result) -> IO ())
-> ((event -> ReaderT LambdaContext IO result)
-> Value -> ReaderT LambdaContext IO result)
-> (event -> ReaderT LambdaContext IO result)
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (event -> ReaderT LambdaContext IO result)
-> Value -> ReaderT LambdaContext IO result
forall a b. FromJSON a => (a -> b) -> Value -> b
withInfallibleParse
ioRuntimeWithContext :: (FromJSON event, ToJSON result) =>
(LambdaContext -> event -> IO (Either String result)) -> IO ()
ioRuntimeWithContext :: forall event result.
(FromJSON event, ToJSON result) =>
(LambdaContext -> event -> IO (Either String result)) -> IO ()
ioRuntimeWithContext = (LambdaContext -> Value -> IO (Either String result)) -> IO ()
forall result.
ToJSON result =>
(LambdaContext -> Value -> IO (Either String result)) -> IO ()
ValueRuntime.ioRuntimeWithContext ((LambdaContext -> Value -> IO (Either String result)) -> IO ())
-> ((LambdaContext -> event -> IO (Either String result))
-> LambdaContext -> Value -> IO (Either String result))
-> (LambdaContext -> event -> IO (Either String result))
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((event -> IO (Either String result))
-> Value -> IO (Either String result))
-> (LambdaContext -> event -> IO (Either String result))
-> LambdaContext
-> Value
-> IO (Either String result)
forall a b. (a -> b) -> (LambdaContext -> a) -> LambdaContext -> b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (event -> IO (Either String result))
-> Value -> IO (Either String result)
forall a b. FromJSON a => (a -> b) -> Value -> b
withInfallibleParse
ioRuntime :: (FromJSON event, ToJSON result) =>
(event -> IO (Either String result)) -> IO ()
ioRuntime :: forall event result.
(FromJSON event, ToJSON result) =>
(event -> IO (Either String result)) -> IO ()
ioRuntime = (Value -> IO (Either String result)) -> IO ()
forall result.
ToJSON result =>
(Value -> IO (Either String result)) -> IO ()
ValueRuntime.ioRuntime ((Value -> IO (Either String result)) -> IO ())
-> ((event -> IO (Either String result))
-> Value -> IO (Either String result))
-> (event -> IO (Either String result))
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (event -> IO (Either String result))
-> Value -> IO (Either String result)
forall a b. FromJSON a => (a -> b) -> Value -> b
withInfallibleParse
fallibleRuntimeWithContext :: (FromJSON event, ToJSON result) =>
(LambdaContext -> event -> Either String result) -> IO ()
fallibleRuntimeWithContext :: forall event result.
(FromJSON event, ToJSON result) =>
(LambdaContext -> event -> Either String result) -> IO ()
fallibleRuntimeWithContext LambdaContext -> event -> Either String result
fn = (LambdaContext -> Value -> Either String result) -> IO ()
forall result.
ToJSON result =>
(LambdaContext -> Value -> Either String result) -> IO ()
ValueRuntime.fallibleRuntimeWithContext ((LambdaContext -> Value -> Either String result) -> IO ())
-> (LambdaContext -> Value -> Either String result) -> IO ()
forall a b. (a -> b) -> a -> b
$ \LambdaContext
lc -> Either String (Either String result) -> Either String result
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join (Either String (Either String result) -> Either String result)
-> (Value -> Either String (Either String result))
-> Value
-> Either String result
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (event -> Either String result)
-> Value -> Either String (Either String result)
forall a b. FromJSON a => (a -> b) -> Value -> Either String b
withFallibleParse (LambdaContext -> event -> Either String result
fn LambdaContext
lc)
fallibleRuntime :: (FromJSON event, ToJSON result) =>
(event -> Either String result) -> IO ()
fallibleRuntime :: forall event result.
(FromJSON event, ToJSON result) =>
(event -> Either String result) -> IO ()
fallibleRuntime = (LambdaContext -> event -> Either String result) -> IO ()
forall event result.
(FromJSON event, ToJSON result) =>
(LambdaContext -> event -> Either String result) -> IO ()
fallibleRuntimeWithContext ((LambdaContext -> event -> Either String result) -> IO ())
-> ((event -> Either String result)
-> LambdaContext -> event -> Either String result)
-> (event -> Either String result)
-> IO ()
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 :: forall event result.
(FromJSON event, ToJSON result) =>
(LambdaContext -> event -> result) -> IO ()
pureRuntimeWithContext = (LambdaContext -> event -> Either String result) -> IO ()
forall event result.
(FromJSON event, ToJSON result) =>
(LambdaContext -> event -> Either String result) -> IO ()
fallibleRuntimeWithContext ((LambdaContext -> event -> Either String result) -> IO ())
-> ((LambdaContext -> event -> result)
-> LambdaContext -> event -> Either String result)
-> (LambdaContext -> event -> result)
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((event -> result) -> event -> Either String result)
-> (LambdaContext -> event -> result)
-> LambdaContext
-> event
-> Either String result
forall a b. (a -> b) -> (LambdaContext -> a) -> LambdaContext -> b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((result -> Either String result)
-> (event -> result) -> event -> Either String result
forall a b. (a -> b) -> (event -> a) -> event -> b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap result -> Either String result
forall a. a -> Either String a
forall (f :: * -> *) a. Applicative f => a -> f a
pure)
pureRuntime :: (FromJSON event, ToJSON result) => (event -> result) -> IO ()
pureRuntime :: forall event result.
(FromJSON event, ToJSON result) =>
(event -> result) -> IO ()
pureRuntime = (LambdaContext -> event -> result) -> IO ()
forall event result.
(FromJSON event, ToJSON result) =>
(LambdaContext -> event -> result) -> IO ()
pureRuntimeWithContext ((LambdaContext -> event -> result) -> IO ())
-> ((event -> result) -> LambdaContext -> event -> result)
-> (event -> result)
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (event -> result) -> LambdaContext -> event -> result
forall a b. a -> b -> a
withoutContext