https://github.com/dedbox/racket-event
Event-lang: synchronizable event programming
https://github.com/dedbox/racket-event
Last synced: 5 months ago
JSON representation
Event-lang: synchronizable event programming
- Host: GitHub
- URL: https://github.com/dedbox/racket-event
- Owner: dedbox
- License: mit
- Created: 2018-04-15T16:40:13.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-07-16T07:33:01.000Z (almost 7 years ago)
- Last Synced: 2025-07-25T08:55:48.717Z (11 months ago)
- Language: Racket
- Homepage:
- Size: 98.6 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Event-lang
**Synchronizable Event Programming**
[](https://pkgd.racket-lang.org/pkgn/package/event-lang)
[](http://docs.racket-lang.org/event-lang/)
[](https://travis-ci.org/dedbox/racket-event-lang)
[](https://coveralls.io/github/dedbox/racket-event-lang?branch=master)
Event-lang is an experimental Racket library that simplifies the creation of
complex synchronizable events.
Event-lang provides a primitive expression lifting form,
```
> (pure 123)
#
```
some event combinators,
```
> (sync (fmap + (pure 1) (pure 2)))
3
> (sync (app (pure +) (pure 1) (pure 2)))
3
> (sync (bind (pure 1) (pure 2) (λ xs (pure (apply + xs)))))
3
```
and a collection of event-friendly alternatives to base Racket forms and
functions.
```
> (sync
(event-let
([x (pure 1)]
[y (pure 2)])
(pure (list x y))))
'(1 2)
```
Composite events make progress by synchronizing constituent events, either
concurrently or in a predictable sequence. Synchronization results can be
ordered as specified,
```
> (let ([t0 (current-inexact-milliseconds)])
(define (now) (- (current-inexact-milliseconds) t0))
(sync
(async-args
(pure (cons 1 (now)))
(pure (cons 2 (now)))
(pure (cons 3 (now))))))
'(1 . 0.200927734375)
'(2 . 0.14990234375)
'(3 . 0.178955078125)
```
or as completed.
```
> (let ([t0 (current-inexact-milliseconds)])
(define (now) (- (current-inexact-milliseconds) t0))
(sync
(async-set
(pure (cons 1 (now)))
(pure (cons 2 (now)))
(pure (cons 3 (now))))))
'(2 . 0.0771484375)
'(3 . 0.093017578125)
'(1 . 0.123046875)
```
The project has three outstanding objectives:
1. _Provide a sophisticated lifting form_ to simplify usage of the provided
constructs. The event/event module contains a first approximation. Its
construction was tedious and error prone, so I commented out the docs.
2. _Provide a full-blown_ `#lang event/racket/base` for producing whole
modules of events and event constructors from ordinary Racket code in a
principled manner.
3. _Provide support for static analysis of synchronization behaviors._ Event
programming in Racket is a curious form of meta-programming, and a few
simple compile-time checks could reduce cognitive overhead.