distributed-process-0.5.5.1: Cloud Haskell: Erlang-style concurrency in Haskell

Safe HaskellNone
LanguageHaskell98

Control.Distributed.Process.Internal.Closure.TH

Contents

Description

Template Haskell support

Synopsis

User-level API

remotable :: [Name] -> Q [Dec] Source

Create the closure, decoder, and metadata definitions for the given list of functions

remotableDecl :: [Q [Dec]] -> Q [Dec] Source

Like remotable, but parameterized by the declaration of a function instead of the function name. So where for remotable you'd do

f :: T1 -> T2
f = ...

remotable ['f]

with remotableDecl you would instead do

remotableDecl [
   [d| f :: T1 -> T2 ;
       f = ...
     |]
 ]

remotableDecl creates the function specified as well as the various dictionaries and static versions that remotable also creates. remotableDecl is sometimes necessary when you want to refer to, say, $(mkClosure 'f) within the definition of f itself.

NOTE: remotableDecl creates __remoteTableDecl instead of __remoteTable so that you can use both remotable and remotableDecl within the same module.

mkStatic :: Name -> Q Exp Source

Construct a static value.

If f : forall a1 .. an. T then $(mkStatic 'f) :: forall a1 .. an. Static T. Be sure to pass f to remotable.

functionSDict :: Name -> Q Exp Source

If f : T1 -> T2 is a monomorphic function then $(functionSDict 'f) :: Static (SerializableDict T1).

Be sure to pass f to remotable.

functionTDict :: Name -> Q Exp Source

If f : T1 -> Process T2 is a monomorphic function then $(functionTDict 'f) :: Static (SerializableDict T2).

Be sure to pass f to remotable.

mkClosure :: Name -> Q Exp Source

If f : T1 -> T2 then $(mkClosure 'f) :: T1 -> Closure T2.

TODO: The current version of mkClosure is too polymorphic (@forall a. Binary a => a -> Closure T2).

mkStaticClosure :: Name -> Q Exp Source

Make a Closure from a static function. This is useful for making a closure for a top-level Process () function, because using mkClosure would require adding a dummy () argument.