It's Kinda FRP-y
kinda-ferpy
is a simplified model for functional reactive programming. Signals, events, and
dependency relationships are implicitly defined by monitoring program
control. The implementation uses a ported and patched form of MaiaVictor’s
PureState library.
(require kinda-ferpy)
(define x (stateful-cell 1))
(define y (stateful-cell 1))
(define sum (stateful-cell (+ (x) (y))))
(displayln (sum)) ; 2
(y 8)
(displayln (sum)) ; 9
For a less trivial example, here’s a progression from a Markdown file
to an HTML document, plus a few ways to use it. %
is an alias of
stateful-cell
, so I’ll shorten it here.
(require kinda-ferpy markdown)
(define md-path
(% (build-path "index.md")))
(define html-path
(% (path-replace-extension (md-path)
#".html")))
(define content-xexpr
(% (parse-markdown (md-path))))
(define page-xexpr
(% `(html (head (title "My Page"))
(body ,(content-xexpr)))))
(define html-string
(% (string-append "<!DOCTYPE html>"
(xexpr->html (page-xexpr)))))
(define html-link
(% (string-append "/"
(path->string ,(html-path)))))
This hooks up a file system path to a Markdown file and expresses
different output formats regarding an HTML document. To produce
new documents, you only need to change md-path
.