aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--luxc/src/lux/lexer.clj20
-rw-r--r--stdlib/source/lux.lux496
-rw-r--r--stdlib/source/lux/compiler/default/phase/analysis.lux2
-rw-r--r--stdlib/source/lux/compiler/default/phase/analysis/expression.lux4
-rw-r--r--stdlib/source/lux/compiler/default/phase/analysis/function.lux2
-rw-r--r--stdlib/source/lux/compiler/default/phase/analysis/inference.lux2
-rw-r--r--stdlib/source/lux/compiler/default/phase/extension.lux2
-rw-r--r--stdlib/source/lux/compiler/default/phase/extension/analysis/host.jvm.lux40
-rw-r--r--stdlib/source/lux/compiler/default/syntax.lux19
-rw-r--r--stdlib/source/lux/control/concatenative.lux2
-rw-r--r--stdlib/source/lux/control/exception.lux8
-rw-r--r--stdlib/source/lux/control/region.lux12
-rw-r--r--stdlib/source/lux/data/format/css.lux2
-rw-r--r--stdlib/source/lux/data/format/xml.lux10
-rw-r--r--stdlib/source/lux/data/number.lux4
-rw-r--r--stdlib/source/lux/data/text.lux34
-rw-r--r--stdlib/source/lux/data/text/regex.lux2
-rw-r--r--stdlib/source/lux/interpreter.lux12
-rw-r--r--stdlib/source/lux/io.lux4
-rw-r--r--stdlib/source/lux/macro.lux10
-rw-r--r--stdlib/source/lux/macro/poly.lux2
-rw-r--r--stdlib/source/lux/macro/syntax.lux2
-rw-r--r--stdlib/source/lux/math/modular.lux10
-rw-r--r--stdlib/source/lux/test.lux16
-rw-r--r--stdlib/source/lux/type.lux4
-rw-r--r--stdlib/source/lux/type/check.lux6
-rw-r--r--stdlib/test/test/lux/compiler/default/syntax.lux6
-rw-r--r--stdlib/test/test/lux/macro/syntax.lux4
28 files changed, 362 insertions, 375 deletions
diff --git a/luxc/src/lux/lexer.clj b/luxc/src/lux/lexer.clj
index 8f6d4e19c..fc572790b 100644
--- a/luxc/src/lux/lexer.clj
+++ b/luxc/src/lux/lexer.clj
@@ -37,8 +37,6 @@
(if (= \\ current-char)
(do (assert (< (+ 1 idx) line-length) (str "[Lexer Error] Text is too short for escaping: " raw-line " " idx))
(case (.charAt raw-line (+ 1 idx))
- \n (do (.append buffer "\n")
- (recur (+ 2 idx)))
\\ (do (.append buffer "\\")
(recur (+ 2 idx)))
;; else
@@ -47,26 +45,12 @@
(recur (+ 1 idx)))))
(.toString buffer)))))
-(defn- lex-text-body [_]
- (|do [[_ _ ^String pre-quotes*] (&reader/read-regex #"^([^\"]*)")
- [pre-quotes post-quotes] (if (.endsWith pre-quotes* "\\")
- (if (if-let [^String back-slashes (re-find #"\\+$" pre-quotes*)]
- (odd? (.length back-slashes)))
- (|do [[_ _ _] (&reader/read-regex #"^([\"])")
- next-part (lex-text-body nil)]
- (return (&/T [(.substring pre-quotes* 0 (dec (.length pre-quotes*)))
- (str "\"" next-part)])))
- (|do [post-quotes* (lex-text-body nil)]
- (return (&/T [pre-quotes* post-quotes*]))))
- (return (&/T [pre-quotes* ""])))]
- (return (str (clean-line pre-quotes) post-quotes))))
-
(def lex-text
(|do [[meta _ _] (&reader/read-text "\"")
:let [[_ _ _column] meta]
- token (lex-text-body nil)
+ [_ _ ^String content] (&reader/read-regex #"^([^\"]*)")
_ (&reader/read-text "\"")]
- (return (&/T [meta ($Text token)]))))
+ (return (&/T [meta ($Text (clean-line content))]))))
(def +ident-re+
#"^([^0-9\[\]\{\}\(\)\s\"#.][^\[\]\{\}\(\)\s\"#.]*)")
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux
index 5e14a9806..0417c9a4d 100644
--- a/stdlib/source/lux.lux
+++ b/stdlib/source/lux.lux
@@ -3,6 +3,16 @@
("lux int char" +34))
[["" 0 0] (10 (0))])
+("lux def" new-line
+ ("lux check" (0 "#Text" (0))
+ ("lux int char" +10))
+ [["" 0 0] (10 (0))])
+
+("lux def" __paragraph
+ ("lux check" (0 "#Text" (0))
+ ("lux text concat" new-line new-line))
+ [["" 0 0] (10 (0))])
+
("lux def" dummy-cursor
("lux check" (2 (0 "#Text" (0))
(2 (0 "#I64" (1 (0 "#Nat" (0)) (0)))
@@ -25,7 +35,7 @@
[dummy-cursor (0 #1)]]
(1 [[dummy-cursor (7 ["lux" "doc"])]
[dummy-cursor (5 ("lux text concat"
- "The type of things whose type is irrelevant.\n\n"
+ ("lux text concat" "The type of things whose type is irrelevant." __paragraph)
"It can be used to write functions or data-structures that can take, or return, anything."))]]
(0)))))])
@@ -41,7 +51,7 @@
[dummy-cursor (0 #1)]]
(1 [[dummy-cursor (7 ["lux" "doc"])]
[dummy-cursor (5 ("lux text concat"
- "The type of things whose type is undefined.\n\n"
+ ("lux text concat" "The type of things whose type is undefined." __paragraph)
"Useful for expressions that cause errors or other 'extraordinary' conditions."))]]
(0)))))])
@@ -104,7 +114,7 @@
[dummy-cursor (0 #1)]]
(#Cons [[dummy-cursor (7 ["lux" "doc"])]
[dummy-cursor (5 ("lux text concat"
- "Natural numbers (unsigned integers).\n\n"
+ ("lux text concat" "Natural numbers (unsigned integers)." __paragraph)
"They start at zero (0) and extend in the positive direction."))]]
#Nil))))])
@@ -130,7 +140,7 @@
[dummy-cursor (0 #1)]]
(#Cons [[dummy-cursor (7 ["lux" "doc"])]
[dummy-cursor (5 ("lux text concat"
- "Fractional numbers that live in the interval [0,1).\n\n"
+ ("lux text concat" "Fractional numbers that live in the interval [0,1)." __paragraph)
"Useful for probability, and other domains that work within that interval."))]]
#Nil))))])
@@ -167,9 +177,7 @@
(#Cons [[dummy-cursor (7 ["lux" "export?"])]
[dummy-cursor (0 #1)]]
(#Cons [[dummy-cursor (7 ["lux" "doc"])]
- [dummy-cursor (5 ("lux text concat"
- "A name.\n\n"
- "It is used as part of Lux syntax to represent identifiers and tags."))]]
+ [dummy-cursor (5 "A name. It is used as part of Lux syntax to represent identifiers and tags.")]]
#Nil))))])
## (type: (Maybe a)
@@ -753,9 +761,9 @@
#Nil)))))))))))))]
(#Cons [(tag$ ["lux" "doc"])
(text$ ("lux text concat"
- "Represents the state of the Lux compiler during a run.\n\n"
+ ("lux text concat" "Represents the state of the Lux compiler during a run." __paragraph)
("lux text concat"
- "It is provided to macros during their invocation, so they can access compiler data.\n\n"
+ ("lux text concat" "It is provided to macros during their invocation, so they can access compiler data." __paragraph)
"Caveat emptor: Avoid fiddling with it, unless you know what you're doing.")))]
default-def-meta-exported))))
@@ -769,7 +777,7 @@
(#Apply Text Either)))))
(record$ (#Cons [(tag$ ["lux" "doc"])
(text$ ("lux text concat"
- "Computations that can have access to the state of the compiler.\n\n"
+ ("lux text concat" "Computations that can have access to the state of the compiler." __paragraph)
"These computations may fail, or modify the state of the compiler."))]
(#Cons [(tag$ ["lux" "type-args"])
(tuple$ (#Cons (text$ "a") #Nil))]
@@ -1033,9 +1041,9 @@
(macro:' #export (comment tokens)
(#Cons [(tag$ ["lux" "doc"])
(text$ ("lux text concat"
- "## Throws away any code given to it.\n\n"
+ ("lux text concat" "## Throws away any code given to it." __paragraph)
("lux text concat"
- "## Great for commenting-out code, while retaining syntax high-lighting and formatting in your text editor.\n\n"
+ ("lux text concat" "## Great for commenting-out code, while retaining syntax high-lighting and formatting in your text editor." __paragraph)
"(comment +1 +2 +3 +4)")))]
#Nil)
(return #Nil))
@@ -1227,11 +1235,11 @@
(macro:' #export (All tokens)
(#Cons [(tag$ ["lux" "doc"])
(text$ ("lux text concat"
- "## Universal quantification.\n\n"
+ ("lux text concat" "## Universal quantification." __paragraph)
("lux text concat"
- "(All [a] (-> a a))\n\n"
+ ("lux text concat" "(All [a] (-> a a))" __paragraph)
("lux text concat"
- "## A name can be provided, to specify a recursive type.\n\n"
+ ("lux text concat" "## A name can be provided, to specify a recursive type." __paragraph)
"(All List [a] (| Any [a (List a)]))"))))]
#Nil)
(let'' [self-name tokens] ({(#Cons [_ (#Identifier "" self-name)] tokens)
@@ -1271,11 +1279,11 @@
(macro:' #export (Ex tokens)
(#Cons [(tag$ ["lux" "doc"])
(text$ ("lux text concat"
- "## Existential quantification.\n\n"
+ ("lux text concat" "## Existential quantification." __paragraph)
("lux text concat"
- "(Ex [a] [(Codec Text a) a])\n\n"
+ ("lux text concat" "(Ex [a] [(Codec Text a) a])" __paragraph)
("lux text concat"
- "## A name can be provided, to specify a recursive type.\n\n"
+ ("lux text concat" "## A name can be provided, to specify a recursive type." __paragraph)
"(Ex Self [a] [(Codec Text a) a (List (Self a))])"))))]
#Nil)
(let'' [self-name tokens] ({(#Cons [_ (#Identifier "" self-name)] tokens)
@@ -1323,9 +1331,9 @@
(macro:' #export (-> tokens)
(#Cons [(tag$ ["lux" "doc"])
(text$ ("lux text concat"
- "## Function types:\n\n"
+ ("lux text concat" "## Function types:" __paragraph)
("lux text concat"
- "(-> Int Int Int)\n\n"
+ ("lux text concat" "(-> Int Int Int)" __paragraph)
"## This is the type of a function that takes 2 Ints and returns an Int.")))]
#Nil)
({(#Cons output inputs)
@@ -1342,7 +1350,7 @@
(macro:' #export (list xs)
(#Cons [(tag$ ["lux" "doc"])
(text$ ("lux text concat"
- "## List-construction macro.\n\n"
+ ("lux text concat" "## List-construction macro." __paragraph)
"(list +1 +2 +3)"))]
#Nil)
(return (#Cons (list/fold (function'' [head tail]
@@ -1356,9 +1364,9 @@
(macro:' #export (list& xs)
(#Cons [(tag$ ["lux" "doc"])
(text$ ("lux text concat"
- "## List-construction macro, with the last element being a tail-list.\n\n"
+ ("lux text concat" "## List-construction macro, with the last element being a tail-list." __paragraph)
("lux text concat"
- "## In other words, this macro prepends elements to another list.\n\n"
+ ("lux text concat" "## In other words, this macro prepends elements to another list." __paragraph)
"(list& +1 +2 +3 (list +4 +5 +6))")))]
#Nil)
({(#Cons last init)
@@ -1375,11 +1383,11 @@
(macro:' #export (& tokens)
(#Cons [(tag$ ["lux" "doc"])
(text$ ("lux text concat"
- "## Tuple types:\n\n"
+ ("lux text concat" "## Tuple types:" __paragraph)
("lux text concat"
- "(& Text Int Bit)\n\n"
+ ("lux text concat" "(& Text Int Bit)" __paragraph)
("lux text concat"
- "## Any.\n\n"
+ ("lux text concat" "## Any." __paragraph)
"(&)"))))]
#Nil)
({#Nil
@@ -1394,11 +1402,11 @@
(macro:' #export (| tokens)
(#Cons [(tag$ ["lux" "doc"])
(text$ ("lux text concat"
- "## Variant types:\n\n"
+ ("lux text concat" "## Variant types:" __paragraph)
("lux text concat"
- "(| Text Int Bit)\n\n"
+ ("lux text concat" "(| Text Int Bit)" __paragraph)
("lux text concat"
- "## Nothing.\n\n"
+ ("lux text concat" "## Nothing." __paragraph)
"(|)"))))]
#Nil)
({#Nil
@@ -1575,12 +1583,12 @@
(macro:' #export (_$ tokens)
(#Cons [(tag$ ["lux" "doc"])
(text$ ("lux text concat"
- "## Left-association for the application of binary functions over variadic arguments.\n\n"
+ ("lux text concat" "## Left-association for the application of binary functions over variadic arguments." ..new-line)
("lux text concat"
- "(_$ text/compose ''Hello, '' name ''.\\nHow are you?'')\n\n"
+ ("lux text concat" "(_$ text/compose ''Hello, '' name ''. How are you?'')" ..new-line)
("lux text concat"
- "## =>\n\n"
- "(text/compose (text/compose ''Hello, '' name) ''.\\nHow are you?'')"))))]
+ ("lux text concat" "## =>" ..new-line)
+ "(text/compose (text/compose ''Hello, '' name) ''. How are you?'')"))))]
#Nil)
({(#Cons op tokens')
({(#Cons first nexts)
@@ -1597,12 +1605,12 @@
(macro:' #export ($_ tokens)
(#Cons [(tag$ ["lux" "doc"])
(text$ ("lux text concat"
- "## Right-association for the application of binary functions over variadic arguments.\n\n"
+ ("lux text concat" "## Right-association for the application of binary functions over variadic arguments." ..new-line)
("lux text concat"
- "($_ text/compose ''Hello, '' name ''.\\nHow are you?'')\n\n"
+ ("lux text concat" "($_ text/compose ''Hello, '' name ''. How are you?'')" ..new-line)
("lux text concat"
- "## =>\n\n"
- "(text/compose ''Hello, '' (text/compose name ''.\\nHow are you?''))"))))]
+ ("lux text concat" "## =>" ..new-line)
+ "(text/compose ''Hello, '' (text/compose name ''. How are you?''))"))))]
#Nil)
({(#Cons op tokens')
({(#Cons last prevs)
@@ -1731,8 +1739,8 @@
(macro:' #export (if tokens)
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
- "Picks which expression to evaluate based on a bit test value." "\n\n"
- "(if #1 ''Oh, yeah!'' ''Aw hell naw!'')" "\n\n"
+ "Picks which expression to evaluate based on a bit test value." __paragraph
+ "(if #1 ''Oh, yeah!'' ''Aw hell naw!'')" __paragraph
"=> ''Oh, yeah!''"))])
({(#Cons test (#Cons then (#Cons else #Nil)))
(return (list (form$ (list (record$ (list [(bit$ #1) then]
@@ -1772,7 +1780,7 @@
(def:''' #export (log! message)
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
- "Logs message to standard output." "\n\n"
+ "Logs message to standard output." __paragraph
"Useful for debugging."))])
(-> Text Any)
("lux io log" message))
@@ -1979,8 +1987,8 @@
(macro:' #export (primitive tokens)
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
- "## Macro to treat define new primitive types." "\n\n"
- "(primitive ''java.lang.Object'')" "\n\n"
+ "## Macro to treat define new primitive types." __paragraph
+ "(primitive ''java.lang.Object'')" __paragraph
"(primitive ''java.util.List'' [(primitive ''java.lang.Long'')])"))])
({(#Cons [_ (#Text class-name)] #Nil)
(return (list (form$ (list (tag$ ["lux" "Primitive"]) (text$ class-name) (tag$ ["lux" "Nil"])))))
@@ -2010,8 +2018,8 @@
(macro:' #export (` tokens)
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
- "## Hygienic quasi-quotation as a macro. Unquote (~) and unquote-splice (~+) must also be used as forms." "\n\n"
- "## All unprefixed macros will receive their parent module's prefix if imported; otherwise will receive the prefix of the module on which the quasi-quote is being used." "\n\n"
+ "## Hygienic quasi-quotation as a macro. Unquote (~) and unquote-splice (~+) must also be used as forms." __paragraph
+ "## All unprefixed macros will receive their parent module's prefix if imported; otherwise will receive the prefix of the module on which the quasi-quote is being used." __paragraph
"(` (def: (~ name) (function ((~' _) (~+ args)) (~ body))))"))])
({(#Cons template #Nil)
(do Monad<Meta>
@@ -2028,7 +2036,7 @@
(macro:' #export (`' tokens)
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
- "## Unhygienic quasi-quotation as a macro. Unquote (~) and unquote-splice (~+) must also be used as forms." "\n\n"
+ "## Unhygienic quasi-quotation as a macro. Unquote (~) and unquote-splice (~+) must also be used as forms." __paragraph
"(`' (def: (~ name) (function (_ (~+ args)) (~ body))))"))])
({(#Cons template #Nil)
(do Monad<Meta>
@@ -2042,7 +2050,7 @@
(macro:' #export (' tokens)
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
- "## Quotation as a macro." "\n\n"
+ "## Quotation as a macro." __paragraph
"(' YOLO)"))])
({(#Cons template #Nil)
(do Monad<Meta>
@@ -2056,9 +2064,9 @@
(macro:' #export (|> tokens)
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
- "## Piping macro." "\n\n"
- "(|> elems (list/map int/encode) (interpose '' '') (fold text/compose ''''))" "\n\n"
- "## =>" "\n\n"
+ "## Piping macro." __paragraph
+ "(|> elems (list/map int/encode) (interpose '' '') (fold text/compose ''''))" __paragraph
+ "## =>" __paragraph
"(fold text/compose '''' (interpose '' '' (list/map int/encode elems)))"))])
({(#Cons [init apps])
(return (list (list/fold ("lux check" (-> Code Code Code)
@@ -2082,9 +2090,9 @@
(macro:' #export (<| tokens)
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
- "## Reverse piping macro." "\n\n"
- "(<| (fold text/compose '''') (interpose '' '') (list/map int/encode) elems)" "\n\n"
- "## =>" "\n\n"
+ "## Reverse piping macro." __paragraph
+ "(<| (fold text/compose '''') (interpose '' '') (list/map int/encode) elems)" __paragraph
+ "## =>" __paragraph
"(fold text/compose '''' (interpose '' '' (list/map int/encode elems)))"))])
({(#Cons [init apps])
(return (list (list/fold ("lux check" (-> Code Code Code)
@@ -2257,10 +2265,10 @@
(macro:' #export (do-template tokens)
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
- "## By specifying a pattern (with holes), and the input data to fill those holes, repeats the pattern as many times as necessary." "\n\n"
- "(do-template [<name> <diff>]" "\n"
- " " "[(def: #export <name> (-> Int Int) (i/+ <diff>))]" "\n\n"
- " " "[inc +1]" "\n"
+ "## By specifying a pattern (with holes), and the input data to fill those holes, repeats the pattern as many times as necessary." __paragraph
+ "(do-template [<name> <diff>]" ..new-line
+ " " "[(def: #export <name> (-> Int Int) (i/+ <diff>))]" __paragraph
+ " " "[inc +1]" ..new-line
" " "[dec -1]"))])
({(#Cons [[_ (#Tuple bindings)] (#Cons [[_ (#Tuple templates)] data])])
({[(#Some bindings') (#Some data')]
@@ -2608,8 +2616,8 @@
(def:''' #export (not x)
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
- "## Bit negation." "\n\n"
- "(not #1) => #0" "\n\n"
+ "## Bit negation." __paragraph
+ "(not #1) => #0" __paragraph
"(not #0) => #1"))])
(-> Bit Bit)
(if x #0 #1))
@@ -2820,7 +2828,7 @@
(macro:' #export (type tokens)
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
- "## Takes a type expression and returns it's representation as data-structure." "\n\n"
+ "## Takes a type expression and returns it's representation as data-structure." __paragraph
"(type (All [a] (Maybe (List a))))"))])
({(#Cons type #Nil)
(do Monad<Meta>
@@ -2839,7 +2847,7 @@
(macro:' #export (: tokens)
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
- "## The type-annotation macro." "\n\n"
+ "## The type-annotation macro." __paragraph
"(: (List Int) (list +1 +2 +3))"))])
({(#Cons type (#Cons value #Nil))
(return (list (` ("lux check" (type (~ type)) (~ value)))))
@@ -2851,7 +2859,7 @@
(macro:' #export (:coerce tokens)
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
- "## The type-coercion macro." "\n\n"
+ "## The type-coercion macro." __paragraph
"(:coerce Dinosaur (list +1 +2 +3))"))])
({(#Cons type (#Cons value #Nil))
(return (list (` ("lux coerce" (type (~ type)) (~ value)))))
@@ -2949,8 +2957,8 @@
(macro:' #export (Rec tokens)
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
- "## Parameter-less recursive types." "\n\n"
- "## A name has to be given to the whole type, to use it within its body." "\n\n"
+ "## Parameter-less recursive types." __paragraph
+ "## A name has to be given to the whole type, to use it within its body." __paragraph
"(Rec Self [Int (List Self)])"))])
({(#Cons [_ (#Identifier "" name)] (#Cons body #Nil))
(let' [body' (replace-syntax (list [name (` (#.Apply (~ (make-parameter 1)) (~ (make-parameter 0))))])
@@ -2964,11 +2972,11 @@
(macro:' #export (exec tokens)
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
- "## Sequential execution of expressions (great for side-effects)." "\n\n"
- "(exec" "\n"
- " " "(log! ''#1'')" "\n"
- " " "(log! ''#2'')" "\n"
- " " "(log! ''#3'')" "\n"
+ "## Sequential execution of expressions (great for side-effects)." __paragraph
+ "(exec" ..new-line
+ " " "(log! ''#1'')" ..new-line
+ " " "(log! ''#2'')" ..new-line
+ " " "(log! ''#3'')" ..new-line
"''YOLO'')"))])
({(#Cons value actions)
(let' [dummy (identifier$ ["" ""])]
@@ -3122,12 +3130,12 @@
(macro:' #export (case tokens)
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
- "## The pattern-matching macro." "\n"
- "## Allows the usage of macros within the patterns to provide custom syntax." "\n"
- "(case (: (List Int) (list +1 +2 +3))" "\n"
- " " "(#Cons x (#Cons y (#Cons z #Nil)))" "\n"
- " " "(#Some ($_ i/* x y z))" "\n\n"
- " " "_" "\n"
+ "## The pattern-matching macro." ..new-line
+ "## Allows the usage of macros within the patterns to provide custom syntax." ..new-line
+ "(case (: (List Int) (list +1 +2 +3))" ..new-line
+ " " "(#Cons x (#Cons y (#Cons z #Nil)))" ..new-line
+ " " "(#Some ($_ i/* x y z))" __paragraph
+ " " "_" ..new-line
" " "#None)"))])
({(#Cons value branches)
(do Monad<Meta>
@@ -3141,13 +3149,13 @@
(macro:' #export (^ tokens)
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
- "## Macro-expanding patterns." "\n"
- "## It's a special macro meant to be used with 'case'." "\n"
- "(case (: (List Int) (list +1 +2 +3))" "\n"
- " (^ (list x y z))" "\n"
+ "## Macro-expanding patterns." ..new-line
+ "## It's a special macro meant to be used with 'case'." ..new-line
+ "(case (: (List Int) (list +1 +2 +3))" ..new-line
+ " (^ (list x y z))" ..new-line
" (#Some ($_ i/* x y z))"
- "\n\n"
- " _" "\n"
+ __paragraph
+ " _" ..new-line
" #None)"))])
(case tokens
(#Cons [_ (#Form (#Cons pattern #Nil))] (#Cons body branches))
@@ -3166,17 +3174,17 @@
(macro:' #export (^or tokens)
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
- "## Or-patterns." "\n"
- "## It's a special macro meant to be used with 'case'." "\n"
+ "## Or-patterns." ..new-line
+ "## It's a special macro meant to be used with 'case'." ..new-line
"(type: Weekday #Monday #Tuesday #Wednesday #Thursday #Friday #Saturday #Sunday)"
- "\n\n"
- "(def: (weekend? day)" "\n"
- " (-> Weekday Bit)" "\n"
- " (case day" "\n"
- " (^or #Saturday #Sunday)" "\n"
+ __paragraph
+ "(def: (weekend? day)" ..new-line
+ " (-> Weekday Bit)" ..new-line
+ " (case day" ..new-line
+ " (^or #Saturday #Sunday)" ..new-line
" #1"
- "\n\n"
- " _" "\n"
+ __paragraph
+ " _" ..new-line
" #0))"))])
(case tokens
(^ (list& [_ (#Form patterns)] body branches))
@@ -3204,10 +3212,10 @@
(macro:' #export (let tokens)
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
- "## Creates local bindings." "\n"
- "## Can (optionally) use pattern-matching macros when binding." "\n"
- "(let [x (foo bar)" "\n"
- " y (baz quux)]" "\n"
+ "## Creates local bindings." ..new-line
+ "## Can (optionally) use pattern-matching macros when binding." ..new-line
+ "(let [x (foo bar)" ..new-line
+ " y (baz quux)]" ..new-line
" (op x y))"))])
(case tokens
(^ (list [_ (#Tuple bindings)] body))
@@ -3230,12 +3238,12 @@
(macro:' #export (function tokens)
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
- "## Syntax for creating functions." "\n"
- "## Allows for giving the function itself a name, for the sake of recursion." "\n"
- "(: (All [a b] (-> a b a))" "\n"
+ "## Syntax for creating functions." ..new-line
+ "## Allows for giving the function itself a name, for the sake of recursion." ..new-line
+ "(: (All [a b] (-> a b a))" ..new-line
" (function (_ x y) x))"
- "\n\n"
- "(: (All [a b] (-> a b a))" "\n"
+ __paragraph
+ "(: (All [a b] (-> a b a))" ..new-line
" (function (const x y) x))"))])
(case (: (Maybe [Text Code (List Code) Code])
(case tokens
@@ -3349,14 +3357,14 @@
(macro:' #export (def: tokens)
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
- "## Defines global constants/functions." "\n"
- "(def: (rejoin-pair pair)" "\n"
- " (-> [Code Code] (List Code))" "\n"
- " (let [[left right] pair]" "\n"
+ "## Defines global constants/functions." ..new-line
+ "(def: (rejoin-pair pair)" ..new-line
+ " (-> [Code Code] (List Code))" ..new-line
+ " (let [[left right] pair]" ..new-line
" (list left right)))"
- "\n\n"
- "(def: branching-exponent" "\n"
- " Int" "\n"
+ __paragraph
+ "(def: branching-exponent" ..new-line
+ " Int" ..new-line
" +5)"))])
(let [[export? tokens'] (export^ tokens)
parts (: (Maybe [Code (List Code) (Maybe Code) Code (List [Code Code])])
@@ -3434,15 +3442,15 @@
(macro:' #export (macro: tokens)
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
- "## Macro-definition macro." "\n"
- "(macro: #export (name-of tokens)" "\n"
- " (case tokens" "\n"
- " (^template [<tag>]" "\n"
- " (^ (list [_ (<tag> [prefix name])]))" "\n"
- " (return (list (` [(~ (text$ prefix)) (~ (text$ name))]))))" "\n"
+ "## Macro-definition macro." ..new-line
+ "(macro: #export (name-of tokens)" ..new-line
+ " (case tokens" ..new-line
+ " (^template [<tag>]" ..new-line
+ " (^ (list [_ (<tag> [prefix name])]))" ..new-line
+ " (return (list (` [(~ (text$ prefix)) (~ (text$ name))]))))" ..new-line
" ([#Identifier] [#Tag])"
- "\n\n"
- " _" "\n"
+ __paragraph
+ " _" ..new-line
" (fail ''Wrong syntax for name-of'')))"))])
(let [[exported? tokens] (export^ tokens)
name+args+meta+body?? (: (Maybe [Name (List Code) Code Code])
@@ -3481,17 +3489,17 @@
(macro: #export (signature: tokens)
{#.doc (text$ ($_ "lux text concat"
- "## Definition of signatures ala ML." "\n"
- "(signature: #export (Ord a)" "\n"
- " (: (Equivalence a)" "\n"
- " eq)" "\n"
- " (: (-> a a Bit)" "\n"
- " <)" "\n"
- " (: (-> a a Bit)" "\n"
- " <=)" "\n"
- " (: (-> a a Bit)" "\n"
- " >)" "\n"
- " (: (-> a a Bit)" "\n"
+ "## Definition of signatures ala ML." ..new-line
+ "(signature: #export (Ord a)" ..new-line
+ " (: (Equivalence a)" ..new-line
+ " eq)" ..new-line
+ " (: (-> a a Bit)" ..new-line
+ " <)" ..new-line
+ " (: (-> a a Bit)" ..new-line
+ " <=)" ..new-line
+ " (: (-> a a Bit)" ..new-line
+ " >)" ..new-line
+ " (: (-> a a Bit)" ..new-line
" >=))"))}
(let [[exported? tokens'] (export^ tokens)
?parts (: (Maybe [Name (List Code) Code (List Code)])
@@ -3573,8 +3581,8 @@
_
(fail <message>)))]
- [and (if (~ pre) (~ post) #0) "'and' requires >=1 clauses." "Short-circuiting 'and'.\n(and #1 #0 #1) ## => #0"]
- [or (if (~ pre) #1 (~ post)) "'or' requires >=1 clauses." "Short-circuiting 'or'.\n(or #1 #0 #1) ## => #1"])
+ [and (if (~ pre) (~ post) #0) "'and' requires >=1 clauses." "Short-circuiting 'and': (and #1 #0 #1) ## => #0"]
+ [or (if (~ pre) #1 (~ post)) "'or' requires >=1 clauses." "Short-circuiting 'or': (or #1 #0 #1) ## => #1"])
(def: (index-of part text)
(-> Text Text (Maybe Nat))
@@ -3608,18 +3616,18 @@
(def: #export (error! message)
{#.doc (text$ ($_ "lux text concat"
- "## Causes an error, with the given error message." "\n"
+ "## Causes an error, with the given error message." ..new-line
"(error! ''OH NO!'')"))}
(-> Text Nothing)
("lux io error" message))
(macro: (default tokens state)
{#.doc (text$ ($_ "lux text concat"
- "## Allows you to provide a default value that will be used" "\n"
+ "## Allows you to provide a default value that will be used" ..new-line
"## if a (Maybe x) value turns out to be #.None."
- "\n\n"
+ __paragraph
"(default +20 (#.Some +10)) ## => +10"
- "\n\n"
+ __paragraph
"(default +20 #.None) ## => +20"))}
(case tokens
(^ (list else maybe))
@@ -3894,18 +3902,18 @@
(macro: #export (structure: tokens)
{#.doc (text$ ($_ "lux text concat"
- "## Definition of structures ala ML." "\n"
- "(structure: #export Ord<Int> (Ord Int)" "\n"
- " (def: eq Equivalence<Int>)" "\n"
- " (def: (< test subject)" "\n"
- " (lux.i/< test subject))" "\n"
- " (def: (<= test subject)" "\n"
- " (or (lux.i/< test subject)" "\n"
- " (lux.i/= test subject)))" "\n"
- " (def: (> test subject)" "\n"
- " (lux.i/> test subject))" "\n"
- " (def: (>= test subject)" "\n"
- " (or (lux.i/> test subject)" "\n"
+ "## Definition of structures ala ML." ..new-line
+ "(structure: #export Ord<Int> (Ord Int)" ..new-line
+ " (def: eq Equivalence<Int>)" ..new-line
+ " (def: (< test subject)" ..new-line
+ " (lux.i/< test subject))" ..new-line
+ " (def: (<= test subject)" ..new-line
+ " (or (lux.i/< test subject)" ..new-line
+ " (lux.i/= test subject)))" ..new-line
+ " (def: (> test subject)" ..new-line
+ " (lux.i/> test subject))" ..new-line
+ " (def: (>= test subject)" ..new-line
+ " (or (lux.i/> test subject)" ..new-line
" (lux.i/= test subject))))"))}
(let [[exported? tokens'] (export^ tokens)
?parts (: (Maybe [Code (List Code) Code Code (List Code)])
@@ -3978,7 +3986,7 @@
(macro: #export (type: tokens)
{#.doc (text$ ($_ "lux text concat"
- "## The type-definition macro." "\n"
+ "## The type-definition macro." ..new-line
"(type: (List a) #Nil (#Cons a (List a)))"))}
(let [[exported? tokens'] (export^ tokens)
[rec? tokens'] (case tokens'
@@ -4211,9 +4219,9 @@
_ ($_ text/compose prefix "/" clean))]
(return output))
(fail ($_ "lux text concat"
- "Cannot climb the module hierarchy...\n"
- "Importing module: " module "\n"
- " Relative Root: " relative-root "\n"))))))
+ "Cannot climb the module hierarchy..." ..new-line
+ "Importing module: " module ..new-line
+ " Relative Root: " relative-root ..new-line))))))
(def: (parse-imports nested? relative-root imports)
(-> Bit Text (List Code) (Meta (List Importation)))
@@ -4497,10 +4505,10 @@
(macro: #export (^open tokens)
{#.doc (text$ ($_ "lux text concat"
- "## Same as the 'open' macro, but meant to be used as a pattern-matching macro for generating local bindings." "\n"
- "## Takes an 'alias' text for the generated local bindings." "\n"
- "(def: #export (range (^open ''.'') from to)" "\n"
- " (All [a] (-> (Enum a) a a (List a)))" "\n"
+ "## Same as the 'open' macro, but meant to be used as a pattern-matching macro for generating local bindings." ..new-line
+ "## Takes an 'alias' text for the generated local bindings." ..new-line
+ "(def: #export (range (^open ''.'') from to)" ..new-line
+ " (All [a] (-> (Enum a) a a (List a)))" ..new-line
" (range' <= succ from to))"))}
(case tokens
(^ (list& [_ (#Form (list [_ (#Text alias)]))] body branches))
@@ -4548,11 +4556,11 @@
(macro: #export (cond tokens)
{#.doc (text$ ($_ "lux text concat"
- "## Branching structures with multiple test conditions." "\n"
- "(cond (n/even? num) ''even''" "\n"
+ "## Branching structures with multiple test conditions." ..new-line
+ "(cond (n/even? num) ''even''" ..new-line
" (n/odd? num) ''odd''"
- "\n\n"
- " ## else-branch" "\n"
+ __paragraph
+ " ## else-branch" ..new-line
" ''???'')"))}
(if (n/= 0 (n/% 2 (list/size tokens)))
(fail "cond requires an uneven number of arguments.")
@@ -4583,14 +4591,14 @@
(macro: #export (get@ tokens)
{#.doc (text$ ($_ "lux text concat"
- "## Accesses the value of a record at a given tag." "\n"
+ "## Accesses the value of a record at a given tag." ..new-line
"(get@ #field my-record)"
- "\n\n"
- "## Can also work with multiple levels of nesting:" "\n"
+ __paragraph
+ "## Can also work with multiple levels of nesting:" ..new-line
"(get@ [#foo #bar #baz] my-record)"
- "\n\n"
- "## And, if only the slot/path is given, generates an accessor function:" "\n"
- "(let [getter (get@ [#foo #bar #baz])]" "\n"
+ __paragraph
+ "## And, if only the slot/path is given, generates an accessor function:" ..new-line
+ "(let [getter (get@ [#foo #bar #baz])]" ..new-line
" (getter my-record))"))}
(case tokens
(^ (list [_ (#Tag slot')] record))
@@ -4652,14 +4660,14 @@
(macro: #export (open: tokens)
{#.doc (text$ ($_ "lux text concat"
"## Opens a structure and generates a definition for each of its members (including nested members)."
- "\n\n"
- "## For example:" "\n"
+ __paragraph
+ "## For example:" ..new-line
"(open: ''i:.'' Number<Int>)"
- "\n\n"
- "## Will generate:" "\n"
- "(def: i:+ (:: Number<Int> +))" "\n"
- "(def: i:- (:: Number<Int> -))" "\n"
- "(def: i:* (:: Number<Int> *))" "\n"
+ __paragraph
+ "## Will generate:" ..new-line
+ "(def: i:+ (:: Number<Int> +))" ..new-line
+ "(def: i:- (:: Number<Int> -))" ..new-line
+ "(def: i:* (:: Number<Int> *))" ..new-line
"..."))}
(case tokens
(^ (list [_ (#Text alias)] struct))
@@ -4693,9 +4701,9 @@
(macro: #export (|>> tokens)
{#.doc (text$ ($_ "lux text concat"
- "## Similar to the piping macro, but rather than taking an initial object to work on, creates a function for taking it." "\n"
- "(|>> (list/map int/encode) (interpose '' '') (fold text/compose ''''))" "\n"
- "## =>" "\n"
+ "## Similar to the piping macro, but rather than taking an initial object to work on, creates a function for taking it." ..new-line
+ "(|>> (list/map int/encode) (interpose '' '') (fold text/compose ''''))" ..new-line
+ "## =>" ..new-line
"(function (_ <arg>) (fold text/compose '''' (interpose '' '' (list/map int/encode <arg>))))"))}
(do Monad<Meta>
[g!_ (gensym "_")
@@ -4704,9 +4712,9 @@
(macro: #export (<<| tokens)
{#.doc (text$ ($_ "lux text concat"
- "## Similar to the piping macro, but rather than taking an initial object to work on, creates a function for taking it." "\n"
- "(<<| (fold text/compose '''') (interpose '' '') (list/map int/encode))" "\n"
- "## =>" "\n"
+ "## Similar to the piping macro, but rather than taking an initial object to work on, creates a function for taking it." ..new-line
+ "(<<| (fold text/compose '''') (interpose '' '') (list/map int/encode))" ..new-line
+ "## =>" ..new-line
"(function (_ <arg>) (fold text/compose '''' (interpose '' '' (list/map int/encode <arg>))))"))}
(do Monad<Meta>
[g!_ (gensym "_")
@@ -4744,10 +4752,10 @@
_
(fail ($_ text/compose "Wrong syntax for refer @ " current-module
- "\n" (|> options
- (list/map code-to-text)
- (interpose " ")
- (list/fold text/compose "")))))))
+ ..new-line (|> options
+ (list/map code-to-text)
+ (interpose " ")
+ (list/fold text/compose "")))))))
(def: (write-refer module-name [r-defs r-opens])
(-> Text Refer (Meta (List Code)))
@@ -4833,20 +4841,20 @@
(macro: #export (module: tokens)
{#.doc (text$ ($_ "lux text concat"
"## Module-definition macro."
- "\n\n"
+ __paragraph
"## Can take optional annotations and allows the specification of modules to import."
- "\n\n"
- "## Example" "\n"
- "(.module: {#.doc ''Some documentation...''}" "\n"
- " [lux #*" "\n"
- " [control" "\n"
- " [''M'' monad #*]]" "\n"
- " [data" "\n"
- " maybe" "\n"
- " [''.'' name (''name/.'' Codec<Text,Name>)]]" "\n"
- " [macro" "\n"
- " code]]" "\n"
- " [//" "\n"
+ __paragraph
+ "## Example" ..new-line
+ "(.module: {#.doc ''Some documentation...''}" ..new-line
+ " [lux #*" ..new-line
+ " [control" ..new-line
+ " [''M'' monad #*]]" ..new-line
+ " [data" ..new-line
+ " maybe" ..new-line
+ " [''.'' name (''name/.'' Codec<Text,Name>)]]" ..new-line
+ " [macro" ..new-line
+ " code]]" ..new-line
+ " [//" ..new-line
" [type (''.'' Equivalence<Type>)]])"))}
(do Monad<Meta>
[#let [[_meta _imports] (: [(List [Code Code]) (List Code)]
@@ -4874,10 +4882,10 @@
(macro: #export (:: tokens)
{#.doc (text$ ($_ "lux text concat"
- "## Allows accessing the value of a structure's member." "\n"
+ "## Allows accessing the value of a structure's member." ..new-line
"(:: Codec<Text,Int> encode)"
- "\n\n"
- "## Also allows using that value as a function." "\n"
+ __paragraph
+ "## Also allows using that value as a function." ..new-line
"(:: Codec<Text,Int> encode +123)"))}
(case tokens
(^ (list struct [_ (#Identifier member)]))
@@ -4891,14 +4899,14 @@
(macro: #export (set@ tokens)
{#.doc (text$ ($_ "lux text concat"
- "## Sets the value of a record at a given tag." "\n"
+ "## Sets the value of a record at a given tag." ..new-line
"(set@ #name ''Lux'' lang)"
- "\n\n"
- "## Can also work with multiple levels of nesting:" "\n"
+ __paragraph
+ "## Can also work with multiple levels of nesting:" ..new-line
"(set@ [#foo #bar #baz] value my-record)"
- "\n\n"
- "## And, if only the slot/path and (optionally) the value are given, generates a mutator function:" "\n"
- "(let [setter (set@ [#foo #bar #baz] value)] (setter my-record))" "\n"
+ __paragraph
+ "## And, if only the slot/path and (optionally) the value are given, generates a mutator function:" ..new-line
+ "(let [setter (set@ [#foo #bar #baz] value)] (setter my-record))" ..new-line
"(let [setter (set@ [#foo #bar #baz])] (setter value my-record))"))}
(case tokens
(^ (list [_ (#Tag slot')] value record))
@@ -4978,14 +4986,14 @@
(macro: #export (update@ tokens)
{#.doc (text$ ($_ "lux text concat"
- "## Modifies the value of a record at a given tag, based on some function." "\n"
+ "## Modifies the value of a record at a given tag, based on some function." ..new-line
"(update@ #age inc person)"
- "\n\n"
- "## Can also work with multiple levels of nesting:" "\n"
+ __paragraph
+ "## Can also work with multiple levels of nesting:" ..new-line
"(update@ [#foo #bar #baz] func my-record)"
- "\n\n"
- "## And, if only the slot/path and (optionally) the value are given, generates a mutator function:" "\n"
- "(let [updater (update@ [#foo #bar #baz] func)] (updater my-record))" "\n"
+ __paragraph
+ "## And, if only the slot/path and (optionally) the value are given, generates a mutator function:" ..new-line
+ "(let [updater (update@ [#foo #bar #baz] func)] (updater my-record))" ..new-line
"(let [updater (update@ [#foo #bar #baz])] (updater func my-record))"))}
(case tokens
(^ (list [_ (#Tag slot')] fun record))
@@ -5051,38 +5059,38 @@
(macro: #export (^template tokens)
{#.doc (text$ ($_ "lux text concat"
- "## It's similar to do-template, but meant to be used during pattern-matching." "\n"
- "(def: (beta-reduce env type)" "\n"
- " (-> (List Type) Type Type)" "\n"
- " (case type" "\n"
- " (#.Primitive name params)" "\n"
+ "## It's similar to do-template, but meant to be used during pattern-matching." ..new-line
+ "(def: (beta-reduce env type)" ..new-line
+ " (-> (List Type) Type Type)" ..new-line
+ " (case type" ..new-line
+ " (#.Primitive name params)" ..new-line
" (#.Primitive name (list/map (beta-reduce env) params))"
- "\n\n"
- " (^template [<tag>]" "\n"
- " (<tag> left right)" "\n"
- " (<tag> (beta-reduce env left) (beta-reduce env right)))" "\n"
+ __paragraph
+ " (^template [<tag>]" ..new-line
+ " (<tag> left right)" ..new-line
+ " (<tag> (beta-reduce env left) (beta-reduce env right)))" ..new-line
" ([#.Sum] [#.Product])"
- "\n\n"
- " (^template [<tag>]" "\n"
- " (<tag> left right)" "\n"
- " (<tag> (beta-reduce env left) (beta-reduce env right)))" "\n"
+ __paragraph
+ " (^template [<tag>]" ..new-line
+ " (<tag> left right)" ..new-line
+ " (<tag> (beta-reduce env left) (beta-reduce env right)))" ..new-line
" ([#.Function] [#.Apply])"
- "\n\n"
- " (^template [<tag>]" "\n"
- " (<tag> old-env def)" "\n"
- " (case old-env" "\n"
- " #.Nil" "\n"
+ __paragraph
+ " (^template [<tag>]" ..new-line
+ " (<tag> old-env def)" ..new-line
+ " (case old-env" ..new-line
+ " #.Nil" ..new-line
" (<tag> env def)"
- "\n\n"
- " _" "\n"
- " type))" "\n"
+ __paragraph
+ " _" ..new-line
+ " type))" ..new-line
" ([#.UnivQ] [#.ExQ])"
- "\n\n"
- " (#.Parameter idx)" "\n"
+ __paragraph
+ " (#.Parameter idx)" ..new-line
" (default type (list.nth idx env))"
- "\n\n"
- " _" "\n"
- " type" "\n"
+ __paragraph
+ " _" ..new-line
+ " type" ..new-line
" ))"))}
(case tokens
(^ (list& [_ (#Form (list& [_ (#Tuple bindings)] templates))]
@@ -5196,7 +5204,7 @@
(-> Nat Cursor Cursor Text)
(if (n/= old-line new-line)
(text/join (repeat (.int (n/- old-column new-column)) " "))
- (let [extra-lines (text/join (repeat (.int (n/- old-line new-line)) "\n"))
+ (let [extra-lines (text/join (repeat (.int (n/- old-line new-line)) ..new-line))
space-padding (text/join (repeat (.int (n/- baseline new-column)) " "))]
(text/compose extra-lines space-padding))))
@@ -5262,27 +5270,27 @@
(case fragment
(#Doc-Comment comment)
(|> comment
- (text/split "\n")
- (list/map (function (_ line) ($_ text/compose "## " line "\n")))
+ (text/split ..new-line)
+ (list/map (function (_ line) ($_ text/compose "## " line ..new-line)))
text/join)
(#Doc-Example example)
(let [baseline (find-baseline-column example)
[cursor _] example
[_ text] (doc-example->Text (with-baseline baseline cursor) baseline example)]
- (text/compose text "\n\n"))))
+ (text/compose text __paragraph))))
(macro: #export (doc tokens)
{#.doc (text$ ($_ "lux text concat"
"## Creates code documentation, embedding text as comments and properly formatting the forms it's being given."
- "\n\n"
- "## For Example:" "\n"
- "(doc ''Allows arbitrary looping, using the \\''recur\\'' form to re-start the loop.''" "\n"
- " ''Can be used in monadic code to create monadic loops.''" "\n"
- " (loop [count +0" "\n"
- " x init]" "\n"
- " (if (< +10 count)" "\n"
- " (recur (inc count) (f x))" "\n"
+ __paragraph
+ "## For Example:" ..new-line
+ "(doc ''Allows arbitrary looping, using the \\''recur\\'' form to re-start the loop.''" ..new-line
+ " ''Can be used in monadic code to create monadic loops.''" ..new-line
+ " (loop [count +0" ..new-line
+ " x init]" ..new-line
+ " (if (< +10 count)" ..new-line
+ " (recur (inc count) (f x))" ..new-line
" x)))"))}
(return (list (` [(~ cursor-code)
(#.Text (~ (|> tokens
@@ -5489,7 +5497,7 @@
[(bit #0) "#0" [_ (#.Bit #0)]]
[(int +123) "+123" [_ (#.Int +123)]]
[(frac +123.0) "+123.0" [_ (#.Frac +123.0)]]
- [(text "\n") "'\\n'" [_ (#.Text "\n")]]
+ [(text "123") "'123'" [_ (#.Text "123")]]
[(tag ["yolo" "lol"]) "#yolo.lol" [_ (#.Tag ["yolo" "lol"])]]
[(identifier ["yolo" "lol"]) "yolo.lol" [_ (#.Identifier ["yolo" "lol"])]]
[(form (list (bit #1) (int +123))) "(#1 +123)" (^ [_ (#.Form (list [_ (#.Bit #1)] [_ (#.Int +123)]))])]
diff --git a/stdlib/source/lux/compiler/default/phase/analysis.lux b/stdlib/source/lux/compiler/default/phase/analysis.lux
index e26cd3516..615075800 100644
--- a/stdlib/source/lux/compiler/default/phase/analysis.lux
+++ b/stdlib/source/lux/compiler/default/phase/analysis.lux
@@ -236,7 +236,7 @@
output])
(#error.Error error)
- (#error.Error (format "@ " (%cursor cursor) "\n"
+ (#error.Error (format "@ " (%cursor cursor) text.new-line
error)))))))
(do-template [<name> <type> <field> <value>]
diff --git a/stdlib/source/lux/compiler/default/phase/analysis/expression.lux b/stdlib/source/lux/compiler/default/phase/analysis/expression.lux
index 073cc9950..317f86a6f 100644
--- a/stdlib/source/lux/compiler/default/phase/analysis/expression.lux
+++ b/stdlib/source/lux/compiler/default/phase/analysis/expression.lux
@@ -26,14 +26,14 @@
(exception: #export (macro-expansion-failed {macro Name} {inputs (List Code)} {error Text})
(ex.report ["Macro" (%name macro)]
["Inputs" (|> inputs
- (list/map (|>> %code (format "\n" text.tab)))
+ (list/map (|>> %code (format text.new-line text.tab)))
(text.join-with ""))]
["Error" error]))
(exception: #export (macro-call-must-have-single-expansion {macro Name} {inputs (List Code)})
(ex.report ["Macro" (%name macro)]
["Inputs" (|> inputs
- (list/map (|>> %code (format "\n" text.tab)))
+ (list/map (|>> %code (format text.new-line text.tab)))
(text.join-with ""))]))
(exception: #export (unrecognized-syntax {code Code})
diff --git a/stdlib/source/lux/compiler/default/phase/analysis/function.lux b/stdlib/source/lux/compiler/default/phase/analysis/function.lux
index 1f0e4c8f9..a996457d9 100644
--- a/stdlib/source/lux/compiler/default/phase/analysis/function.lux
+++ b/stdlib/source/lux/compiler/default/phase/analysis/function.lux
@@ -30,7 +30,7 @@
["Arguments" (|> arguments
list.enumerate
(list/map (.function (_ [idx argC])
- (format "\n " (%n idx) " " (%code argC))))
+ (format text.new-line " " (%n idx) " " (%code argC))))
(text.join-with ""))]))
(def: #export (function analyse function-name arg-name body)
diff --git a/stdlib/source/lux/compiler/default/phase/analysis/inference.lux b/stdlib/source/lux/compiler/default/phase/analysis/inference.lux
index c96d0457c..010bdc437 100644
--- a/stdlib/source/lux/compiler/default/phase/analysis/inference.lux
+++ b/stdlib/source/lux/compiler/default/phase/analysis/inference.lux
@@ -27,7 +27,7 @@
["Arguments" (|> args
list.enumerate
(list/map (function (_ [idx argC])
- (format "\n " (%n idx) " " (%code argC))))
+ (format text.new-line " " (%n idx) " " (%code argC))))
(text.join-with ""))]))
(exception: #export (cannot-infer-argument {inferred Type} {argument Code})
diff --git a/stdlib/source/lux/compiler/default/phase/extension.lux b/stdlib/source/lux/compiler/default/phase/extension.lux
index c7a2048a8..c87d8d54c 100644
--- a/stdlib/source/lux/compiler/default/phase/extension.lux
+++ b/stdlib/source/lux/compiler/default/phase/extension.lux
@@ -49,7 +49,7 @@
["Available" (|> bundle
dictionary.keys
(list.sort text/<)
- (list/map (|>> %t (format "\n" text.tab)))
+ (list/map (|>> %t (format text.new-line text.tab)))
(text.join-with ""))]))
(exception: #export (incorrect-arity {name Text} {arity Nat} {args Nat})
diff --git a/stdlib/source/lux/compiler/default/phase/extension/analysis/host.jvm.lux b/stdlib/source/lux/compiler/default/phase/extension/analysis/host.jvm.lux
index 31f4b33ff..64edb791b 100644
--- a/stdlib/source/lux/compiler/default/phase/extension/analysis/host.jvm.lux
+++ b/stdlib/source/lux/compiler/default/phase/extension/analysis/host.jvm.lux
@@ -95,7 +95,7 @@
(ex.report ["Class" class]
["Method" method]
["Hints" (|> hints
- (list/map (|>> product.left %type (format "\n" text.tab)))
+ (list/map (|>> product.left %type (format text.new-line text.tab)))
(text.join-with ""))]))]
[no-candidates]
@@ -643,14 +643,14 @@
num-type-params (list.size params)]
(cond (not (text/= class-name name))
(////.throw cannot-correspond-type-with-a-class
- (format "Class = " class-name "\n"
+ (format "Class = " class-name text.new-line
"Type = " (%type type)))
(not (n/= num-class-params num-type-params))
(////.throw type-parameter-mismatch
- (format "Expected: " (%i (.int num-class-params)) "\n"
- " Actual: " (%i (.int num-type-params)) "\n"
- " Class: " class-name "\n"
+ (format "Expected: " (%i (.int num-class-params)) text.new-line
+ " Actual: " (%i (.int num-type-params)) text.new-line
+ " Class: " class-name text.new-line
" Type: " (%type type)))
## else
@@ -704,9 +704,9 @@
(wrap #1))
(do @
[current-class (load-class current-name)
- _ (////.assert cannot-cast (format "From class/primitive: " current-name "\n"
- " To class/primitive: " to-name "\n"
- " For value: " (%code valueC) "\n")
+ _ (////.assert cannot-cast (format "From class/primitive: " current-name text.new-line
+ " To class/primitive: " to-name text.new-line
+ " For value: " (%code valueC) text.new-line)
(Class::isAssignableFrom [current-class] to-class))
candiate-parents (monad.map @
(function (_ java-type)
@@ -726,17 +726,17 @@
(recur [next-name nextT]))
#.Nil
- (////.throw cannot-cast (format "From class/primitive: " from-name "\n"
- " To class/primitive: " to-name "\n"
- " For value: " (%code valueC) "\n")))
+ (////.throw cannot-cast (format "From class/primitive: " from-name text.new-line
+ " To class/primitive: " to-name text.new-line
+ " For value: " (%code valueC) text.new-line)))
))))))]
(if can-cast?
(wrap (#analysis.Extension extension-name (list (analysis.text from-name)
(analysis.text to-name)
valueA)))
- (////.throw cannot-cast (format "From class/primitive: " from-name "\n"
- " To class/primitive: " to-name "\n"
- " For value: " (%code valueC) "\n"))))
+ (////.throw cannot-cast (format "From class/primitive: " from-name text.new-line
+ " To class/primitive: " to-name text.new-line
+ " For value: " (%code valueC) text.new-line))))
_
(////.throw ///.invalid-syntax extension-name))))
@@ -764,9 +764,9 @@
(if (is? owner class)
(wrap [class field])
(////.throw mistaken-field-owner
- (format " Field: " field-name "\n"
- " Owner Class: " (Class::getName [] owner) "\n"
- "Target Class: " class-name "\n"))))
+ (format " Field: " field-name text.new-line
+ " Owner Class: " (Class::getName [] owner) text.new-line
+ "Target Class: " class-name text.new-line))))
(#e.Error _)
(////.throw unknown-field (format class-name "#" field-name)))))
@@ -802,9 +802,9 @@
[#let [num-params (list.size _class-params)
num-vars (list.size var-names)]
_ (////.assert type-parameter-mismatch
- (format "Expected: " (%i (.int num-params)) "\n"
- " Actual: " (%i (.int num-vars)) "\n"
- " Class: " _class-name "\n"
+ (format "Expected: " (%i (.int num-params)) text.new-line
+ " Actual: " (%i (.int num-vars)) text.new-line
+ " Class: " _class-name text.new-line
" Type: " (%type objectT))
(n/= num-params num-vars))]
(wrap (|> (list.zip2 var-names _class-params)
diff --git a/stdlib/source/lux/compiler/default/syntax.lux b/stdlib/source/lux/compiler/default/syntax.lux
index faa072d88..92f223940 100644
--- a/stdlib/source/lux/compiler/default/syntax.lux
+++ b/stdlib/source/lux/compiler/default/syntax.lux
@@ -59,7 +59,6 @@
(def: digits+ (format "_" ..digits))
(def: white-space " ")
-(def: new-line "\n")
## (def: new-line^ (l.this new-line))
(def: #export text-delimiter text.double-quote)
@@ -128,7 +127,7 @@
## (:: p.Monad<Parser> wrap where)))
## Escaped character sequences follow the usual syntax of
-## back-slash followed by a letter (e.g. \n).
+## back-slash followed by a letter.
## Escaped characters may show up in Char and Text literals.
(def: escaped-char^
(Lexer [Nat Text])
@@ -137,7 +136,6 @@
[code l.any]
(case code
## Handle special cases.
- "n" (wrap [2 ..new-line])
(^ (static ..escape)) (wrap [2 ..escape])
_
@@ -255,7 +253,7 @@
## ($_ p.either
## ## Normal text characters.
## (do @
-## [normal (l.slice (l.many! (l.none-of! (format ..escape ..text-delimiter ..new-line))))]
+## [normal (l.slice (l.many! (l.none-of! (format ..escape ..text-delimiter text.new-line))))]
## (recur (format text-read normal)
## (update@ #.column (n/+ (text.size normal)) where)
## #0))
@@ -373,7 +371,7 @@
## ..sigil
## ..text-delimiter
## ..name-separator)
-## space (format ..white-space ..new-line)
+## space (format ..white-space text.new-line)
## head (l.none-of! (format ..digits delimiters space))
## tail (l.some! (l.none-of! (format delimiters space)))]
## (l.slice (l.and! head tail))))
@@ -585,7 +583,7 @@
(#error.Success [("lux text size" source-code) (!inc end) <finish-text>])))))
(template: (!guarantee-no-new-lines content body)
- (case ("lux text index" content (static ..new-line) 0)
+ (case ("lux text index" content (static text.new-line) 0)
(#.Some g!_)
(ex.throw ..text-cannot-contain-new-lines content)
@@ -604,8 +602,7 @@
(^template [<input> <output>]
(^ (char <input>))
(!find-next-escape 2 next-escape end source-code total <output>))
- (["n" (static ..new-line)]
- [(~~ (static ..escape)) (static ..escape)])
+ ([(~~ (static ..escape)) (static ..escape)])
_
(ex.throw invalid-escape-syntax []))))))
@@ -666,7 +663,7 @@
(`` (template: (!strict-name-char? char)
(not (or ("lux i64 =" (.char (~~ (static ..white-space))) char)
- ("lux i64 =" (.char (~~ (static ..new-line))) char)
+ ("lux i64 =" (.char (~~ (static text.new-line))) char)
("lux i64 =" (.char (~~ (static ..name-separator))) char)
@@ -836,7 +833,7 @@
([(~~ (static ..white-space)) #.column]
[(~~ (static text.carriage-return)) #.column])
- (^ (char (~~ (static ..new-line))))
+ (^ (char (~~ (static text.new-line))))
(recur tracker [(!new-line where) (!inc offset) source-code])
## Form
@@ -868,7 +865,7 @@
## Single-line comment
(^ (char (~~ (static ..sigil))))
- (case ("lux text index" source-code (static ..new-line) offset')
+ (case ("lux text index" source-code (static text.new-line) offset')
(#.Some end)
(recur tracker [(!new-line where) (!inc end) source-code])
diff --git a/stdlib/source/lux/control/concatenative.lux b/stdlib/source/lux/control/concatenative.lux
index 0011c8956..80fa1b40e 100644
--- a/stdlib/source/lux/control/concatenative.lux
+++ b/stdlib/source/lux/control/concatenative.lux
@@ -63,7 +63,7 @@
(wrap singleton)
_
- (macro.fail (format "Cannot expand to more than a single AST/Code node:\n"
+ (macro.fail (format "Cannot expand to more than a single AST/Code node:" text.new-line
(|> expansion (list/map %code) (text.join-with " ")))))))
(syntax: #export (=> {aliases aliases^}
diff --git a/stdlib/source/lux/control/exception.lux b/stdlib/source/lux/control/exception.lux
index 085269e54..a906c97aa 100644
--- a/stdlib/source/lux/control/exception.lux
+++ b/stdlib/source/lux/control/exception.lux
@@ -98,7 +98,7 @@
(macro.with-gensyms [g!descriptor]
(do @
[current-module macro.current-module-name
- #let [descriptor ($_ text/compose "{" current-module "." name "}" "\n")
+ #let [descriptor ($_ text/compose "{" current-module "." name "}" text.new-line)
g!self (code.local-identifier name)]]
(wrap (list (` (def: (~+ (csw.export export))
(~ g!self)
@@ -122,7 +122,7 @@
(list.repeat (n/- (text.size header)
largest-header-size))
(text.join-with ""))]
- ($_ text/compose padding header ": " message "\n"))))
+ ($_ text/compose padding header ": " message text.new-line))))
(text.join-with ""))))
(syntax: #export (report {entries (p.many (s.tuple (p.and s.any s.any)))})
@@ -132,9 +132,9 @@
(def: separator
($_ "lux text concat"
- "\n\n"
+ text.new-line text.new-line
"-----------------------------------------"
- "\n\n"))
+ text.new-line text.new-line))
(def: #export (with-stack exception message computation)
(All [e a] (-> (Exception e) e (Error a) (Error a)))
diff --git a/stdlib/source/lux/control/region.lux b/stdlib/source/lux/control/region.lux
index 7bd43bd09..cfd074f6b 100644
--- a/stdlib/source/lux/control/region.lux
+++ b/stdlib/source/lux/control/region.lux
@@ -7,7 +7,7 @@
["ex" exception (#+ Exception exception:)]]
[data
["e" error (#+ Error)]
- [text
+ ["." text
format]
[collection
[list ("list/." Fold<List>)]]]])
@@ -22,11 +22,11 @@
(def: separator
Text
- (format "\n"
- "-----------------------------------------\n"
- "-----------------------------------------\n"
- "-----------------------------------------\n"
- "\n"))
+ (format text.new-line
+ "-----------------------------------------" text.new-line
+ "-----------------------------------------" text.new-line
+ "-----------------------------------------" text.new-line
+ text.new-line))
(exception: #export [a] (clean-up-error {error Text}
{output (Error a)})
diff --git a/stdlib/source/lux/data/format/css.lux b/stdlib/source/lux/data/format/css.lux
index 083195972..fbdad1885 100644
--- a/stdlib/source/lux/data/format/css.lux
+++ b/stdlib/source/lux/data/format/css.lux
@@ -37,7 +37,7 @@
(if (list.empty? style)
""
(format selector "{" (inline style) "}"))))
- (text.join-with "\n")))
+ (text.join-with text.new-line)))
(def: #export (rgb color)
(-> Color Value)
diff --git a/stdlib/source/lux/data/format/xml.lux b/stdlib/source/lux/data/format/xml.lux
index a5cb39ab5..0ed744b46 100644
--- a/stdlib/source/lux/data/format/xml.lux
+++ b/stdlib/source/lux/data/format/xml.lux
@@ -110,9 +110,9 @@
spaced^
(p.after (l.this "/"))
(l.enclosed ["<" ">"]))]
- (p.assert ($_ text/compose "Close tag does not match open tag.\n"
- "Expected: " (name/encode expected) "\n"
- " Actual: " (name/encode actual) "\n")
+ (p.assert ($_ text/compose "Close tag does not match open tag." text.new-line
+ "Expected: " (name/encode expected) text.new-line
+ " Actual: " (name/encode actual) text.new-line)
(name/= expected actual))))
(def: comment^
@@ -254,10 +254,12 @@
(exception: #export (wrong-tag {tag Name})
(name/encode tag))
+(def: blank-line ($_ text/compose text.new-line text.new-line))
+
(exception: #export (unconsumed-inputs {inputs (List XML)})
(|> inputs
(list/map (:: Codec<Text,XML> encode))
- (text.join-with "\n\n")))
+ (text.join-with blank-line)))
(def: #export text
(Reader Text)
diff --git a/stdlib/source/lux/data/number.lux b/stdlib/source/lux/data/number.lux
index df3e2d353..e45c4ff1c 100644
--- a/stdlib/source/lux/data/number.lux
+++ b/stdlib/source/lux/data/number.lux
@@ -674,9 +674,7 @@
encoding
" number, generates a Nat, an Int, a Rev or a Frac.")
underscore "Allows for the presence of underscore in the numbers."
- description [cursor (#.Text ($_ "lux text concat"
- encoding "\n"
- underscore))]]
+ description [cursor (#.Text ($_ "lux text concat" encoding " " underscore))]]
(#error.Success [state (list (` (doc (~ description)
(~ example-1)
(~ example-2))))]))
diff --git a/stdlib/source/lux/data/text.lux b/stdlib/source/lux/data/text.lux
index 0c6a5ea45..3807275c1 100644
--- a/stdlib/source/lux/data/text.lux
+++ b/stdlib/source/lux/data/text.lux
@@ -16,6 +16,22 @@
[compiler
["." host]]])
+(def: #export from-code
+ (-> Nat Text)
+ (|>> (:coerce Int) "lux int char"))
+
+(do-template [<name> <code>]
+ [(def: #export <name> (from-code <code>))]
+
+ [back-space 8]
+ [tab 9]
+ [new-line 10]
+ [vertical-tab 11]
+ [form-feed 12]
+ [carriage-return 13]
+ [double-quote 34]
+ )
+
(def: #export (size x)
(-> Text Nat)
("lux text size" x))
@@ -122,7 +138,7 @@
(#.Cons sample #.Nil)))
(def: #export split-lines
- (..split-all-with "\n"))
+ (..split-all-with ..new-line))
(def: #export (replace-once pattern value template)
(-> Text Text Text Text)
@@ -216,22 +232,6 @@
(-> Text Text Text)
(enclose [boundary boundary] content))
-(def: #export from-code
- (-> Nat Text)
- (|>> (:coerce Int) "lux int char"))
-
-(do-template [<name> <code>]
- [(def: #export <name> (from-code <code>))]
-
- [back-space 8]
- [tab 9]
- [new-line 10]
- [vertical-tab 11]
- [form-feed 12]
- [carriage-return 13]
- [double-quote 34]
- )
-
(def: #export encode
(-> Text Text)
(..enclose' ..double-quote))
diff --git a/stdlib/source/lux/data/text/regex.lux b/stdlib/source/lux/data/text/regex.lux
index bb2c570e3..ec11c9259 100644
--- a/stdlib/source/lux/data/text/regex.lux
+++ b/stdlib/source/lux/data/text/regex.lux
@@ -465,7 +465,7 @@
(p.before l.end)
(l.run pattern))
(#e.Error error)
- (macro.fail (format "Error while parsing regular-expression:\n"
+ (macro.fail (format "Error while parsing regular-expression:" //.new-line
error))
(#e.Success regex)
diff --git a/stdlib/source/lux/interpreter.lux b/stdlib/source/lux/interpreter.lux
index 6837f24d9..75389db21 100644
--- a/stdlib/source/lux/interpreter.lux
+++ b/stdlib/source/lux/interpreter.lux
@@ -5,7 +5,7 @@
["ex" exception (#+ exception:)]]
[data
["." error (#+ Error)]
- [text ("text/." Equivalence<Text>)
+ ["." text ("text/." Equivalence<Text>)
format]]
[type (#+ :share)
["." check]]
@@ -36,16 +36,16 @@
(def: (add-line line [where offset input])
(-> Text Source Source)
- [where offset (format input "\n" line)])
+ [where offset (format input text.new-line line)])
(def: exit-command Text "exit")
(def: welcome-message
Text
- (format "\n"
- "Welcome to the interpreter!" "\n"
- "Type 'exit' to leave." "\n"
- "\n"))
+ (format text.new-line
+ "Welcome to the interpreter!" text.new-line
+ "Type 'exit' to leave." text.new-line
+ text.new-line))
(def: farewell-message
Text
diff --git a/stdlib/source/lux/io.lux b/stdlib/source/lux/io.lux
index 96503f10e..c054c5347 100644
--- a/stdlib/source/lux/io.lux
+++ b/stdlib/source/lux/io.lux
@@ -6,9 +6,7 @@
[monad (#+ do Monad)]
["ex" exception (#+ Exception)]]
[data
- ["." error (#+ Error)]
- [collection
- [list]]]])
+ ["." error (#+ Error)]]])
(type: #export (IO a)
{#.doc "A type that represents synchronous, effectful computations that may interact with the outside world."}
diff --git a/stdlib/source/lux/macro.lux b/stdlib/source/lux/macro.lux
index 10b5d3b41..5d5c8f0cf 100644
--- a/stdlib/source/lux/macro.lux
+++ b/stdlib/source/lux/macro.lux
@@ -507,17 +507,17 @@
_
(let [current-module (|> compiler (get@ #.current-module) (maybe.default "???"))]
(#e.Error ($_ text/compose
- "Unknown definition: " (name/encode name) "\n"
- " Current module: " current-module "\n"
+ "Unknown definition: " (name/encode name) text.new-line
+ " Current module: " current-module text.new-line
(case (get current-module (get@ #.modules compiler))
(#.Some this-module)
($_ text/compose
- " Imports: " (|> this-module (get@ #.imports) (text.join-with ", ")) "\n"
- " Aliases: " (|> this-module (get@ #.module-aliases) (list/map (function (_ [alias real]) ($_ text/compose alias " => " real))) (text.join-with ", ")) "\n")
+ " Imports: " (|> this-module (get@ #.imports) (text.join-with ", ")) text.new-line
+ " Aliases: " (|> this-module (get@ #.module-aliases) (list/map (function (_ [alias real]) ($_ text/compose alias " => " real))) (text.join-with ", ")) text.new-line)
_
"")
- " All Known modules: " (|> compiler (get@ #.modules) (list/map product.left) (text.join-with ", ")) "\n")))))))
+ " All Known modules: " (|> compiler (get@ #.modules) (list/map product.left) (text.join-with ", ")) text.new-line)))))))
(def: #export (find-def-type name)
{#.doc "Looks-up a definition's type in the available modules (including the current one)."}
diff --git a/stdlib/source/lux/macro/poly.lux b/stdlib/source/lux/macro/poly.lux
index 7b3bc49a2..51f7a4885 100644
--- a/stdlib/source/lux/macro/poly.lux
+++ b/stdlib/source/lux/macro/poly.lux
@@ -56,7 +56,7 @@
(exception: #export (unconsumed {remaining (List Type)})
(ex.report ["Types" (|> remaining
- (list/map (|>> %type (format "\n* ")))
+ (list/map (|>> %type (format text.new-line "* ")))
(text.join-with ""))]))
(type: #export Env (Dictionary Nat [Type Code]))
diff --git a/stdlib/source/lux/macro/syntax.lux b/stdlib/source/lux/macro/syntax.lux
index 74901beb9..83137cef0 100644
--- a/stdlib/source/lux/macro/syntax.lux
+++ b/stdlib/source/lux/macro/syntax.lux
@@ -31,7 +31,7 @@
## [Utils]
(def: (remaining-inputs asts)
(-> (List Code) Text)
- ($_ text/compose "\nRemaining input: "
+ ($_ text/compose text.new-line "Remaining input: "
(|> asts (list/map code.to-text) (list.interpose " ") (text.join-with ""))))
## [Syntaxs]
diff --git a/stdlib/source/lux/math/modular.lux b/stdlib/source/lux/math/modular.lux
index 883febecb..ac141a3c9 100644
--- a/stdlib/source/lux/math/modular.lux
+++ b/stdlib/source/lux/math/modular.lux
@@ -37,15 +37,13 @@
(exception: #export [m] (incorrect-modulus {modulus (Modulus m)}
{parsed Int})
- ($_ text/compose
- "Expected: " (int/encode (to-int modulus)) "\n"
- " Actual: " (int/encode parsed) "\n"))
+ (ex.report ["Expected" (int/encode (to-int modulus))]
+ ["Actual" (int/encode parsed)]))
(exception: #export [rm sm] (cannot-equalize-moduli {reference (Modulus rm)}
{sample (Modulus sm)})
- ($_ text/compose
- "Reference: " (int/encode (to-int reference)) "\n"
- " Sample: " (int/encode (to-int sample)) "\n"))
+ (ex.report ["Reference" (int/encode (to-int reference))]
+ ["Sample" (int/encode (to-int sample))]))
(def: #export (congruent? modulus reference sample)
(All [m] (-> (Modulus m) Int Int Bit))
diff --git a/stdlib/source/lux/test.lux b/stdlib/source/lux/test.lux
index 5b214579d..b928b1860 100644
--- a/stdlib/source/lux/test.lux
+++ b/stdlib/source/lux/test.lux
@@ -79,9 +79,9 @@
#let [post (io.run instant.now)
_ (log! (format "@ " module " "
"(" (%duration (instant.span pre post)) ")"
- "\n"
- description "\n"
- "\n" documentation "\n"))]]
+ text.new-line
+ description text.new-line
+ text.new-line documentation text.new-line))]]
(wrap counters)))))
(monad.seq @))]
(wrap (list/fold add-counters start test-runs))))
@@ -99,7 +99,7 @@
(def: (times-failure seed documentation)
(-> (I64 Any) Text Text)
- (format "Failed with this seed: " (%n (.nat seed)) "\n"
+ (format "Failed with this seed: " (%n (.nat seed)) text.new-line
documentation))
(def: #export (times amount test)
@@ -217,9 +217,9 @@
(def: (success-message successes failures)
(-> Nat Nat Text)
- (format "Test-suite finished." "\n"
- (%n successes) " out of " (%n (n/+ failures successes)) " tests passed." "\n"
- (%n failures) " tests failed." "\n"))
+ (format "Test-suite finished." text.new-line
+ (%n successes) " out of " (%n (n/+ failures successes)) " tests passed." text.new-line
+ (%n failures) " tests failed." text.new-line))
(syntax: #export (run)
{#.doc (doc "Runs all the tests defined on the current module, and in all imported modules."
@@ -264,4 +264,4 @@
[[l-counter l-documentation] left
[r-counter r-documentation] right]
(wrap [(add-counters l-counter r-counter)
- (format l-documentation "\n" r-documentation)])))))
+ (format l-documentation text.new-line r-documentation)])))))
diff --git a/stdlib/source/lux/type.lux b/stdlib/source/lux/type.lux
index be3b54eed..ff614a328 100644
--- a/stdlib/source/lux/type.lux
+++ b/stdlib/source/lux/type.lux
@@ -345,8 +345,8 @@
[cursor macro.cursor
valueT (macro.find-type valueN)
#let [_ (log! ($_ text/compose
- ":log!" " @ " (.cursor-description cursor) "\n"
- (name/encode valueN) " : " (..to-text valueT) "\n"))]]
+ ":log!" " @ " (.cursor-description cursor) text.new-line
+ (name/encode valueN) " : " (..to-text valueT) text.new-line))]]
(wrap (list (' []))))
(#.Right valueC)
diff --git a/stdlib/source/lux/type/check.lux b/stdlib/source/lux/type/check.lux
index ce5ce652a..97ccc0626 100644
--- a/stdlib/source/lux/type/check.lux
+++ b/stdlib/source/lux/type/check.lux
@@ -10,7 +10,7 @@
["." product]
["." error (#+ Error)]
["." number ("nat/." Codec<Text,Nat>)]
- [text ("text/." Monoid<Text> Equivalence<Text>)]
+ ["." text ("text/." Monoid<Text> Equivalence<Text>)]
[collection
["." list]
["." set (#+ Set)]]]]
@@ -460,7 +460,9 @@
_
($_ text/compose
(on-error [])
- "\n\n-----------------------------------------\n\n"
+ text.new-line text.new-line
+ "-----------------------------------------"
+ text.new-line text.new-line
error)))
output
diff --git a/stdlib/test/test/lux/compiler/default/syntax.lux b/stdlib/test/test/lux/compiler/default/syntax.lux
index e24779057..829199aa8 100644
--- a/stdlib/test/test/lux/compiler/default/syntax.lux
+++ b/stdlib/test/test/lux/compiler/default/syntax.lux
@@ -30,7 +30,7 @@
(do r.Monad<Random>
[#let [digits "0123456789"
delimiters (format "()[]{}#." &.text-delimiter)
- space " \n"
+ space (format " " text.new-line)
invalid-range (format digits delimiters space)
char-gen (|> r.nat
(:: @ map (|>> (n/% 256) (n/max 1)))
@@ -114,7 +114,7 @@
(def: comment-text^
(r.Random Text)
- (let [char-gen (|> r.nat (r.filter (|>> (n/= (char "\n")) not)))]
+ (let [char-gen (|> r.nat (r.filter (|>> (n/= (`` (char (~~ (static text.new-line))))) not)))]
(do r.Monad<Random>
[size (|> r.nat (r/map (n/% 20)))]
(r.text char-gen size))))
@@ -123,7 +123,7 @@
(r.Random Text)
(do r.Monad<Random>
[comment comment-text^]
- (wrap (format "## " comment "\n"))))
+ (wrap (format "## " comment text.new-line))))
(context: "Multi-line text & comments."
(<| (seed 12137892244981970631)
diff --git a/stdlib/test/test/lux/macro/syntax.lux b/stdlib/test/test/lux/macro/syntax.lux
index b1e2f445b..0bf7b8804 100644
--- a/stdlib/test/test/lux/macro/syntax.lux
+++ b/stdlib/test/test/lux/macro/syntax.lux
@@ -75,9 +75,9 @@
["Can parse Bit syntax." #1 code.bit bit.Equivalence<Bit> s.bit]
["Can parse Nat syntax." 123 code.nat number.Equivalence<Nat> s.nat]
["Can parse Int syntax." +123 code.int number.Equivalence<Int> s.int]
- ["Can parse Rev syntax." .123 code.rev number.Equivalence<Rev> s.rev]
+ ["Can parse Rev syntax." .123 code.rev number.Equivalence<Rev> s.rev]
["Can parse Frac syntax." +123.0 code.frac number.Equivalence<Frac> s.frac]
- ["Can parse Text syntax." "\n" code.text text.Equivalence<Text> s.text]
+ ["Can parse Text syntax." text.new-line code.text text.Equivalence<Text> s.text]
["Can parse Identifier syntax." ["yolo" "lol"] code.identifier name.Equivalence<Name> s.identifier]
["Can parse Tag syntax." ["yolo" "lol"] code.tag name.Equivalence<Name> s.tag]
)]