aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux.lux
diff options
context:
space:
mode:
authorEduardo Julian2018-08-23 00:03:26 -0400
committerEduardo Julian2018-08-23 00:03:26 -0400
commita89088576c4e586d3dad18f82eb451ff4eaa14fb (patch)
tree82bba48250a84f0ca4054e2c9a5699a851393915 /stdlib/source/lux.lux
parent324665cef68fa326d358733d36ed20feba5dbbd6 (diff)
No more escaping of double-quotes.
Diffstat (limited to 'stdlib/source/lux.lux')
-rw-r--r--stdlib/source/lux.lux127
1 files changed, 66 insertions, 61 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux
index 5ffe8d939..5e14a9806 100644
--- a/stdlib/source/lux.lux
+++ b/stdlib/source/lux.lux
@@ -1,3 +1,8 @@
+("lux def" double-quote
+ ("lux check" (0 "#Text" (0))
+ ("lux int char" +34))
+ [["" 0 0] (10 (0))])
+
("lux def" dummy-cursor
("lux check" (2 (0 "#Text" (0))
(2 (0 "#I64" (1 (0 "#Nat" (0)) (0)))
@@ -37,7 +42,7 @@
(1 [[dummy-cursor (7 ["lux" "doc"])]
[dummy-cursor (5 ("lux text concat"
"The type of things whose type is undefined.\n\n"
- "Useful for expressions that cause errors or other \"extraordinary\" conditions."))]]
+ "Useful for expressions that cause errors or other 'extraordinary' conditions."))]]
(0)))))])
## (type: (List a)
@@ -1572,10 +1577,10 @@
(text$ ("lux text concat"
"## Left-association for the application of binary functions over variadic arguments.\n\n"
("lux text concat"
- "(_$ text/compose \"Hello, \" name \".\\nHow are you?\")\n\n"
+ "(_$ text/compose ''Hello, '' name ''.\\nHow are you?'')\n\n"
("lux text concat"
"## =>\n\n"
- "(text/compose (text/compose \"Hello, \" name) \".\\nHow are you?\")"))))]
+ "(text/compose (text/compose ''Hello, '' name) ''.\\nHow are you?'')"))))]
#Nil)
({(#Cons op tokens')
({(#Cons first nexts)
@@ -1594,10 +1599,10 @@
(text$ ("lux text concat"
"## Right-association for the application of binary functions over variadic arguments.\n\n"
("lux text concat"
- "($_ text/compose \"Hello, \" name \".\\nHow are you?\")\n\n"
+ "($_ text/compose ''Hello, '' name ''.\\nHow are you?'')\n\n"
("lux text concat"
"## =>\n\n"
- "(text/compose \"Hello, \" (text/compose name \".\\nHow are you?\"))"))))]
+ "(text/compose ''Hello, '' (text/compose name ''.\\nHow are you?''))"))))]
#Nil)
({(#Cons op tokens')
({(#Cons last prevs)
@@ -1727,8 +1732,8 @@
(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"
- "=> \"Oh, yeah!\""))])
+ "(if #1 ''Oh, yeah!'' ''Aw hell naw!'')" "\n\n"
+ "=> ''Oh, yeah!''"))])
({(#Cons test (#Cons then (#Cons else #Nil)))
(return (list (form$ (list (record$ (list [(bit$ #1) then]
[(bit$ #0) else]))
@@ -1975,8 +1980,8 @@
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
"## Macro to treat define new primitive types." "\n\n"
- "(primitive \"java.lang.Object\")" "\n\n"
- "(primitive \"java.util.List\" [(primitive \"java.lang.Long\")])"))])
+ "(primitive ''java.lang.Object'')" "\n\n"
+ "(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"])))))
@@ -2038,7 +2043,7 @@
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
"## Quotation as a macro." "\n\n"
- "(' \"YOLO\")"))])
+ "(' YOLO)"))])
({(#Cons template #Nil)
(do Monad<Meta>
[=template (untemplate #0 "" template)]
@@ -2052,9 +2057,9 @@
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
"## Piping macro." "\n\n"
- "(|> elems (list/map int/encode) (interpose \" \") (fold text/compose \"\"))" "\n\n"
+ "(|> elems (list/map int/encode) (interpose '' '') (fold text/compose ''''))" "\n\n"
"## =>" "\n\n"
- "(fold text/compose \"\" (interpose \" \" (list/map int/encode elems)))"))])
+ "(fold text/compose '''' (interpose '' '' (list/map int/encode elems)))"))])
({(#Cons [init apps])
(return (list (list/fold ("lux check" (-> Code Code Code)
(function' [app acc]
@@ -2078,9 +2083,9 @@
(list [(tag$ ["lux" "doc"])
(text$ ($_ "lux text concat"
"## Reverse piping macro." "\n\n"
- "(<| (fold text/compose \"\") (interpose \" \") (list/map int/encode) elems)" "\n\n"
+ "(<| (fold text/compose '''') (interpose '' '') (list/map int/encode) elems)" "\n\n"
"## =>" "\n\n"
- "(fold text/compose \"\" (interpose \" \" (list/map int/encode elems)))"))])
+ "(fold text/compose '''' (interpose '' '' (list/map int/encode elems)))"))])
({(#Cons [init apps])
(return (list (list/fold ("lux check" (-> Code Code Code)
(function' [app acc]
@@ -2961,10 +2966,10 @@
(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"
- "\"YOLO\")"))])
+ " " "(log! ''#1'')" "\n"
+ " " "(log! ''#2'')" "\n"
+ " " "(log! ''#3'')" "\n"
+ "''YOLO'')"))])
({(#Cons value actions)
(let' [dummy (identifier$ ["" ""])]
(return (list (list/fold ("lux check" (-> Code Code Code)
@@ -3046,7 +3051,7 @@
(frac/encode value)
[_ (#Text value)]
- ($_ text/compose "\"" value "\"")
+ ($_ text/compose ..double-quote value ..double-quote)
[_ (#Identifier [prefix name])]
(if (text/= "" prefix)
@@ -3107,11 +3112,11 @@
(do Monad<Meta> [] (wrap (list)))
_
- (fail ($_ text/compose "\"lux.case\" expects an even number of tokens: " (|> branches
- (list/map code-to-text)
- (interpose " ")
- list/reverse
- (list/fold text/compose ""))))}
+ (fail ($_ text/compose "'lux.case' expects an even number of tokens: " (|> branches
+ (list/map code-to-text)
+ (interpose " ")
+ list/reverse
+ (list/fold text/compose ""))))}
branches))
(macro:' #export (case tokens)
@@ -3438,7 +3443,7 @@
" ([#Identifier] [#Tag])"
"\n\n"
" _" "\n"
- " (fail \"Wrong syntax for name-of\")))"))])
+ " (fail ''Wrong syntax for name-of'')))"))])
(let [[exported? tokens] (export^ tokens)
name+args+meta+body?? (: (Maybe [Name (List Code) Code Code])
(case tokens
@@ -3568,8 +3573,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'.\n(and #1 #0 #1) ## => #0"]
+ [or (if (~ pre) #1 (~ post)) "'or' requires >=1 clauses." "Short-circuiting 'or'.\n(or #1 #0 #1) ## => #1"])
(def: (index-of part text)
(-> Text Text (Maybe Nat))
@@ -3604,7 +3609,7 @@
(def: #export (error! message)
{#.doc (text$ ($_ "lux text concat"
"## Causes an error, with the given error message." "\n"
- "(error! \"OH NO!\")"))}
+ "(error! ''OH NO!'')"))}
(-> Text Nothing)
("lux io error" message))
@@ -3851,7 +3856,7 @@
(#Left "Not expecting any type.")))))
(macro: #export (structure tokens)
- {#.doc "Not meant to be used directly. Prefer \"structure:\"."}
+ {#.doc "Not meant to be used directly. Prefer 'structure:'."}
(do Monad<Meta>
[tokens' (monad/map Monad<Meta> macro-expand tokens)
struct-type get-expected-type
@@ -3961,7 +3966,7 @@
(structure (~+ definitions)))))))
#None
- (fail "Cannot infer name, so struct must have a name other than \"_\"!"))
+ (fail "Cannot infer name, so struct must have a name other than '_'!"))
#None
(fail "Wrong syntax for structure:"))))
@@ -4492,9 +4497,9 @@
(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"
+ "## 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"
" (range' <= succ from to))"))}
(case tokens
@@ -4509,7 +4514,7 @@
struct-evidence (resolve-type-tags init-type)]
(case struct-evidence
#None
- (fail (text/compose "Can only \"open\" structs: " (type/encode init-type)))
+ (fail (text/compose "Can only 'open' structs: " (type/encode init-type)))
(#Some tags&members)
(do Monad<Meta>
@@ -4544,11 +4549,11 @@
(macro: #export (cond tokens)
{#.doc (text$ ($_ "lux text concat"
"## Branching structures with multiple test conditions." "\n"
- "(cond (n/even? num) \"even\"" "\n"
- " (n/odd? num) \"odd\""
+ "(cond (n/even? num) ''even''" "\n"
+ " (n/odd? num) ''odd''"
"\n\n"
" ## else-branch" "\n"
- " \"???\")"))}
+ " ''???'')"))}
(if (n/= 0 (n/% 2 (list/size tokens)))
(fail "cond requires an uneven number of arguments.")
(case (list/reverse tokens)
@@ -4649,7 +4654,7 @@
"## Opens a structure and generates a definition for each of its members (including nested members)."
"\n\n"
"## For example:" "\n"
- "(open: \"i:.\" Number<Int>)"
+ "(open: ''i:.'' Number<Int>)"
"\n\n"
"## Will generate:" "\n"
"(def: i:+ (:: Number<Int> +))" "\n"
@@ -4674,7 +4679,7 @@
(return (list/join decls')))
_
- (fail (text/compose "Can only \"open:\" structs: " (type/encode struct-type)))))
+ (fail (text/compose "Can only 'open:' structs: " (type/encode struct-type)))))
_
(do Monad<Meta>
@@ -4689,9 +4694,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"
+ "(|>> (list/map int/encode) (interpose '' '') (fold text/compose ''''))" "\n"
"## =>" "\n"
- "(function (_ <arg>) (fold text/compose \"\" (interpose \" \" (list/map int/encode <arg>))))"))}
+ "(function (_ <arg>) (fold text/compose '''' (interpose '' '' (list/map int/encode <arg>))))"))}
(do Monad<Meta>
[g!_ (gensym "_")
g!arg (gensym "arg")]
@@ -4700,9 +4705,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"
+ "(<<| (fold text/compose '''') (interpose '' '') (list/map int/encode))" "\n"
"## =>" "\n"
- "(function (_ <arg>) (fold text/compose \"\" (interpose \" \" (list/map int/encode <arg>))))"))}
+ "(function (_ <arg>) (fold text/compose '''' (interpose '' '' (list/map int/encode <arg>))))"))}
(do Monad<Meta>
[g!_ (gensym "_")
g!arg (gensym "arg")]
@@ -4832,17 +4837,17 @@
"## Can take optional annotations and allows the specification of modules to import."
"\n\n"
"## Example" "\n"
- "(.module: {#.doc \"Some documentation...\"}" "\n"
+ "(.module: {#.doc ''Some documentation...''}" "\n"
" [lux #*" "\n"
" [control" "\n"
- " [\"M\" monad #*]]" "\n"
+ " [''M'' monad #*]]" "\n"
" [data" "\n"
" maybe" "\n"
- " [\".\" name (\"name/.\" Codec<Text,Name>)]]" "\n"
+ " [''.'' name (''name/.'' Codec<Text,Name>)]]" "\n"
" [macro" "\n"
" code]]" "\n"
" [//" "\n"
- " [type (\".\" Equivalence<Type>)]])"))}
+ " [type (''.'' Equivalence<Type>)]])"))}
(do Monad<Meta>
[#let [[_meta _imports] (: [(List [Code Code]) (List Code)]
(case tokens
@@ -4887,7 +4892,7 @@
(macro: #export (set@ tokens)
{#.doc (text$ ($_ "lux text concat"
"## Sets the value of a record at a given tag." "\n"
- "(set@ #name \"Lux\" lang)"
+ "(set@ #name ''Lux'' lang)"
"\n\n"
"## Can also work with multiple levels of nesting:" "\n"
"(set@ [#foo #bar #baz] value my-record)"
@@ -5154,7 +5159,7 @@
(def: (text/encode original)
(-> Text Text)
- ($_ text/compose "\"" original "\""))
+ ($_ text/compose ..double-quote original ..double-quote))
(do-template [<name> <extension> <doc>]
[(def: #export (<name> value)
@@ -5272,8 +5277,8 @@
"## 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"
+ "(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"
@@ -5337,7 +5342,7 @@
(identifier$ [module name])))
(macro: #export (loop tokens)
- {#.doc (doc "Allows arbitrary looping, using the \"recur\" form to re-start the loop."
+ {#.doc (doc "Allows arbitrary looping, using the 'recur' form to re-start the loop."
"Can be used in monadic code to create monadic loops."
(loop [count +0
x init]
@@ -5480,18 +5485,18 @@
(compare <text> (:: Code/encode encode <expr>))
(compare #1 (:: Equivalence<Code> = <expr> <expr>))]
- [(bit #1) "#1" [_ (#.Bit #1)]]
- [(bit #0) "#0" [_ (#.Bit #0)]]
+ [(bit #1) "#1" [_ (#.Bit #1)]]
+ [(bit #0) "#0" [_ (#.Bit #0)]]
[(int +123) "+123" [_ (#.Int +123)]]
[(frac +123.0) "+123.0" [_ (#.Frac +123.0)]]
- [(text "\n") "\"\\n\"" [_ (#.Text "\n")]]
- [(tag ["yolo" "lol"]) "#yolo.lol" [_ (#.Tag ["yolo" "lol"])]]
- [(identifier ["yolo" "lol"]) "yolo.lol" [_ (#.Identifier ["yolo" "lol"])]]
+ [(text "\n") "'\\n'" [_ (#.Text "\n")]]
+ [(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)]))])]
[(tuple (list (bit #1) (int +123))) "[#1 +123]" (^ [_ (#.Tuple (list [_ (#.Bit #1)] [_ (#.Int +123)]))])]
[(record (list [(bit #1) (int +123)])) "{#1 +123}" (^ [_ (#.Record (list [[_ (#.Bit #1)] [_ (#.Int +123)]]))])]
- [(local-tag "lol") "#lol" [_ (#.Tag ["" "lol"])]]
- [(local-identifier "lol") "lol" [_ (#.Identifier ["" "lol"])]]
+ [(local-tag "lol") "#lol" [_ (#.Tag ["" "lol"])]]
+ [(local-identifier "lol") "lol" [_ (#.Identifier ["" "lol"])]]
)]
(test-all <tests>))))}
(case tokens
@@ -5597,7 +5602,7 @@
(wrap (list pattern')))
_
- (fail "Wrong syntax for \"static\".")))
+ (fail "Wrong syntax for 'static'.")))
(type: Multi-Level-Case
[Code (List [Code Code])])
@@ -5750,7 +5755,7 @@
(fail "Wrong syntax for $")))
(def: #export (is? reference sample)
- {#.doc (doc "Tests whether the 2 values are identical (not just \"equal\")."
+ {#.doc (doc "Tests whether the 2 values are identical (not just 'equal')."
"This one should succeed:"
(let [value +5]
(is? value value))