Skip to content

Milky2018/moonchor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Moonchor: Choreographic Programming Library for MoonBit

Installation

moon add Milky2018/moonchor

Examples

Check examples

Basic APIs

trait Location: Show + Hash {
  name(Self) -> String
}

fn make_local_backend(
  locations : Array[&Location],
  logger~ : &Logger = make_mute_logger()
) -> Backend

async fn run_choreo[T, L : Location](
  backend : Backend,
  choreography : (ChoreoContext) -> T!Async,
  role : L,
  logger? : &Logger
) -> T 

For example, you can define some roles/locations by implementing the Location trait:

struct Alice {}
struct Bob {}
impl Location for Alice with name(_) { "Alice" }
impl Location for Bob with name(_) { "Bob" }
let alice : Alice = Alice::{ }
let bob : Bob = Bob::{ }

Define a simple choreography: Alice --msg-> Bob

async fn simple_choreo(ctx: ChoreoContext) -> Unit {
  let msg_at_alice = ctx.locally(alice, fn (_) { "Hello" })
  let msg_at_bob = ctx.comm(alice, bob, msg_at_alice)
  ctx.locally(bob, fn (unwrapper) { println(unwrapper.unwrap(msg_at_bob)) })
}

Then you can run the choreography:

let backend = make_local_backend([alice, bob])
run_choreo!(backend, simple_choreo, alice)
// or  run_choreo!(backend, simple_choreo, bob)

Todo

  • README
  • HTTP backend
  • Choice of knowledge
  • Enclave
  • Logging update
  • Async support

Further Readings

Introduction to Choreographies

HasChor

About

Choreographic programming library for MoonBit.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors