[racket] An elm-like racket language?

From: Anthony Carrico (acarrico at memebeam.org)
Date: Sat Nov 16 08:57:31 EST 2013

On 11/12/2013 03:21 PM, Daniel Prager wrote:
> Given the existence of FrTime, whalesong, and FlapJax is anyone
> working on or considering doing an elm-like language
> (http://elm-lang.org/) for Racket?

I've taken a look at FrTime, FlapJax, and Elm. I agree that it is all a
good idea. It appeals to the electrical engineer in me. I've been
playing with an event based dataflow system. I can put it into github at
some point if you are curious. It is very simple right now.

> Perspectives and suggestions most welcome.

Ok, here are some notes:

1. I've been thinking a lot about the best way to do the previous
operator. FrTime updates previous nodes after each propagation, so a
node is almost always the same as its previous value. This makes sense
for FrTime's continuous time semantics, but I would like previous nodes
to always reflect the previous event's value, rather than the value at
the previous instant. I hope that makes sense. Mine is an event based
semantics for previous. For example, if "current-frame" is the current
frame of your gui, then "(previous current-frame)" should remain the
previous frame until a new frame is calculated.

2. I'm not necessarily thinking about dataflow graphs that can rewire
(higher order signals or whatever). I'm not sure it is necessary if you
mainly want a framework for wiring up a gui, etc. This might be a case
where a simple dataflow system can go a long way.

3. I've also thought a little about about compiling the network. This
doesn't seem too hard if you serialize external events (inputs)--just
turn the network into a function for each input. Code size would explode
doing that for each combination of inputs, so supporting parallel events
would be trickier than it is with an explicit event queue (but I like
parallel events). I'm not sure compiling is necessary, but something to
keep in mind during design.

> Elm seems to have momentum, looks clean, and targets the web, but has
> a Haskell-inspired syntax.

4. The async stuff in Elm is cool. That is something I'd like to play
with more.

5. As I said, it is pretty simple. Here are the details:

Use these four plus application to define networks:

(input initial-value) -> input signal
(output callback) -> output signal
(lift value) -> convert a value to a signal
(previous signal initial-value) -> previous value signal of the given
  signal.

To inject events:

(event an-event value) -> (void)

To propagate events:

(propagate)

6. Here is an example from my unit tests. It is a delay line:

(let* ((x2 (input 1))
       (x1 (previous x2 0))
       (x0 (previous x1 0))
       (y ((lift +) x0 x1 x2)))

   ;; 0, 0, 1
   (check = 1 (source-value y))
   (printf "::: ~s\n" (map source-value (list y x0 x1 x2)))

   ;; 0, 1, 2
   (event x2 2)
   (propagate)
   (printf "::: ~s\n" (map source-value (list y x0 x1 x2)))
   (check = 3 (source-value y))

   ;; 1, 2, 3
   (event x2 3)
   (propagate)
   (printf "::: ~s\n" (map source-value (list y x0 x1 x2)))
   (check = 6 (source-value y))

   ;; 2, 3, 4
   (event x2 4)
   (propagate)
   (printf "::: ~s\n" (map source-value (list y x0 x1 x2)))
   (check = 9 (source-value y)))

-- 
Anthony Carrico

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 259 bytes
Desc: OpenPGP digital signature
URL: <http://lists.racket-lang.org/users/archive/attachments/20131116/25abae5e/attachment.sig>

Posted on the users mailing list.