aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorCamil Staps2016-03-30 10:54:45 +0200
committerCamil Staps2016-03-30 11:25:31 +0200
commit25681f822f4a965ca38efa47eed9927b0edc75c7 (patch)
tree3d7b1bd603f83f5a5f4faff85939dd397beb67c2 /README.md
parentReadme: features, headings (diff)
Overloaded state, more boolean ops, unaliased Var
Diffstat (limited to 'README.md')
-rw-r--r--README.md27
1 files changed, 14 insertions, 13 deletions
diff --git a/README.md b/README.md
index 0619e88..a69c119 100644
--- a/README.md
+++ b/README.md
@@ -17,23 +17,26 @@ For example, the [following program][sqrt] is a rounded down square root
function (if `x=n` at the start and `n` is a natural number, then `z` is the
square root of `n`, rounded down, after execution):
+ import While
+ from WhileVars import o, s, x, z // o :== Var 'o'; etc.
+
sqrt :: Stm
- sqrt = 'z' := 0 :.
- 'o' := 1 :.
- 's' := 1 :.
- While ('s' <= 'x')
- ( 'z' := 'z' + 1 :.
- 'o' := 'o' + 2 :.
- 's' := 's' + 'o' )
+ sqrt = z := 0 :.
+ o := 1 :.
+ s := 1 :.
+ While (s <= x)
+ ( z := z + 1 :.
+ o := o + 2 :.
+ s := s + o )
### Evaluation
-We can now execute this code on a `State`, which maps `Var` (`Char`) to `Int`:
+We can now execute this code on a `State`, which maps `Var` to `Int`:
Start :: Int
- Start = eval NS sqrt st 'z'
+ Start = eval NS sqrt st z
where
- st :: Var -> Int
- st 'x' = 36
+ st :: Char -> Int // Or: st :: Var -> Int // st :: CharState
+ st 'x' = 9 // st (Var 'x') = 9 // st = \'x' -> 9
`eval NS sqrt st` is a `State` itself (the state that results from execution of
`sqrt` in `st`), so we apply that to `z` to get the result. Other than the
@@ -135,8 +138,6 @@ qualified imports where needed.
## Todo
- Gast testing
- - More boolean operators for testing integers besides `==` and `<=`
- - Can boolean operators be made functions rather than type constructors?
- Prettyprint for `DerivTree`
- Parser
- Add the state to the `toString` of `DerivTree` and `DerivSeq`