Previous Up Next

3.13  Scalar Interfaces and Importing values

Scalar interfaces written in Objective Caml can be imported by Lucid Synchrone. In the current implementation, a restricted subset of Objective Caml interfaces is considered. The syntax is the following:

scalar-interface:: ={ scalar-interface-phrase [ ;; ] }
 
scalar-interface-phrase::=value-declaration
    | type-definition
 
value-declaration::=val ident : type

When a value is imported from the host language Objective Caml the value is automatically lifted to the stream level in the following way.

3.13.1  Making a Node from an Imported Value

It is possible to build a node from a pair (s0, step) of type a × (abc × a). s0 stands for the initial state and step for the step function. The step function takes the current state, an input (with type b) and returns a value (with type c) and a new state. Such a pair can be transformed into a node by defining a lifting function like the following (other encoding are of course possible).

let node instance (s0, step) input =
  let rec last s = s0
  and o, s = step (last s) input in
    o

val instance :  'a * ('a -> 'b -> 'c * 'a) -> 'b => 'c
val instance :: 'a * ('a -> 'b -> 'c * 'a) -> 'b -> 'c

Previous Up Next