A exploration (read: very incomplete implementation) of Scrapscript.
With Go installed, run go install github.com/Victorystick/scrapscript/cmd/scrap
.
The aim is to implement Scrapscript along with the scrap
CLI as documented on https://scrapscript.org/guide.
So far it supports
-
scrap eval
to evaluate a script passed over standard input. -
scrap eval apply '...'
works likescrap eval
but passes the result of the former to the function defined by'...'
. For example:$ echo '0' \ | scrap eval apply 'n -> n + 1' \ | scrap eval apply 'n -> n + 1' \ | scrap eval apply 'n -> n + 1'
-
scrap type
to infer the type of a script passed over standard input.$ echo 'list/fold 0 (total -> text -> total + text/length text)' | scrap type list text -> int
-
Only supports pattern matching on the argument immediately following a pipe.
f 1 3 ; f = | 1 -> 1 -> 1 | 1 -> 2 -> 3 | 3 -> 5 -> 8 | 5 -> 8 -> 12 | a -> b -> a + b # evaluation error: function parameter must be an identifier # 3: | 1 -> 1 -> 1 # ^
-
scrap flat
- due to a lack of details. -
scrap yard
- just TODO.
Note: Scraps are currently fetched from the scrapyard at https://scraps.oseg.dev/ as text and cached locally.
Differences from https://scrapscript.org
-
Defines a
$sha256
function to import scraps instead of$sha1
as the latter is cryptographically weak. -
No attempt to implement Scrap Maps, Scrap passes or Scrapbooks.