aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/abstract/monad/indexed.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/abstract/monad/indexed.lux')
-rw-r--r--stdlib/source/lux/abstract/monad/indexed.lux83
1 files changed, 0 insertions, 83 deletions
diff --git a/stdlib/source/lux/abstract/monad/indexed.lux b/stdlib/source/lux/abstract/monad/indexed.lux
deleted file mode 100644
index 5a5a63b27..000000000
--- a/stdlib/source/lux/abstract/monad/indexed.lux
+++ /dev/null
@@ -1,83 +0,0 @@
-(.module:
- [lux #*
- [control
- [monad]
- ["p" parser
- ["s" code (#+ Parser)]]]
- [data
- [collection
- ["." list ("#\." functor fold)]]]
- ["." macro
- [syntax (#+ syntax:)]
- ["." code]]])
-
-(interface: #export (IxMonad m)
- (: (All [p a]
- (-> a (m p p a)))
- wrap)
-
- (: (All [ii it io vi vo]
- (-> (-> vi (m it io vo))
- (m ii it vi)
- (m ii io vo)))
- bind))
-
-(type: Binding [Code Code])
-
-(def: binding
- (Parser Binding)
- (p.and s.any s.any))
-
-(type: Context
- (#Let (List Binding))
- (#Bind Binding))
-
-(def: context
- (Parser Context)
- (p.or (p.after (s.this! (' #let))
- (s.tuple (p.some binding)))
- binding))
-
-(def: (pair_list [binding value])
- (All [a] (-> [a a] (List a)))
- (list binding value))
-
-(def: named_monad
- (Parser [(Maybe Text) Code])
- (p.either (s.record (p.and (\ p.monad map (|>> #.Some)
- s.local_identifier)
- s.any))
- (\ p.monad map (|>> [#.None])
- s.any)))
-
-(syntax: #export (do {[?name monad] ..named_monad}
- {context (s.tuple (p.some context))}
- expression)
- (macro.with_gensyms [g!_ g!bind]
- (let [body (list\fold (function (_ context next)
- (case context
- (#Let bindings)
- (` (let [(~+ (|> bindings
- (list\map pair_list)
- list.concat))]
- (~ next)))
-
- (#Bind [binding value])
- (` ((~ g!bind)
- (.function ((~ g!_) (~ binding))
- (~ next))
- (~ value)))))
- expression
- (list.reverse context))]
- (wrap (list (case ?name
- (#.Some name)
- (let [name (code.local_identifier name)]
- (` (let [(~ name) (~ monad)
- {#..wrap (~' wrap)
- #..bind (~ g!bind)} (~ name)]
- (~ body))))
-
- #.None
- (` (let [{#..wrap (~' wrap)
- #..bind (~ g!bind)} (~ monad)]
- (~ body)))))))))