aboutsummaryrefslogtreecommitdiffstats
path: root/docs/reference
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2021-01-08 16:03:59 +0000
committers-ol <s-ol@users.noreply.github.com>2021-01-08 16:03:59 +0000
commit09b85d4e07984c7453e34585d829757f0c83cff8 (patch)
treeb3b858f0d98cc29261386dd4df61cb2118c51976 /docs/reference
parentadd reference/pure-operators (diff)
downloadalive-09b85d4e07984c7453e34585d829757f0c83cff8.tar.gz
alive-09b85d4e07984c7453e34585d829757f0c83cff8.zip
add reference/arrays and reference/structs
Diffstat (limited to 'docs/reference')
-rw-r--r--docs/reference/04-2_pure-operators.md31
-rw-r--r--docs/reference/05-1_arrays.md11
-rw-r--r--docs/reference/05-2_structs.md16
-rw-r--r--docs/reference/index.md6
4 files changed, 46 insertions, 18 deletions
diff --git a/docs/reference/04-2_pure-operators.md b/docs/reference/04-2_pure-operators.md
index d4a8d14..d2dc4c5 100644
--- a/docs/reference/04-2_pure-operators.md
+++ b/docs/reference/04-2_pure-operators.md
@@ -21,23 +21,26 @@ As an example, let's consider [math/+][]:
(import* math time)
(trace (+ 1 2 3))
- #((+ num= num= num=) -> num=
- trace (+ 1 2 3): <num= 6>)
-
(trace (+ 1 2 (lfo 2)))
- #((+ num= num= num~) -> num~
- trace (+ 1 2 (lfo 2)): <num~ 4.0>
- trace (+ 1 2 (lfo 2)): <num~ 3.9882585630406>)
-
(trace (+ 1 2 (every 1 3)))
- #((+ num= num= num!) -> num!
- trace (+ 1 2 (every 2 3)): <num! 6>
- trace (+ 1 2 (every 2 3)): <num! 6>)
-
(trace (+ 1 (lfo 2) (every 1 3)))
- #((+ num= num~ num!) -> num!
- trace (+ 1 (lfo 2) (every 2 3)): <num! 4.9950529446967>
- trace (+ 1 (lfo 2) (every 2 3)): <num! 4.9950529446967>)
+
+<div />
+
+ (+ num= num= num=) -> num=
+ trace (+ 1 2 3): <num= 6>
+
+ (+ num= num= num~) -> num~
+ trace (+ 1 2 (lfo 2)): <num~ 4.0>
+ trace (+ 1 2 (lfo 2)): <num~ 3.9882585630406>
+
+ (+ num= num= num!) -> num!
+ trace (+ 1 2 (every 2 3)): <num! 6>
+ trace (+ 1 2 (every 2 3)): <num! 6>
+
+ (+ num= num~ num!) -> num!
+ trace (+ 1 (lfo 2) (every 2 3)): <num! 4.9950529446967>
+ trace (+ 1 (lfo 2) (every 2 3)): <num! 4.9950529446967>
Sometimes a *Pure Op* will require additional constraints on the *kinds* of
some of its inputs. These will be specified in the documentation.
diff --git a/docs/reference/05-1_arrays.md b/docs/reference/05-1_arrays.md
new file mode 100644
index 0000000..cf10f1e
--- /dev/null
+++ b/docs/reference/05-1_arrays.md
@@ -0,0 +1,11 @@
+Arrays are composite types that contain a fixed number of values of the same
+type. Arrays values can be created using the [`(array …)`][:array:] builtin,
+which uses [Pure Op](04-2_pure-operators.html) semantics to construct an array
+from its parameters, all of which have to be of the same type.
+
+ (trace (array 1 2 3)) #(<num[3]= [1 2 3]>)
+
+The type notation `num[3]` designates an array of three numbers, whereas the
+value notation `[1 2 3]` is used to show the array contents.
+
+The [array][:array/:] module provides *Op*s for working with arrays.
diff --git a/docs/reference/05-2_structs.md b/docs/reference/05-2_structs.md
new file mode 100644
index 0000000..83181df
--- /dev/null
+++ b/docs/reference/05-2_structs.md
@@ -0,0 +1,16 @@
+Structs are composite types that contain values of different types associated
+with a set of string keys. The set of keys and their corresponding value types
+is fixed at *runtime*.
+
+Struct values can be created using the the [`(struct …)`][:struct:] builtin,
+which uses [Pure Op](04-2_pure-operators.html) semantics to construct a struct
+from its parameters. The keys have to be constants.
+
+ (trace (struct "a" 1 "b" 'hello world')) <{a: num b: str}= {a: 1 b: "hello world"}>
+
+The type notation `{a: num b: str}` designates a struct type with the key `a`
+mapping to a value of type `num` and the key `b` mapping to a value of type
+`str` respectively, whereas the value notation `{a: 1 b: "hello world"}` shows
+the struct contents.
+
+The [struct][:struct/:] module provides *Op*s for working with arrays.
diff --git a/docs/reference/index.md b/docs/reference/index.md
index 4d2dd40..beb6f77 100644
--- a/docs/reference/index.md
+++ b/docs/reference/index.md
@@ -1,5 +1,3 @@
-__This section is currently under construction.__
-
This reference manual documents the `alv` langauge and its standard facilities
in detail. If you are new to alive, the [getting started guide][guide] is the
recommended place to start. If you are looking for information on adding your
@@ -23,7 +21,7 @@ own module or contributing to alive, check out the
1. [result kinds](04-1_result-kinds.html)
2. [pure operators](04-2_pure-operators.html)
5. compound types
- 1. arrays
- 2. structs
+ 1. [arrays](05-1_arrays.html)
+ 2. [structs](05-2_structs.html)
6. [builtin listing](builtins.html)
7. included modules