Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jaredly/unison.rs
https://github.com/jaredly/unison.rs
Last synced: 23 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jaredly/unison.rs
- Owner: jaredly
- Created: 2020-08-21T00:25:02.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-09-13T12:17:10.000Z (about 2 years ago)
- Last Synced: 2024-10-04T11:46:01.705Z (about 1 month ago)
- Language: Scheme
- Homepage:
- Size: 1.81 MB
- Stars: 68
- Watchers: 8
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# unison.rs
An experimental runtime for unison code, written in rust, compiled to wasm for use in the browser.
## Usage:
- download the [release binary](https://github.com/jaredly/unison.rs/releases/tag/release-2)
- run `unison.rs serve`
- go to `http://localhost:8080`, view the different namespaces that you've got, click on terms to "watch" them (including the ability to provide arguments to functions, as long as they're "primitives")
- run `unison` somewhere
- grab the web example (if you want to) `pull https://github.com/jaredly/unison-wasm-example .example`
- browse to `example.app` and click on it
- see that it's interactive!
- `cd example` and `edit counter` - in the scratch file, change `"Hello unison"` to something else
- save the scratch file, run `update` in unison, and see that the watcher auto-updates in your browser!```
```
ability abilities.a_01 where
getInt : Int
abilities.f_01 = handle (abilities.a_01.getInt) with cases
{ a } -> (a, 2)
{ abilities.a_01.getInt -> k } -> handle (k +5) with cases { a } -> (a, 3)
abilities.t_01 = abilities.f_01 == (+5, 3)(define stack '())
(define (throw-effect k effect)
(let ((handler (car stack)))
(set! stack (cdr stack))
(handler (cons 'effect (cons k effect)))
)
)(define (rethrow eff)
(let ((k (cadr eff))
(ef (cddr eff)))
(throw-effect k eff)))(define (add-handler handler)
(set! stack (cons handler stack)))(define (getInt)
(call/cc (lambda (k) (throw-effect k (list 'getInt)))))(define (handle inner handler)
(handler (call/cc (lambda (k)
(add-handler k) ; TODO we'll have to pop at some point?
(list 'pure (inner))
)))
)(define f_01
(handle
(lambda () (getInt))
(lambda (eff)
(match eff
[('pure a) (list a 2)]
[('effect k 'getInt)
(handle
(lambda () (k 5))
(lambda (eff)
(display eff)
(match eff
[('pure a) (list a 3)]
[_ (rethrow eff)]
)
)
)
]
[_ (rethrow eff)]
)
)
)
)```