hnock

A Nock interpreter.
Log | Files | Refs | README | LICENSE

commit 1c1dd72399be6dc5bd7a2694f32f4d5a40b448b7
parent 9b4a85c26f7ee18899845eb8c23594843f1ff865
Author: Jared Tobin <jared@jtobin.io>
Date:   Wed, 30 Jan 2019 12:15:31 +1300

Rename 'enock' to 'nock'.

* Update README.

Diffstat:
MREADME.md | 24++++++++++++++++++++----
Mlib/Nock.hs | 13++++++-------
2 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/README.md b/README.md @@ -1,10 +1,21 @@ # hnock -A Nock interpreter. +A [Nock][nock] interpreter. + +## Install + +Use a simple + +``` +stack install +``` + +to build the `hnock` binary and get it moved somewhere on your PATH. If you +just want to build the binary, you can use `stack build`. ## Usage -From bash, simply pipe Nock expressions into the executable `hnock`: +From bash, simply pipe Nock expressions into the `hnock` executable: ``` $ echo '*[[[4 5] [6 14 15]] [0 7]]' | hnock @@ -20,13 +31,18 @@ and evaluate Nock expressions: ``` To evaluate raw nock Nouns, i.e. to compute `nock(a)` for some noun `a`, use -`enock`: +the `nock` function: ``` *Nock> let expression = hnock "[[[4 5] [6 14 15]] [0 7]]" *Nock> expression [[[4 5] [6 [14 15]]] [0 7]] -*Nock> enock expression +*Nock> nock expression [14 15] ``` +## Testing + +Use a simple `stack test` to run the test suite. + +[nock]: https://urbit.org/docs/learn/arvo/nock/definition/ diff --git a/lib/Nock.hs b/lib/Nock.hs @@ -4,27 +4,26 @@ module Nock ( module L , module P - , enock + , nock , hnock - , eval - , nock + , E.eval ) where import Data.Text as T -import Nock.Eval as E +import qualified Nock.Eval as E import Nock.Language as L import Nock.Parse as P hnock :: T.Text -> Noun hnock input = case runParser expr [] "ghci" input of Left perr -> error (show perr) - Right ex -> case eval ex of + Right ex -> case E.eval ex of Left err -> error (show err) Right e -> e -enock :: Noun -> Noun -enock noun = case nock noun of +nock :: Noun -> Noun +nock noun = case E.nock noun of Left err -> error (show err) Right e -> e