aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/type/resource.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/type/resource.lux52
1 files changed, 25 insertions, 27 deletions
diff --git a/stdlib/source/lux/type/resource.lux b/stdlib/source/lux/type/resource.lux
index a6d60074b..07425c45b 100644
--- a/stdlib/source/lux/type/resource.lux
+++ b/stdlib/source/lux/type/resource.lux
@@ -9,8 +9,8 @@
["." io (#+ IO)]
[concurrency
["." promise (#+ Promise)]]
- ["p" parser
- ["s" code (#+ Parser)]]]
+ ["<>" parser
+ ["<.>" code (#+ Parser)]]]
[data
["." identity (#+ Identity)]
["." maybe]
@@ -80,25 +80,22 @@
[async Promise promise.monad run_async lift_async]
)
-(abstract: #export Ordered [])
+(abstract: #export Ordered Any)
-(abstract: #export Commutative [])
+(abstract: #export Commutative Any)
(abstract: #export (Key mode key)
- []
+ Any
(template [<name> <mode>]
[(def: <name>
- (Ex [k] (-> [] (Key <mode> k)))
+ (Ex [k] (-> Any (Key <mode> k)))
(|>> :abstraction))]
[ordered_key Ordered]
[commutative_key Commutative]
))
-(type: #export OK (Key Ordered))
-(type: #export CK (Key Commutative))
-
(abstract: #export (Res key value)
value
@@ -138,21 +135,22 @@
(def: indices
(Parser (List Nat))
- (s.tuple (loop [seen (set.new n.hash)]
- (do {! p.monad}
- [done? s.end?]
- (if done?
- (wrap (list))
- (do !
- [head s.nat
- _ (p.assert (exception.construct index_cannot_be_repeated head)
- (not (set.member? seen head)))
- tail (recur (set.add head seen))]
- (wrap (list& head tail))))))))
+ (<code>.tuple (loop [seen (set.new n.hash)]
+ (do {! <>.monad}
+ [done? <code>.end?]
+ (if done?
+ (wrap (list))
+ (do !
+ [head <code>.nat
+ _ (<>.assert (exception.construct ..index_cannot_be_repeated head)
+ (not (set.member? seen head)))
+ tail (recur (set.add head seen))]
+ (wrap (list& head tail))))))))
(def: (no_op Monad<m>)
(All [m] (-> (Monad m) (Linear m Any)))
- (function (_ context) (\ Monad<m> wrap [context []])))
+ (function (_ context)
+ (\ Monad<m> wrap [context []])))
(template [<name> <m> <monad>]
[(syntax: #export (<name> {swaps ..indices})
@@ -174,8 +172,8 @@
swaps)
maybe.assume
row.to_list)
- g!inputsT+ (list\map (|>> (~) ..CK (`)) g!inputs)
- g!outputsT+ (list\map (|>> (~) ..CK (`)) g!outputs)]]
+ g!inputsT+ (list\map (|>> (~) (..Key ..Commutative) (`)) g!inputs)
+ g!outputsT+ (list\map (|>> (~) (..Key ..Commutative) (`)) g!outputs)]]
(wrap (list (` (: (All [(~+ g!inputs) (~ g!context)]
(Procedure (~! <m>)
[(~+ g!inputsT+) (~ g!context)]
@@ -191,10 +189,10 @@
(def: amount
(Parser Nat)
- (do p.monad
- [raw s.nat
- _ (p.assert (exception.construct ..amount_cannot_be_zero [])
- (n.> 0 raw))]
+ (do <>.monad
+ [raw <code>.nat
+ _ (<>.assert (exception.construct ..amount_cannot_be_zero [])
+ (n.> 0 raw))]
(wrap raw)))
(template [<name> <m> <monad> <from> <to>]