mirror of
https://github.com/chrisdone/duet.git
synced 2025-01-08 06:53:22 +03:00
More run docs
This commit is contained in:
parent
60b09edec1
commit
8733efb581
34
README.md
34
README.md
@ -21,6 +21,39 @@ Available commands:
|
|||||||
run Run the given program source
|
run Run the given program source
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Run
|
||||||
|
|
||||||
|
The help for this command:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ duet run --help
|
||||||
|
Usage: duet run FILEPATH [--main NAME] [--concise] [-n|--steps steps]
|
||||||
|
Run the given program source
|
||||||
|
|
||||||
|
Available options:
|
||||||
|
-h,--help Show this help text
|
||||||
|
FILEPATH The .hs file to interpret
|
||||||
|
--main NAME The main value to run
|
||||||
|
--concise Concise view
|
||||||
|
-n,--steps steps steps
|
||||||
|
```
|
||||||
|
|
||||||
|
Running code in Duet literally performs one substitution step at
|
||||||
|
time. For example, evaluating `(\x -> x + 5) (2 * 3)`, we get:
|
||||||
|
|
||||||
|
``` haskell
|
||||||
|
[1]
|
||||||
|
(\x -> x + 5) (2 * 3)
|
||||||
|
[2]
|
||||||
|
(2 * 3) + 5
|
||||||
|
[3]
|
||||||
|
6 + 5
|
||||||
|
[4]
|
||||||
|
11
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that this demonstrates basic argument application and non-strictness.
|
||||||
|
|
||||||
Example `integers.hs`:
|
Example `integers.hs`:
|
||||||
|
|
||||||
```haskell
|
```haskell
|
||||||
@ -46,6 +79,7 @@ $ duet run examples/integers.hs
|
|||||||
See also the next section for a complete example using all the
|
See also the next section for a complete example using all the
|
||||||
available syntax.
|
available syntax.
|
||||||
|
|
||||||
|
* Duet is non-strict, but is not lazy. There is no sharing and no thunks.
|
||||||
* No `let` syntax, no parameters in definitions e.g. `f x = ..` you
|
* No `let` syntax, no parameters in definitions e.g. `f x = ..` you
|
||||||
must use a lambda. Representing `let` in the stepper presents a
|
must use a lambda. Representing `let` in the stepper presents a
|
||||||
design challenge not currently met.
|
design challenge not currently met.
|
||||||
|
@ -1,14 +1 @@
|
|||||||
factorial = \n -> case n of
|
it = (\x -> x + 5) (2 * 3)
|
||||||
0 -> 1
|
|
||||||
1 -> 1
|
|
||||||
_ -> n * factorial (n - 1)
|
|
||||||
|
|
||||||
|
|
||||||
go =
|
|
||||||
\n acc ->
|
|
||||||
case n of
|
|
||||||
0 -> acc
|
|
||||||
1 -> acc
|
|
||||||
_ -> go (n - 1) (n * acc)
|
|
||||||
|
|
||||||
it = go 3 1
|
|
||||||
|
Loading…
Reference in New Issue
Block a user