kriti-lang icon indicating copy to clipboard operation
kriti-lang copied to clipboard

Adds a repl

Open solomon-b opened this issue 2 years ago • 1 comments

Launching the repl

➜ cabal run kriti-repl
Kriti Lang, version 0.3.2: github.com/hasura/kriti-lang/ :? for help
> 

Using it

> {{ {"foo": 4} }}
{
    "foo": 4
}
> {{ {"foo": 4}.foo }}
4
> {{ 1 == 2 }}
false
> :let $ ./test/data/eval/success/source.json
> {{ $[0].isActive }}
false
> :let x = http://httpbin.org/json
> x
{
    "slideshow": {
        "author": "Yours Truly",
        "date": "date of publication",
        "slides": [
            {
                "title": "Wake up to WonderWidgets!",
                "type": "all"
            },
            {
                "items": [
                    "Why <em>WonderWidgets</em> are great",
                    "Who <em>buys</em> WonderWidgets"
                ],
                "title": "Overview",
                "type": "all"
            }
        ],
        "title": "Sample Slide Show"
    }
}

solomon-b avatar Sep 15 '22 08:09 solomon-b

Looks great!

The one recommendation I'd make is to support the stdin/stdout patterns by outputting non-evaluation content to STDERR and not prefixing output with >:

> echo '{}' | /Users/lyndon/hasura/kriti-lang/dist-newstyle/build/x86_64-osx/ghc-8.10.7/kriti-lang-0.3.2/x/kriti-repl/build/kriti-repl/kriti-repl 2>/dev/null
Kriti Lang, version 0.3.2: github.com/hasura/kriti-lang/ :? for help
> {}
> Goodbye!

Would be better as:

> echo '{}' | /Users/lyndon/hasura/kriti-lang/dist-newstyle/build/x86_64-osx/ghc-8.10.7/kriti-lang-0.3.2/x/kriti-repl/build/kriti-repl/kriti-repl 2>/dev/null
{}

So that it could be used in scripts more easily.

sordina avatar Sep 16 '22 01:09 sordina