Pervasive Operators: #

These are of type T -> T'. The first 7 all have straightforward Orc translations, while the last 4 do not:
ref: a -> (a)ref create fresh ref
get: (a)ref -> a get contents of ref
set: (a×(a)ref) -> unit set contents of ref
chan: string->(a)chan create fresh channel
send: ((a)chan × a)->unit send message on channel
recv: (a)chan->a receive message off channel
fork: (unit ->unit)->unit start thread in parallel
name: string->name create fresh name
box: (unit ->unit)->part create new partition
paste: (name ×part)->unit paste named partition
cut: name -> part cut named partition

Basic Interface: B.mli#

This next interface is the basic interface used to build services. Note that its a mix of VM management functions and combinators:
type vm
type vm snapshot
type event = VM Crash | VM Shutdown |
VM Overload | VM Underload
type (a,b) proc
type (a,b) procref
val call : (a,b) proc -> a -> b
val eOr : (a,b) proc -> (a,b) proc -> (a,b) proc
val ePar : (a,b) proc -> (a,b) proc -> (a,b) proc
val eRef : (a,b) proc -> ((a,b) proc × (a,b) procref)
val eRefUpdate : (a,b) procref -> (a,b) proc -> unit
val eVM : vm -> (event -> unit) -> unit
val eDelete: (a,b) proc -> unit
val shutdownVM: vm -> unit
val snapshotVM : vm -> vm snapshot
val restoreVM : vm snapshot -> unit

ePar is identical to the | combinator, while eOr is similar, it simply picks one of the two options nondeterministically (easily accomplished in Orc). Call is simply a function call, and eRef and eRefUpdate are done easily in Orc as well.

Orc implementation of the ePar and eOr combinators:#

def ePar[A,B](lambda(A) :: B, lambda(A) :: B)(A) :: B
def ePar(f,g)(x) = let(f(x) | g(x))

def eOr[A,B](lambda(A) :: B, lambda(A) :: B)(A) :: B
def eOr(f,g)(x) = if random(1) = 0 then f(x) else g(x)

Environment Interface:#

In order to work through the motivating example, here is an example interface to a payment processing system:
ype Payment
type Order
type tPayment=(Payment,string) proc
type tOrderEntry=(Order,string) proc
type tOrderProcessing=
(Order,unit) proc
val createOrderEntryRole:
tPayment -> tOrderProcessing -> (vm ÃtOrderEntry)
val createOrderProcessingRole :
unit -> (vm × tOrderProcessing)
val createPaymentRole :
unit -> (vm × tPayment)
val importPayment1: unit -> tPayment
val importPayment2: unit -> tPayment
val exportOrderEntry:
tOrderEntry -> tOrderEntry

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-1) was last changed on 06-Mar-2009 10:28 by AdrianQuark