Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: Functional Reactive Programming in OCaml?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Vincenzo Ciancia <vincenzo_mlRE.MOVE@y...>
Subject: Re: [Caml-list] Re: Functional Reactive Programming in OCaml?
On Tuesday 30 November 2004 04:02, Benjamin Pierce wrote:
> The common idea in these systems is to introduce an abstraction of
> "signals" -- roughly, functions from time to "values", where the
> values can be anything from real numbers (conventional
> signal-processing-type signals) to two- or three-dimensional
> pictures, to booleans (representing events). What's special is that
> time is represented as a continuous, real-number quantity.  They do
> all kinds of work behind the scenes to actually compute with
> behaviors, but what shows through in the API is a very simple,
> elegant, and powerful set of primitives that can be combined in
> straightforward ways to achieve very complex effects.

I am surely not an expert on the subject, but I tried this at home in a 
student project at university. I wrote a library for composition of 
monomorphic signal functions. It was just a simple attempt but I found 
two things:

1. arrow composition in haskell can be very efficient - you usually 
implement your actions in terms of IO actions, and IO actions 
composition is _I suppose_ optimized somewhat by the compiler, e.g. 
inlining functions as needed to form a bigger code block. However you 
can compose as many arrows as you want without degrading performance.

Parallel or sequential arrow composition in ocaml will certainly involve 
- as in the haskell implementation - something "like" function 
composition, and this will result in efficiency proportional to the 
number of functions involved, which is unwanted. The performance gap 
between an event-based loop and "fran-like" code is discouraging for 
this reason. But you could generate bytecode at runtime and avoid this 
problem (and even beat haskell to please your language envy :)). I 
would seriously consider the second alternative if I had the time to 
work on it.

2. you are sometimes constrained to reveal implementation of your arrows 
when implementing composition, due to the value restriction - you 
certainly know this better than me, and I couldn't explain this 
anymore, the search function on the mailing list archives is not 
working or else I'd find an example I posted years ago and forgot 
about :) If you are interest I'll download the raw archives and find 
it.

Hope this helps - I would be interested in an implementation of FRAN for 
ocaml even if I am not so sure that I might be of any help.

Vincenzo