aboutsummaryrefslogtreecommitdiff
path: root/source/lux
diff options
context:
space:
mode:
Diffstat (limited to 'source/lux')
-rw-r--r--source/lux/data/list.lux20
-rw-r--r--source/lux/data/text.lux18
-rw-r--r--source/lux/meta/lux.lux8
3 files changed, 31 insertions, 15 deletions
diff --git a/source/lux/data/list.lux b/source/lux/data/list.lux
index 2bbbe66cc..f840688fd 100644
--- a/source/lux/data/list.lux
+++ b/source/lux/data/list.lux
@@ -11,7 +11,8 @@
(functor #as F #refer #all)
(monad #as M #refer #all)
(eq #as E)
- (dict #as D #refer #all))
+ (dict #as D #refer #all)
+ (stack #as S))
(data (number (int #open ("i" Int/Number Int/Ord Int/Eq)))
bool)
meta/macro))
@@ -312,3 +313,20 @@
(if (:: eq (E;= k k'))
kvs'
(#;Cons [[k' v'] (recur kvs')]))))])))
+
+(defstruct #export List/Stack (S;Stack List)
+ (def S;empty (list))
+ (def (S;empty? xs)
+ (case xs
+ #;Nil true
+ _ false))
+ (def (S;push x xs)
+ (#;Cons x xs))
+ (def (S;pop xs)
+ (case xs
+ #;Nil #;None
+ (#;Cons x xs') (#;Some xs')))
+ (def (S;top xs)
+ (case xs
+ #;Nil #;None
+ (#;Cons x xs') (#;Some x))))
diff --git a/source/lux/data/text.lux b/source/lux/data/text.lux
index ae4f9974f..1d582c1d5 100644
--- a/source/lux/data/text.lux
+++ b/source/lux/data/text.lux
@@ -147,16 +147,14 @@
## [Syntax]
(def (extract-var template)
(-> Text (Maybe (, Text Text Text)))
- (exec (_jvm_invokevirtual "java.io.PrintStream" "println" ["java.lang.Object"]
- (_jvm_getstatic "java.lang.System" "out") [(:: Text/Monoid (m;++ "Template: " template))])
- (do Maybe/Monad
- [pre-idx (index-of "#{" template)
- [pre in] (split pre-idx template)
- [_ in] (split 2 in)
- post-idx (index-of "}" in)
- [var post] (split post-idx in)
- [_ post] (split 1 post)]
- (M;wrap [pre var post]))))
+ (do Maybe/Monad
+ [pre-idx (index-of "#{" template)
+ [pre in] (split pre-idx template)
+ [_ in] (split 2 in)
+ post-idx (index-of "}" in)
+ [var post] (split post-idx in)
+ [_ post] (split 1 post)]
+ (M;wrap [pre var post])))
(def (unravel-template template)
(-> Text (List Syntax))
diff --git a/source/lux/meta/lux.lux b/source/lux/meta/lux.lux
index 66e4cc341..cdbade999 100644
--- a/source/lux/meta/lux.lux
+++ b/source/lux/meta/lux.lux
@@ -286,10 +286,10 @@
(#;Some [_ def-data])
(case def-data
- #;TypeD (#;Some Type)
- (#;ValueD type) (#;Some type)
- (#;MacroD m) (#;Some Macro)
- (#;AliasD name') (find-in-defs name' state))))))
+ (#;TypeD value) (#;Some Type)
+ (#;ValueD type _) (#;Some type)
+ (#;MacroD m) (#;Some Macro)
+ (#;AliasD name') (find-in-defs name' state))))))
(def #export (find-var-type name)
(-> Ident (Lux Type))