diff --git a/index.sz b/index.sz index 6a9a13d..3921826 100644 --- a/index.sz +++ b/index.sz @@ -68,7 +68,7 @@ This sums every line and every char read from stdin. When the port is closed, th 0) } -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. +Bjolang can read a literal with a grammar. @code{def/grammar} declares the syntax of the literals and the types they become, and (std run) declares one for pipelines, called @code{Form}. @code{run/string} takes a @code{Form}, so @code{'(pipe (cat "notes.txt") ,shout (grep "BOMB"))} is read as @code{(FPipe (list (FCmd (list (WSym 'cat) (WStr "notes.txt"))) (FFilter shout) (FCmd (list (WSym 'grep) (WStr "BOMB")))))}. The compiler checks the literal against the grammar where it is written, so a pipeline that does not fit is a compile error, and @code{,shout} has to be a filter. You can declare grammars for DSLs of your own the same way. 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}.