diff options
Diffstat (limited to 'source/lux')
-rw-r--r-- | source/lux/codata/function.lux | 4 | ||||
-rw-r--r-- | source/lux/codata/lazy.lux | 12 | ||||
-rw-r--r-- | source/lux/codata/reader.lux | 12 | ||||
-rw-r--r-- | source/lux/codata/state.lux | 12 | ||||
-rw-r--r-- | source/lux/codata/stream.lux | 8 | ||||
-rw-r--r-- | source/lux/data/bool.lux | 8 | ||||
-rw-r--r-- | source/lux/data/char.lux | 4 | ||||
-rw-r--r-- | source/lux/data/error.lux | 8 | ||||
-rw-r--r-- | source/lux/data/id.lux | 14 | ||||
-rw-r--r-- | source/lux/data/io.lux | 8 | ||||
-rw-r--r-- | source/lux/data/list.lux | 28 | ||||
-rw-r--r-- | source/lux/data/maybe.lux | 14 | ||||
-rw-r--r-- | source/lux/data/number/int.lux | 40 | ||||
-rw-r--r-- | source/lux/data/number/real.lux | 40 | ||||
-rw-r--r-- | source/lux/data/text.lux | 18 | ||||
-rw-r--r-- | source/lux/data/writer.lux | 8 | ||||
-rw-r--r-- | source/lux/meta/lux.lux | 16 | ||||
-rw-r--r-- | source/lux/meta/syntax.lux | 8 |
18 files changed, 131 insertions, 131 deletions
diff --git a/source/lux/codata/function.lux b/source/lux/codata/function.lux index 8eb87c00b..7898e998d 100644 --- a/source/lux/codata/function.lux +++ b/source/lux/codata/function.lux @@ -26,5 +26,5 @@ ## [Structures] (defstruct #export Comp/Monoid (All [a] (m;Monoid (-> a a))) - (def unit id) - (def ++ .)) + (def m;unit id) + (def m;++ .)) diff --git a/source/lux/codata/lazy.lux b/source/lux/codata/lazy.lux index de5c40eef..893c74d9e 100644 --- a/source/lux/codata/lazy.lux +++ b/source/lux/codata/lazy.lux @@ -9,8 +9,8 @@ (;import lux (lux (meta macro ast) - (control functor - monad) + (control (functor #as F #refer #all) + (monad #as M #refer #all)) (data list)) (.. function)) @@ -37,13 +37,13 @@ ## [Structs] (defstruct #export Lazy/Functor (Functor Lazy) - (def (map f ma) + (def (F;map f ma) (lambda [k] (ma (. k f))))) (defstruct #export Lazy/Monad (Monad Lazy) - (def _functor Lazy/Functor) + (def M;_functor Lazy/Functor) - (def (wrap a) + (def (M;wrap a) (... a)) - (def join !)) + (def M;join !)) diff --git a/source/lux/codata/reader.lux b/source/lux/codata/reader.lux index ee1798793..e91687c3a 100644 --- a/source/lux/codata/reader.lux +++ b/source/lux/codata/reader.lux @@ -7,8 +7,8 @@ ## You must not remove this notice, or any other, from this software. (;import (lux #refer (#exclude Reader)) - (lux/control functor - monad)) + (lux/control (functor #as F #refer #all) + (monad #as M #refer #all))) ## [Types] (deftype #export (Reader r a) @@ -17,17 +17,17 @@ ## [Structures] (defstruct #export Reader/Functor (All [r] (Functor (Reader r))) - (def (map f fa) + (def (F;map f fa) (lambda [env] (f (fa env))))) (defstruct #export Reader/Monad (All [r] (Monad (Reader r))) - (def _functor Reader/Functor) + (def M;_functor Reader/Functor) - (def (wrap x) + (def (M;wrap x) (lambda [env] x)) - (def (join mma) + (def (M;join mma) (lambda [env] (mma env env)))) diff --git a/source/lux/codata/state.lux b/source/lux/codata/state.lux index c6fd8397d..bc9858a29 100644 --- a/source/lux/codata/state.lux +++ b/source/lux/codata/state.lux @@ -7,8 +7,8 @@ ## You must not remove this notice, or any other, from this software. (;import lux - (lux/control functor - monad)) + (lux/control (functor #as F #refer #all) + (monad #as M #refer #all))) ## [Types] (deftype #export (State s a) @@ -16,20 +16,20 @@ ## [Structures] (defstruct #export State/Functor (Functor State) - (def (map f ma) + (def (F;map f ma) (lambda [state] (let [[state' a] (ma state)] [state' (f a)])))) (defstruct #export State/Monad (All [s] (Monad (State s))) - (def _functor State/Functor) + (def M;_functor State/Functor) - (def (wrap x) + (def (M;wrap x) (lambda [state] [state x])) - (def (join mma) + (def (M;join mma) (lambda [state] (let [[state' ma] (mma state)] (ma state'))))) diff --git a/source/lux/codata/stream.lux b/source/lux/codata/stream.lux index 728adc174..64491eb5c 100644 --- a/source/lux/codata/stream.lux +++ b/source/lux/codata/stream.lux @@ -113,14 +113,14 @@ ## [Structures] (defstruct #export Stream/Functor (Functor Stream) - (def (map f fa) + (def (F;map f fa) (let [[h t] (! fa)] (... [(f h) (map f t)])))) (defstruct #export Stream/CoMonad (CoMonad Stream) - (def _functor Stream/Functor) - (def unwrap head) - (def (split wa) + (def CM;_functor Stream/Functor) + (def CM;unwrap head) + (def (CM;split wa) (:: Stream/Functor (F;map repeat wa)))) ## [Pattern-matching] diff --git a/source/lux/data/bool.lux b/source/lux/data/bool.lux index 8f7a3bd13..92f5486ef 100644 --- a/source/lux/data/bool.lux +++ b/source/lux/data/bool.lux @@ -14,19 +14,19 @@ ## [Structures] (defstruct #export Bool/Eq (E;Eq Bool) - (def (= x y) + (def (E;= x y) (if x y (not y)))) (defstruct #export Bool/Show (S;Show Bool) - (def (show x) + (def (S;show x) (if x "true" "false"))) (do-template [<name> <unit> <op>] [(defstruct #export <name> (m;Monoid Bool) - (def unit <unit>) - (def (++ x y) + (def m;unit <unit>) + (def (m;++ x y) (<op> x y)))] [ Or/Monoid false or] diff --git a/source/lux/data/char.lux b/source/lux/data/char.lux index 04579c3a7..b97ec644d 100644 --- a/source/lux/data/char.lux +++ b/source/lux/data/char.lux @@ -13,9 +13,9 @@ ## [Structures] (defstruct #export Char/Eq (E;Eq Char) - (def (= x y) + (def (E;= x y) (_jvm_ceq x y))) (defstruct #export Char/Show (S;Show Char) - (def (show x) + (def (S;show x) ($ text:++ "#\"" (_jvm_invokevirtual "java.lang.Object" "toString" [] x []) "\""))) diff --git a/source/lux/data/error.lux b/source/lux/data/error.lux index 7388dd786..cb5c309a6 100644 --- a/source/lux/data/error.lux +++ b/source/lux/data/error.lux @@ -17,18 +17,18 @@ ## [Structures] (defstruct #export Error/Functor (Functor Error) - (def (map f ma) + (def (F;map f ma) (case ma (#Fail msg) (#Fail msg) (#Ok datum) (#Ok (f datum))))) (defstruct #export Error/Monad (Monad Error) - (def _functor Error/Functor) + (def M;_functor Error/Functor) - (def (wrap a) + (def (M;wrap a) (#Ok a)) - (def (join mma) + (def (M;join mma) (case mma (#Fail msg) (#Fail msg) (#Ok ma) ma))) diff --git a/source/lux/data/id.lux b/source/lux/data/id.lux index 58e7360b8..3ad6b056b 100644 --- a/source/lux/data/id.lux +++ b/source/lux/data/id.lux @@ -17,16 +17,16 @@ ## [Structures] (defstruct #export Id/Functor (Functor Id) - (def (map f fa) + (def (F;map f fa) (let [(#Id a) fa] (#Id (f a))))) (defstruct #export Id/Monad (Monad Id) - (def _functor Id/Functor) - (def (wrap a) (#Id a)) - (def (join mma) (let [(#Id ma) mma] ma))) + (def M;_functor Id/Functor) + (def (M;wrap a) (#Id a)) + (def (M;join mma) (let [(#Id ma) mma] ma))) (defstruct #export Id/CoMonad (CoMonad Id) - (def _functor Id/Functor) - (def (unwrap wa) (let [(#Id a) wa] a)) - (def (split wa) (#Id wa))) + (def CM;_functor Id/Functor) + (def (CM;unwrap wa) (let [(#Id a) wa] a)) + (def (CM;split wa) (#Id wa))) diff --git a/source/lux/data/io.lux b/source/lux/data/io.lux index ae71f9f34..f03dbddc6 100644 --- a/source/lux/data/io.lux +++ b/source/lux/data/io.lux @@ -30,16 +30,16 @@ ## [Structures] (defstruct #export IO/Functor (F;Functor IO) - (def (map f ma) + (def (F;map f ma) (io (f (ma []))))) (defstruct #export IO/Monad (M;Monad IO) - (def _functor IO/Functor) + (def M;_functor IO/Functor) - (def (wrap x) + (def (M;wrap x) (io x)) - (def (join mma) + (def (M;join mma) (mma []))) ## [Functions] diff --git a/source/lux/data/list.lux b/source/lux/data/list.lux index 87afe7fe9..5a8357251 100644 --- a/source/lux/data/list.lux +++ b/source/lux/data/list.lux @@ -258,30 +258,30 @@ (defstruct #export List/Monoid (All [a] (Monoid (List a))) - (def unit #;Nil) - (def (++ xs ys) + (def m;unit #;Nil) + (def (m;++ xs ys) (case xs #;Nil ys (#;Cons [x xs']) (#;Cons [x (++ xs' ys)])))) (defstruct #export List/Functor (Functor List) - (def (map f ma) + (def (F;map f ma) (case ma #;Nil #;Nil (#;Cons [a ma']) (#;Cons [(f a) (map f ma')])))) (defstruct #export List/Monad (Monad List) - (def _functor List/Functor) + (def M;_functor List/Functor) - (def (wrap a) + (def (M;wrap a) (#;Cons [a #;Nil])) - (def (join mma) + (def (M;join mma) (using List/Monoid (foldL ++ unit mma)))) (defstruct #export PList/Dict (Dict PList) - (def (get k (#PList [eq kvs])) + (def (D;get k (#PList [eq kvs])) (loop [kvs kvs] (case kvs #;Nil @@ -292,7 +292,7 @@ (#;Some v') (recur kvs'))))) - (def (put k v (#PList [eq kvs])) + (def (D;put k v (#PList [eq kvs])) (#PList [eq (loop [kvs kvs] (case kvs #;Nil @@ -303,7 +303,7 @@ (#;Cons [k v] kvs') (#;Cons [k' v'] (recur kvs')))))])) - (def (remove k (#PList [eq kvs])) + (def (D;remove k (#PList [eq kvs])) (#PList [eq (loop [kvs kvs] (case kvs #;Nil @@ -315,18 +315,18 @@ (#;Cons [[k' v'] (recur kvs')]))))]))) (defstruct #export List/Stack (S;Stack List) - (def empty (list)) - (def (empty? xs) + (def S;empty (list)) + (def (S;empty? xs) (case xs #;Nil true _ false)) - (def (push x xs) + (def (S;push x xs) (#;Cons x xs)) - (def (pop xs) + (def (S;pop xs) (case xs #;Nil #;None (#;Cons x xs') (#;Some xs'))) - (def (top xs) + (def (S;top xs) (case xs #;Nil #;None (#;Cons x xs') (#;Some x)))) diff --git a/source/lux/data/maybe.lux b/source/lux/data/maybe.lux index e23dbe291..9405c3a60 100644 --- a/source/lux/data/maybe.lux +++ b/source/lux/data/maybe.lux @@ -20,26 +20,26 @@ ## (#;Some a))) ## [Structures] -(defstruct #export Maybe/Monoid (Monoid Maybe) - (def unit #;None) - (def (++ xs ys) +(defstruct #export Maybe/Monoid (All [a] (Monoid (Maybe a))) + (def m;unit #;None) + (def (m;++ xs ys) (case xs #;None ys (#;Some x) (#;Some x)))) (defstruct #export Maybe/Functor (Functor Maybe) - (def (map f ma) + (def (F;map f ma) (case ma #;None #;None (#;Some a) (#;Some (f a))))) (defstruct #export Maybe/Monad (Monad Maybe) - (def _functor Maybe/Functor) + (def M;_functor Maybe/Functor) - (def (wrap x) + (def (M;wrap x) (#;Some x)) - (def (join mma) + (def (M;join mma) (case mma #;None #;None (#;Some xs) xs))) diff --git a/source/lux/data/number/int.lux b/source/lux/data/number/int.lux index f3c81ef4e..35c8d34bf 100644 --- a/source/lux/data/number/int.lux +++ b/source/lux/data/number/int.lux @@ -18,20 +18,20 @@ ## Number (do-template [<name> <type> <+> <-> <*> </> <%> <=> <<> <from> <0> <1> <-1>] [(defstruct #export <name> (N;Number <type>) - (def (+ x y) (<+> x y)) - (def (- x y) (<-> x y)) - (def (* x y) (<*> x y)) - (def (/ x y) (</> x y)) - (def (% x y) (<%> x y)) - (def (from-int x) + (def (N;+ x y) (<+> x y)) + (def (N;- x y) (<-> x y)) + (def (N;* x y) (<*> x y)) + (def (N;/ x y) (</> x y)) + (def (N;% x y) (<%> x y)) + (def (N;from-int x) (<from> x)) - (def (negate x) + (def (N;negate x) (<*> <-1> x)) - (def (abs x) + (def (N;abs x) (if (<<> x <0>) (<*> <-1> x) x)) - (def (signum x) + (def (N;signum x) (cond (<=> x <0>) <0> (<<> x <0>) <-1> ## else @@ -42,18 +42,18 @@ ## Eq (defstruct #export Int/Eq (E;Eq Int) - (def (= x y) (_jvm_leq x y))) + (def (E;= x y) (_jvm_leq x y))) ## Ord (do-template [<name> <type> <eq> <=> <lt> <gt>] [(defstruct #export <name> (O;Ord <type>) - (def _eq <eq>) - (def (< x y) (<lt> x y)) - (def (<= x y) + (def O;_eq <eq>) + (def (O;< x y) (<lt> x y)) + (def (O;<= x y) (or (<lt> x y) (<=> x y))) - (def (> x y) (<gt> x y)) - (def (>= x y) + (def (O;> x y) (<gt> x y)) + (def (O;>= x y) (or (<gt> x y) (<=> x y))))] @@ -62,16 +62,16 @@ ## Bounded (do-template [<name> <type> <top> <bottom>] [(defstruct #export <name> (B;Bounded <type>) - (def top <top>) - (def bottom <bottom>))] + (def B;top <top>) + (def B;bottom <bottom>))] [ Int/Bounded Int (_jvm_getstatic "java.lang.Long" "MAX_VALUE") (_jvm_getstatic "java.lang.Long" "MIN_VALUE")]) ## Monoid (do-template [<name> <type> <unit> <++>] [(defstruct #export <name> (m;Monoid <type>) - (def unit <unit>) - (def (++ x y) (<++> x y)))] + (def m;unit <unit>) + (def (m;++ x y) (<++> x y)))] [ IntAdd/Monoid Int 0 _jvm_ladd] [ IntMul/Monoid Int 1 _jvm_lmul] @@ -82,7 +82,7 @@ ## Show (do-template [<name> <type> <body>] [(defstruct #export <name> (S;Show <type>) - (def (show x) + (def (S;show x) <body>))] [ Int/Show Int (_jvm_invokevirtual "java.lang.Object" "toString" [] x [])] diff --git a/source/lux/data/number/real.lux b/source/lux/data/number/real.lux index 9ba05df62..4f9e4fa5f 100644 --- a/source/lux/data/number/real.lux +++ b/source/lux/data/number/real.lux @@ -18,20 +18,20 @@ ## Number (do-template [<name> <type> <+> <-> <*> </> <%> <=> <<> <from> <0> <1> <-1>] [(defstruct #export <name> (N;Number <type>) - (def (+ x y) (<+> x y)) - (def (- x y) (<-> x y)) - (def (* x y) (<*> x y)) - (def (/ x y) (</> x y)) - (def (% x y) (<%> x y)) - (def (from-int x) + (def (N;+ x y) (<+> x y)) + (def (N;- x y) (<-> x y)) + (def (N;* x y) (<*> x y)) + (def (N;/ x y) (</> x y)) + (def (N;% x y) (<%> x y)) + (def (N;from-int x) (<from> x)) - (def (negate x) + (def (N;negate x) (<*> <-1> x)) - (def (abs x) + (def (N;abs x) (if (<<> x <0>) (<*> <-1> x) x)) - (def (signum x) + (def (N;signum x) (cond (<=> x <0>) <0> (<<> x <0>) <-1> ## else @@ -42,18 +42,18 @@ ## Eq (defstruct #export Real/Eq (E;Eq Real) - (def (= x y) (_jvm_deq x y))) + (def (E;= x y) (_jvm_deq x y))) ## Ord (do-template [<name> <type> <eq> <=> <lt> <gt>] [(defstruct #export <name> (O;Ord <type>) - (def _eq <eq>) - (def (< x y) (<lt> x y)) - (def (<= x y) + (def O;_eq <eq>) + (def (O;< x y) (<lt> x y)) + (def (O;<= x y) (or (<lt> x y) (<=> x y))) - (def (> x y) (<gt> x y)) - (def (>= x y) + (def (O;> x y) (<gt> x y)) + (def (O;>= x y) (or (<gt> x y) (<=> x y))))] @@ -62,16 +62,16 @@ ## Bounded (do-template [<name> <type> <top> <bottom>] [(defstruct #export <name> (B;Bounded <type>) - (def top <top>) - (def bottom <bottom>))] + (def B;top <top>) + (def B;bottom <bottom>))] [Real/Bounded Real (_jvm_getstatic "java.lang.Double" "MAX_VALUE") (_jvm_getstatic "java.lang.Double" "MIN_VALUE")]) ## Monoid (do-template [<name> <type> <unit> <++>] [(defstruct #export <name> (m;Monoid <type>) - (def unit <unit>) - (def (++ x y) (<++> x y)))] + (def m;unit <unit>) + (def (m;++ x y) (<++> x y)))] [RealAdd/Monoid Real 0.0 _jvm_dadd] [RealMul/Monoid Real 1.0 _jvm_dmul] @@ -82,7 +82,7 @@ ## Show (do-template [<name> <type> <body>] [(defstruct #export <name> (S;Show <type>) - (def (show x) + (def (S;show x) <body>))] [Real/Show Real (_jvm_invokevirtual "java.lang.Object" "toString" [] x [])] diff --git a/source/lux/data/text.lux b/source/lux/data/text.lux index 81a642698..d1c06b6a7 100644 --- a/source/lux/data/text.lux +++ b/source/lux/data/text.lux @@ -118,12 +118,12 @@ ## [Structures] (defstruct #export Text/Eq (E;Eq Text) - (def (= x y) + (def (E;= x y) (_jvm_invokevirtual "java.lang.Object" "equals" ["java.lang.Object"] x [y]))) (defstruct #export Text/Ord (O;Ord Text) - (def _eq Text/Eq) + (def O;_eq Text/Eq) (do-template [<name> <op>] [(def (<name> x y) @@ -131,17 +131,17 @@ x [y])) 0))] - [< i<] - [<= i<=] - [> i>] - [>= i>=])) + [O;< i<] + [O;<= i<=] + [O;> i>] + [O;>= i>=])) (defstruct #export Text/Show (S;Show Text) - (def show id)) + (def S;show id)) (defstruct #export Text/Monoid (m;Monoid Text) - (def unit "") - (def (++ x y) + (def m;unit "") + (def (m;++ x y) (_jvm_invokevirtual "java.lang.String" "concat" ["java.lang.String"] x [y]))) diff --git a/source/lux/data/writer.lux b/source/lux/data/writer.lux index 7c6831e85..f71492e35 100644 --- a/source/lux/data/writer.lux +++ b/source/lux/data/writer.lux @@ -18,17 +18,17 @@ ## [Structures] (defstruct #export Writer/Functor (All [l] (Functor (Writer l))) - (def (map f fa) + (def (F;map f fa) (let [[log datum] fa] [log (f datum)]))) (defstruct #export (Writer/Monad mon) (All [l] (-> (Monoid l) (Monad (Writer l)))) - (def _functor Writer/Functor) + (def M;_functor Writer/Functor) - (def (wrap x) + (def (M;wrap x) [(:: mon m;unit) x]) - (def (join mma) + (def (M;join mma) (let [[log1 [log2 a]] mma] [(:: mon (m;++ log1 log2)) a]))) diff --git a/source/lux/meta/lux.lux b/source/lux/meta/lux.lux index d1bc4e219..057345622 100644 --- a/source/lux/meta/lux.lux +++ b/source/lux/meta/lux.lux @@ -29,7 +29,7 @@ ## [Structures] (defstruct #export Lux/Functor (F;Functor Lux) - (def (map f fa) + (def (F;map f fa) (lambda [state] (case (fa state) (#;Left msg) @@ -39,11 +39,11 @@ (#;Right [state' (f a)]))))) (defstruct #export Lux/Monad (M;Monad Lux) - (def _functor Lux/Functor) - (def (wrap x) + (def M;_functor Lux/Functor) + (def (M;wrap x) (lambda [state] (#;Right [state x]))) - (def (join mma) + (def (M;join mma) (lambda [state] (case (mma state) (#;Left msg) @@ -254,7 +254,7 @@ (let [vname' (ident->text name)] (case state {#;source source #;modules modules - #;envs envs #;types types #;host host + #;envs envs #;type-vars types #;host host #;seed seed #;eval? eval? #;expected expected #;cursor cursor} (some (: (-> (Env Text (, LuxVar Type)) (Maybe Type)) @@ -275,14 +275,14 @@ (-> Ident Compiler (Maybe Type)) (let [[v-prefix v-name] name {#;source source #;modules modules - #;envs envs #;types types #;host host + #;envs envs #;type-vars types #;host host #;seed seed #;eval? eval? #;expected expected #;cursor cursor} state] (case (get v-prefix modules) #;None #;None - (#;Some {#;defs defs #;module-aliases _ #;imports _}) + (#;Some {#;defs defs #;module-aliases _ #;imports _ #;tags _ #;types _}) (case (get v-name defs) #;None #;None @@ -311,7 +311,7 @@ _ (let [{#;source source #;modules modules - #;envs envs #;types types #;host host + #;envs envs #;type-vars types #;host host #;seed seed #;eval? eval? #;expected expected #;cursor cursor} state] (#;Left ($ text:++ "Unknown var: " (ident->text name) "\n\n" (show-envs envs)))))))) diff --git a/source/lux/meta/syntax.lux b/source/lux/meta/syntax.lux index f1644cdb5..b9834f972 100644 --- a/source/lux/meta/syntax.lux +++ b/source/lux/meta/syntax.lux @@ -38,7 +38,7 @@ ## [Structures] (defstruct #export Parser/Functor (F;Functor Parser) - (def (map f ma) + (def (F;map f ma) (lambda [tokens] (case (ma tokens) #;None @@ -48,12 +48,12 @@ (#;Some [tokens' (f a)]))))) (defstruct #export Parser/Monad (M;Monad Parser) - (def _functor Parser/Functor) + (def M;_functor Parser/Functor) - (def (wrap x tokens) + (def (M;wrap x tokens) (#;Some [tokens x])) - (def (join mma) + (def (M;join mma) (lambda [tokens] (case (mma tokens) #;None |