gfb
2019-10-11 13:53:09

@me1531 fructure has a high-enough level of meaningful editing actions that logging them (and replaying as animation) as-is could already be close to a worthwhile ~semantic history. Maybe it’s already part of fructure, will look later, but http://tomasp.net/histogram/#s3 reminded me.


soegaard2
2019-10-11 15:56:51

Working on using React from Urlang. (urlang (urmodule react ; saved in react.js (import $ setTimeout req React ReactDOM this) ;;; A Counter component (var [Counter (React.createClass (object [getInitialState (λ() (object [count 0]))] [handleClick (λ() (this.setState (object [count (+ this.state.count 1)])))] [render (λ() @jsx{@button[onClick: @ur[this.handleClick]]{ @ur[(+ "Click me! Number of clicks: " this.state.count)]}})]))]) (define ($0 selector) (ref ($ selector) 0)) (ReactDOM.render (React.createElement Counter) ($0 "#example"))))


soegaard2
2019-10-11 15:59:37

Running the racket program generates a react.js which find the div (DOM element) with the name example. It then uses that element to render a Counter.


soegaard2
2019-10-11 16:00:32

The Counter is a React component with an initial state where count is 0.


soegaard2
2019-10-11 16:01:36

The method render is called by the React system when the state changes. Based on the current state it renders a new dom element to display.


soegaard2
2019-10-11 16:02:46

The jsx macro allows me to mix html tags (such as button) with javascript.


soegaard2
2019-10-11 18:40:58

Same example with “React Hooks”: (urlang (urmodule example ; saved in example.js (import $ React ReactDOM) (define (Counter) (use-state count set-count 0) @jsx{@div[@p{You clicked @ur[count] times} @button[onClick: @ur[(λ() (set-count (+ count 1)))]]{ Click me}]}) (define ($0 selector) (ref ($ selector) 0)) (ReactDOM.render (React.createElement Counter) ($0 "#example"))))


soegaard2
2019-10-11 18:41:59

rokitna
2019-10-11 18:58:32

awesome :)


samth
2019-10-11 18:59:04

@soegaard2 I hope that you create something for Om (or something like it written in urlang)


soegaard2
2019-10-11 19:23:35

Om?


githree
2019-10-11 19:24:10

samth
2019-10-11 19:24:56

yes


soegaard2
2019-10-11 19:25:41

What’s the elevator pitch?


samth
2019-10-11 19:29:31

it’s like react, but if you had real functional programming instead of JS


samth
2019-10-11 19:30:24

sorawee
2019-10-11 19:34:03

@soegaard2 I really wish to see https://github.com/vadimdemedes/ink ported to Racket. The ported version doesn’t necessarily need to use React (which brings all JS madness)—we really only need a reconciliator engine.


soegaard2
2019-10-11 19:52:28

Well, Urlang is JS with S-expressions and macros. I can make it feel more Racket-like, but it will still be JS.


soegaard2
2019-10-11 19:55:23

That being said, you can get surprisingly far with macros. The space invaders example looks a lot like HtDP programs: https://github.com/soegaard/urlang/blob/master/urlang-examples/space-invaders/space-invaders.rkt#L135