diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/library/lux/control/function/contract.lux | 10 | ||||
-rw-r--r-- | stdlib/source/library/lux/control/function/memo.lux | 2 | ||||
-rw-r--r-- | stdlib/source/library/lux/control/function/mutual.lux | 6 |
3 files changed, 11 insertions, 7 deletions
diff --git a/stdlib/source/library/lux/control/function/contract.lux b/stdlib/source/library/lux/control/function/contract.lux index ce62f8c45..0fb706a14 100644 --- a/stdlib/source/library/lux/control/function/contract.lux +++ b/stdlib/source/library/lux/control/function/contract.lux @@ -2,7 +2,9 @@ [library [lux #* [control - ["." exception (#+ exception:)]] + ["." exception (#+ exception:)] + [parser + ["<.>" code]]] [data [text ["%" format (#+ format)]]] @@ -28,7 +30,8 @@ [] (panic! message))) -(syntax: .public (pre test expr) +(syntax: .public (pre [test <code>.any + expr <code>.any]) {#.doc (example "Pre-conditions." "Given a test and an expression to run, only runs the expression if the test passes." "Otherwise, an error is raised." @@ -39,7 +42,8 @@ (~ test)) (~ expr)))))) -(syntax: .public (post test expr) +(syntax: .public (post [test <code>.any + expr <code>.any]) {#.doc (example "Post-conditions." "Given a predicate and an expression to run, evaluates the expression and then tests the output with the predicate." "If the predicate returns #1, returns the value of the expression." diff --git a/stdlib/source/library/lux/control/function/memo.lux b/stdlib/source/library/lux/control/function/memo.lux index 924ec4c00..ae8c4e9bf 100644 --- a/stdlib/source/library/lux/control/function/memo.lux +++ b/stdlib/source/library/lux/control/function/memo.lux @@ -29,7 +29,7 @@ #.None (do ! [output (delegate input) - _ (state.update (dictionary.put input output))] + _ (state.update (dictionary.has input output))] (in output))))))) (type: .public (Memo i o) diff --git a/stdlib/source/library/lux/control/function/mutual.lux b/stdlib/source/library/lux/control/function/mutual.lux index e9cac3871..fd36ac10b 100644 --- a/stdlib/source/library/lux/control/function/mutual.lux +++ b/stdlib/source/library/lux/control/function/mutual.lux @@ -52,8 +52,8 @@ (function (_ parameters) (\ meta.monad in (list (` (((~ g!self) (~ g!context)) (~+ parameters)))))))) -(syntax: .public (let {functions (<code>.tuple (<>.some ..mutual))} - body) +(syntax: .public (let [functions (<code>.tuple (<>.some ..mutual)) + body <code>.any]) {#.doc (example "Locally-defined mutually-recursive functions." (let [(even? number) (-> Nat Bit) @@ -118,7 +118,7 @@ (<code>.tuple (<>.either (<>.and <code>.any ..mutual) (<>.and (<>\in (` .private)) ..mutual)))) -(syntax: .public (def: {functions (<>.many ..definition)}) +(syntax: .public (def: [functions (<>.many ..definition)]) {#.doc (example "Globally-defined mutually-recursive functions." (def: [.public (even? number) |