Skip to content

Victorystick/scrapscript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scrapscript

A exploration (read: very incomplete implementation) of Scrapscript.

Installation

With Go installed, run go install github.com/Victorystick/scrapscript/cmd/scrap.

Overview

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 like scrap 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

Known bugs

  • 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
    #               ^

Missing

  • 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.

About

An exploration of https://scrapscript.org/ in Golang.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages