@hackage remote-monad0.2
An parametrizable Remote Monad, and parametrizable Applicative Functor
Categories
License
BSD-3-Clause
Maintainer
andygill@ku.edu
Links
Versions
Installation
Tested Compilers
Dependencies (3)
- base >=4.8 && <5
- transformers >=0.4 && <0.6
- natural-transformation >=0.3.1 && <0.4 Show all…
Dependents (4)
@hackage/wahsp, @hackage/remote-json, @hackage/api-rpc-accumulate, @hackage/api-rpc-pegnet
An implementation of the concepts behind Remote Monads. There is support for various bundling strategies.
{-# LANGUAGE GADTs #-} {-# LANGUAGE KindSignatures #-} module Main where import Control.Natural (nat, (#)) import Control.Remote.Monad import Control.Remote.Monad.Packet.Weak data Command :: * where Say :: String -> Command data Procedure :: * -> * where Temperature :: Procedure Int say :: String -> RemoteMonad Command Procedure () say s = command (Say s) temperature :: RemoteMonad Command Procedure Int temperature = procedure Temperature runWP :: WeakPacket Command Procedure a -> IO a runWP (Command (Say s)) = print s runWP (Procedure Temperature) = return 42 send :: RemoteMonad Command Procedure a -> IO a send = run $ runMonad $ nat runWP main = send $ do say "Howdy doodly do" say "How about a muffin?" t <- temperature say (show t ++ "F")