Made the landing page better

This commit is contained in:
Linus Björnstam 2026-10-05 14:24:30 +02:00
parent 1a41f8bc70
commit 8aee744928

View file

@ -35,7 +35,7 @@ build it.
@section{more examples} @section{more examples}
ConcurrentML brings the multithreading story for bjolang into the 1990s. The function within cannot be written in go, because select is a statement. ConcurrentML brings the multithreading story for bjolang into the 1990s. It uses events that can be combined and synced on, meaning you can build trees of events and then preform them. This is indeed an extra layer for most operations in cml compared to CSP-inspired things, but allows us to write composable events. The function @code{within} returns a new event can be composed with other events. You can of course perform @code{within} in golang by writing a special function that races two fibers, but the composable version is not writeable.
@codeblock[#:lang "bjolang"]{ @codeblock[#:lang "bjolang"]{
(: within (-> int (Event %a) (Event (Option %a)))) (: within (-> int (Event %a) (Event (Option %a))))
@ -49,6 +49,7 @@ ConcurrentML brings the multithreading story for bjolang into the 1990s. The fun
} }
This sums every line and every char read from stdin. When the port is closed, the result is printed using the show function from (std fmt). This sums every line and every char read from stdin. When the port is closed, the result is printed using the show function from (std fmt).
@codeblock[#:lang "bjolang"]{ @codeblock[#:lang "bjolang"]{
(import (only (std ports) port->seq)) (import (only (std ports) port->seq))
(import (std fmt)) (import (std fmt))
@ -66,22 +67,18 @@ This sums every line and every char read from stdin. When the port is closed, th
0) 0)
} }
Here is a small example showing off bjoroutine use together with process pipelines Bjolang does type elaboration on literals. That means that if a function takes a (List CmdStuff) argument and you pass it '(pipe (cat "notes.txt") ,shout (grep "bomb")) it gets elaborated into (list (CmdPipe (Cmd 'cat (CmdString "notes.txt") (CmdFilter shout) (Cmd 'grep "bomb")))). For the type elaboration in (std run) this is not quite typesafe, even though it catches most of the issues, but with some care you can make type safe DSLs that can be typechecked.
The example below pipes the output (as in a commandline pipe) from a file through a bjolang function that upcases it and then greps it for "bomb". The shout function is completely async, and suspends if it cannot read from @code{in} or write to @code{out}.
@codeblock[#:lang "bjolang"]{ @codeblock[#:lang "bjolang"]{
(import (std run)) (import (std run))
;; this is an asynchronous filter that suspends if the read-char/opt or ;; Filter is a function type described in (std run)
;; write-char has to wait. A filter is a function type declared in (std run)
;; this particular filter upcases every letter.
(: shout Filter) (: shout Filter)
(defbjo (shout in out) (defbjo (shout in out)
(loop (:for ch (in-port in read-char/opt)) (loop (:for ch (in-port in read-char/opt))
(:do (write-char out (char-upcase ch))))) (:do (write-char out (char-upcase ch)))))
;; the run/xyz functions uses type elaboration to allow for
;; simple DSLs using quoted lists. This runs cat (the linux binary)
;; pipes it's output to the shout method and pipes that to a grep after
;; the word BOMB.
(run/string '(pipe (cat "notes.txt") ,shout (grep "BOMB"))) (run/string '(pipe (cat "notes.txt") ,shout (grep "BOMB")))
} }