Copyright | (c) Connor Moreside 2016 |
---|---|
License | BSD-3 |
Maintainer | connor@moresi.de |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
- type Lightning a = LightningT IO a
- data LightningF m a where
- FailWith :: APIError LightningError -> LightningF m a
- ReceiveRoute :: Receivable b => Route -> (b -> a) -> LightningF m a
- RunRoute :: FromJSON b => Route -> (b -> a) -> LightningF m a
- SendJSON :: Receivable b => Value -> Route -> (b -> a) -> LightningF m a
- WithBaseURL :: Text -> LightningT m b -> (b -> a) -> LightningF m a
- newtype LightningT m a = LightningT (ReaderT BaseUrl (FreeT (LightningF m) m) a)
- class ValidatablePlot a where
- runRoute :: (FromJSON a, Monad m) => Route -> LightningT m a
- sendPlot :: (ToJSON p, ValidatablePlot p, Receivable a, Monad m) => Text -> p -> Route -> LightningT m a
- streamPlot :: (ToJSON p, ValidatablePlot p, Receivable a, Monad m) => Maybe Visualization -> Text -> p -> Route -> LightningT m a
- sendJSON :: (Receivable a, Monad m) => Value -> Route -> LightningT m a
- receiveRoute :: (Receivable a, Monad m) => Route -> LightningT m a
- withBaseURL :: Monad m => Text -> LightningT m a -> LightningT m a
- failWith :: Monad m => APIError LightningError -> LightningT m a
- liftLightningF :: Monad m => FreeT (LightningF m) m a -> ReaderT Text (FreeT (LightningF m) m) a
Lightning Types
type Lightning a = LightningT IO a Source #
Represents an IO Lightning transformer action.
data LightningF m a where Source #
Defines the available actions
FailWith :: APIError LightningError -> LightningF m a | |
ReceiveRoute :: Receivable b => Route -> (b -> a) -> LightningF m a | |
RunRoute :: FromJSON b => Route -> (b -> a) -> LightningF m a | |
SendJSON :: Receivable b => Value -> Route -> (b -> a) -> LightningF m a | |
WithBaseURL :: Text -> LightningT m b -> (b -> a) -> LightningF m a |
Functor (LightningF m) Source # | |
newtype LightningT m a Source #
Defines free monad transformer
LightningT (ReaderT BaseUrl (FreeT (LightningF m) m) a) |
MonadTrans LightningT Source # | |
Monad m => MonadReader Text (LightningT m) Source # | |
Monad m => Monad (LightningT m) Source # | |
Monad m => Functor (LightningT m) Source # | |
Monad m => Applicative (LightningT m) Source # | |
MonadIO m => MonadIO (LightningT m) Source # | |
class ValidatablePlot a where Source #
Allows plot fields to be validated.
validatePlot :: a -> Either LightningError a Source #
Lightning Actions
:: (FromJSON a, Monad m) | |
=> Route | Route to run |
-> LightningT m a | Monad transformer stack with result. |
Runs a route action within the free monadic transformer context.
:: (ToJSON p, ValidatablePlot p, Receivable a, Monad m) | |
=> Text | The plot type |
-> p | The plot creation request |
-> Route | The plot route. |
-> LightningT m a | Monad transformer stack with result. |
Sends a request to the lightning-viz server to create a visualization.
:: (ToJSON p, ValidatablePlot p, Receivable a, Monad m) | |
=> Maybe Visualization | Visualization to update. If nothing, create a new plot. |
-> Text | Plot type |
-> p | Plot payload |
-> Route | Route to send plot to. |
-> LightningT m a | Monad transformer stack with result. |
Sends a request to either create a brand new streaming plot or to append data to an existing streaming plot.
:: (Receivable a, Monad m) | |
=> Value | The JSON payload |
-> Route | Route to send request to |
-> LightningT m a | Monad transformer stack with result. |
Sends a request containing JSON to the specified route.
:: (Receivable a, Monad m) | |
=> Route | The route to retrieve data from. |
-> LightningT m a | Monad transformer stack with result. |
Send and receives a GET request to the specified route.
:: Monad m | |
=> Text | The new base URL. |
-> LightningT m a | Next action to run. |
-> LightningT m a | Monad transformer stack with result. |
Replaces the base URL in the stack and run the supplied action afterwards.
:: Monad m | |
=> APIError LightningError | The error message to return. |
-> LightningT m a | Monad transformer stack with error. |
Returns an error message.
liftLightningF :: Monad m => FreeT (LightningF m) m a -> ReaderT Text (FreeT (LightningF m) m) a Source #
Lifts a LightningF
free monad into the ReaderT context.