-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Remote Monad for JavaScript on the browser -- -- Bridge from Haskell to JavaScript on the browser @package javascript-bridge @version 0.2.0 module Network.JavaScript.Internal newtype JavaScript JavaScript :: Text -> JavaScript class Command f internalCommand :: Command f => JavaScript -> f () internalConstructor :: Command f => JavaScript -> f (RemoteValue a) class Procedure f internalProcedure :: (Procedure f, FromJSON a) => JavaScript -> f a data Primitive :: * -> * [Command] :: JavaScript -> Primitive () [Procedure] :: FromJSON a => JavaScript -> Primitive a [Constructor] :: JavaScript -> Primitive (RemoteValue a) newtype RemoteValue a RemoteValue :: Int -> RemoteValue a -- | generate the text for a RemoteValue. They can be used as assignment -- targets as well, but exposes the JavaScript scoping semantics. var :: RemoteValue a -> JavaScript -- | The Remote Applicative Packet newtype Packet a Packet :: AF Primitive a -> Packet a data AF :: (* -> *) -> * -> * [PureAF] :: a -> AF m a [PrimAF] :: m a -> AF m a [ApAF] :: AF m (a -> b) -> AF m a -> AF m b -- | The Remote Monad newtype RemoteMonad a RemoteMonad :: M Primitive a -> RemoteMonad a evalAF :: Applicative f => (forall x. m x -> f x) -> AF m a -> f a concatAF :: (forall x. m x -> Maybe b) -> AF m a -> [b] data M :: (* -> *) -> * -> * [PureM] :: a -> M m a [PrimM] :: m a -> M m a [ApM] :: M m (a -> b) -> M m a -> M m b [BindM] :: M m a -> (a -> M m b) -> M m b evalM :: Monad f => (forall x. m x -> f x) -> M m a -> f a instance GHC.Base.Monad Network.JavaScript.Internal.RemoteMonad instance GHC.Base.Applicative Network.JavaScript.Internal.RemoteMonad instance GHC.Base.Functor Network.JavaScript.Internal.RemoteMonad instance GHC.Base.Applicative Network.JavaScript.Internal.Packet instance GHC.Base.Functor Network.JavaScript.Internal.Packet instance GHC.Show.Show (Network.JavaScript.Internal.RemoteValue a) instance GHC.Classes.Ord (Network.JavaScript.Internal.RemoteValue a) instance GHC.Classes.Eq (Network.JavaScript.Internal.RemoteValue a) instance GHC.Show.Show Network.JavaScript.Internal.JavaScript instance Network.JavaScript.Internal.Command Network.JavaScript.Internal.RemoteMonad instance Network.JavaScript.Internal.Procedure Network.JavaScript.Internal.RemoteMonad instance GHC.Base.Functor (Network.JavaScript.Internal.M m) instance GHC.Base.Applicative (Network.JavaScript.Internal.M m) instance GHC.Base.Monad (Network.JavaScript.Internal.M m) instance Network.JavaScript.Internal.Command Network.JavaScript.Internal.Packet instance Network.JavaScript.Internal.Procedure Network.JavaScript.Internal.Packet instance GHC.Base.Functor (Network.JavaScript.Internal.AF m) instance GHC.Base.Applicative (Network.JavaScript.Internal.AF m) instance Data.Aeson.Types.ToJSON.ToJSON (Network.JavaScript.Internal.RemoteValue a) instance Data.String.IsString Network.JavaScript.Internal.JavaScript instance GHC.Base.Semigroup Network.JavaScript.Internal.JavaScript instance GHC.Base.Monoid Network.JavaScript.Internal.JavaScript module Network.JavaScript.Services -- | An Engine is a handle to a specific JavaScript engine data Engine Engine :: (JavaScript -> IO ()) -> IO Int -> (Int -> IO (Either Value [Value])) -> STM (Value, UTCTime) -> Engine [sendJavaScript] :: Engine -> JavaScript -> IO () [genNonce] :: Engine -> IO Int [replyBox] :: Engine -> Int -> IO (Either Value [Value]) [eventChan] :: Engine -> STM (Value, UTCTime) -- | This accepts WebSocket requests, calls the callback with an -- Engine that can be used to access JavaScript. start :: (Engine -> IO ()) -> Application -> Application -- | Add a listener for events. There can be many. non-blocking. -- -- From JavaScript, you can call event(..) to send values to this -- listener. Any valid JSON value can be sent. addListener :: Engine -> (Value -> IO ()) -> IO ThreadId -- | listen for the next event. blocking. -- -- From JavaScript, you can call event(..) to send values to this -- listener. Any valid JSON value can be sent. listen :: Engine -> IO Value -- | readEventChan uses STM to read the next event. -- -- From JavaScript, you can call event(..) to send values to this -- channel. Any valid JSON value can be sent. readEventChan :: Engine -> STM (Value, UTCTime) -- | The WAI application. -- -- Note that, since WAI 3.0, this type is structured in continuation -- passing style to allow for proper safe resource handling. This was -- handled in the past via other means (e.g., ResourceT). As a -- demonstration: -- --
-- app :: Application -- app req respond = bracket_ -- (putStrLn "Allocating scarce resource") -- (putStrLn "Cleaning up") -- (respond $ responseLBS status200 [] "Hello World") --type Application = Request -> Response -> IO ResponseReceived -> IO ResponseReceived instance GHC.Show.Show Network.JavaScript.Services.Reply instance Data.Aeson.Types.FromJSON.FromJSON Network.JavaScript.Services.Reply module Network.JavaScript -- | send a remote monad for execution on a JavaScript engine. The -- monad may be split into several packets for transmission and exection. send :: Engine -> RemoteMonad a -> IO a -- | send an (applicative) Packet. This packet always sent -- atomically to JavaScript. sendA :: Engine -> Packet a -> IO a -- | send with all JavaScript exceptions caught and returned. sendE :: Engine -> RemoteMonad a -> IO (Either Value a) newtype JavaScript JavaScript :: Text -> JavaScript -- | command statement to execute in JavaScript. ';' is not needed -- as a terminator. Should never throw an exception, which may be -- reported to console.log. command :: Command f => JavaScript -> f () -- | procedure expression to execute in JavaScript. ';' is not -- needed as a terminator. Should never throw an exception, but any -- exceptions are returned to the send as Haskell exceptions. -- -- Procedures can return Promises. Before completing the transaction, all -- the values for all the procedures that are promises are fulfilled -- (using Promises.all). -- -- If a procedure throws an exception, future commands and procedures in -- the same packet will not be executed. Use promises to allow all -- commands and procedures to be invoked, if needed. procedure :: forall a f. (Procedure f, FromJSON a) => JavaScript -> f a -- | constructor expression to execute in JavaScript. ';' is not -- needed as a terminator. Should never throw an exception, but any -- exceptions are returned to the send as Haskell exceptions. -- -- The value returned in not returned to Haskell. Instead, a handle is -- returned, that can be used to access the remote value. Examples of -- remote values include objects that can not be serialized, or values -- that are too large to serialize. -- -- The first type argument is the phantom type of the RemoteValue, -- so that type application can be used to specify the type. constructor :: forall a f. Command f => JavaScript -> f (RemoteValue a) -- | The Remote Applicative Packet data Packet a -- | The Remote Monad data RemoteMonad a class Command f class Procedure f data RemoteValue a -- | delete a remote value. delete :: Command f => RemoteValue a -> f () -- | localize brings a remote value into Haskell. localize :: Procedure f => RemoteValue a -> f Value -- | remote sends a local value to JavaScript. remote :: Command f => Value -> f (RemoteValue a) -- | generate the text for a RemoteValue. They can be used as assignment -- targets as well, but exposes the JavaScript scoping semantics. var :: RemoteValue a -> JavaScript -- | Generate a JavaScript value, including for -- RemoteValue's. value :: ToJSON v => v -> JavaScript -- | Generate a function call call :: JavaScript -> [JavaScript] -> JavaScript -- | Generate JavaScript number number :: Double -> JavaScript -- | Generate (quoted) JavaScript string string :: Text -> JavaScript data JavaScriptException JavaScriptException :: Value -> JavaScriptException -- | Send an event back to Haskell event :: ToJSON v => v -> JavaScript -- | Add a listener for events. There can be many. non-blocking. -- -- From JavaScript, you can call event(..) to send values to this -- listener. Any valid JSON value can be sent. addListener :: Engine -> (Value -> IO ()) -> IO ThreadId -- | listen for the next event. blocking. -- -- From JavaScript, you can call event(..) to send values to this -- listener. Any valid JSON value can be sent. listen :: Engine -> IO Value -- | readEventChan uses STM to read the next event. -- -- From JavaScript, you can call event(..) to send values to this -- channel. Any valid JSON value can be sent. readEventChan :: Engine -> STM (Value, UTCTime) -- | This accepts WebSocket requests, calls the callback with an -- Engine that can be used to access JavaScript. start :: (Engine -> IO ()) -> Application -> Application -- | An Engine is a handle to a specific JavaScript engine data Engine -- | The WAI application. -- -- Note that, since WAI 3.0, this type is structured in continuation -- passing style to allow for proper safe resource handling. This was -- handled in the past via other means (e.g., ResourceT). As a -- demonstration: -- --
-- app :: Application -- app req respond = bracket_ -- (putStrLn "Allocating scarce resource") -- (putStrLn "Cleaning up") -- (respond $ responseLBS status200 [] "Hello World") --type Application = Request -> Response -> IO ResponseReceived -> IO ResponseReceived instance GHC.Classes.Eq Network.JavaScript.JavaScriptException instance GHC.Show.Show Network.JavaScript.JavaScriptException instance GHC.Show.Show (Network.JavaScript.Stmt a) instance GHC.Exception.Type.Exception Network.JavaScript.JavaScriptException