aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
authorEduardo Julian2020-10-07 20:53:30 -0400
committerEduardo Julian2020-10-07 20:53:30 -0400
commit24ba990800665299b551e66d1bc3d89c96ff6c55 (patch)
tree4aade042f9fe69e1c9a28e728f5cd6ddeaba13d5 /stdlib/source
parentce7614f00a134cb61b4a6f88cfea33461a7bf478 (diff)
Re-named "Cursor" type to "Location".
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux.lux344
-rw-r--r--stdlib/source/lux/abstract/comonad.lux6
-rw-r--r--stdlib/source/lux/abstract/monad.lux6
-rw-r--r--stdlib/source/lux/control/parser/binary.lux6
-rw-r--r--stdlib/source/lux/control/try.lux2
-rw-r--r--stdlib/source/lux/data/format/binary.lux6
-rw-r--r--stdlib/source/lux/data/lazy.lux13
-rw-r--r--stdlib/source/lux/data/maybe.lux2
-rw-r--r--stdlib/source/lux/data/number.lux4
-rw-r--r--stdlib/source/lux/data/store.lux8
-rw-r--r--stdlib/source/lux/data/text/format.lux2
-rw-r--r--stdlib/source/lux/macro/code.lux22
-rw-r--r--stdlib/source/lux/meta.lux12
-rw-r--r--stdlib/source/lux/target/js.lux2
-rw-r--r--stdlib/source/lux/tool/compiler/default/init.lux6
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/analysis.lux40
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/analysis.lux14
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/analysis/case.lux36
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/analysis/inference.lux10
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/directive.lux2
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/syntax.lux26
-rw-r--r--stdlib/source/lux/type.lux12
-rw-r--r--stdlib/source/test/aedifex/parser.lux4
-rw-r--r--stdlib/source/test/lux/control/parser/binary.lux14
-rw-r--r--stdlib/source/test/lux/data/lazy.lux50
-rw-r--r--stdlib/source/test/lux/data/maybe.lux99
-rw-r--r--stdlib/source/test/lux/macro/code.lux6
-rw-r--r--stdlib/source/test/lux/meta.lux30
-rw-r--r--stdlib/source/test/lux/tool/compiler/language/lux/syntax.lux12
29 files changed, 405 insertions, 391 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux
index 2409d3f39..fa33ac0b4 100644
--- a/stdlib/source/lux.lux
+++ b/stdlib/source/lux.lux
@@ -1,21 +1,21 @@
-("lux def" dummy-cursor
+("lux def" dummy-location
["" 0 0]
[["" 0 0] (9 #1 (0 #0))]
#1)
("lux def" double-quote
("lux i64 char" +34)
- [dummy-cursor (9 #1 (0 #0))]
+ [dummy-location (9 #1 (0 #0))]
#0)
("lux def" new-line
("lux i64 char" +10)
- [dummy-cursor (9 #1 (0 #0))]
+ [dummy-location (9 #1 (0 #0))]
#0)
("lux def" __paragraph
("lux text concat" new-line new-line)
- [dummy-cursor (9 #1 (0 #0))]
+ [dummy-location (9 #1 (0 #0))]
#0)
## (type: Any
@@ -24,11 +24,11 @@
("lux check type"
(9 #1 ["lux" "Any"]
(8 #0 (0 #0) (4 #0 1))))
- [dummy-cursor
- (9 #1 (0 #1 [[dummy-cursor (7 #0 ["lux" "doc"])]
- [dummy-cursor (5 #0 ("lux text concat"
- ("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."))]]
+ [dummy-location
+ (9 #1 (0 #1 [[dummy-location (7 #0 ["lux" "doc"])]
+ [dummy-location (5 #0 ("lux text concat"
+ ("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 #0)))]
#1)
@@ -38,11 +38,11 @@
("lux check type"
(9 #1 ["lux" "Nothing"]
(7 #0 (0 #0) (4 #0 1))))
- [dummy-cursor
- (9 #1 (0 #1 [[dummy-cursor (7 #0 ["lux" "doc"])]
- [dummy-cursor (5 #0 ("lux text concat"
- ("lux text concat" "The type of things whose type is undefined." __paragraph)
- "Useful for expressions that cause errors or other 'extraordinary' conditions."))]]
+ [dummy-location
+ (9 #1 (0 #1 [[dummy-location (7 #0 ["lux" "doc"])]
+ [dummy-location (5 #0 ("lux text concat"
+ ("lux text concat" "The type of things whose type is undefined." __paragraph)
+ "Useful for expressions that cause errors or other 'extraordinary' conditions."))]]
(0 #0)))]
#1)
@@ -57,11 +57,11 @@
## "lux.Cons"
(2 #0 (4 #0 1)
(9 #0 (4 #0 1) (4 #0 0))))))
- [dummy-cursor
- (9 #1 (0 #1 [[dummy-cursor (7 #0 ["lux" "type-args"])]
- [dummy-cursor (9 #0 (0 #1 [dummy-cursor (5 #0 "a")] (0 #0)))]]
- (0 #1 [[dummy-cursor (7 #0 ["lux" "doc"])]
- [dummy-cursor (5 #0 "A potentially empty list of values.")]]
+ [dummy-location
+ (9 #1 (0 #1 [[dummy-location (7 #0 ["lux" "type-args"])]
+ [dummy-location (9 #0 (0 #1 [dummy-location (5 #0 "a")] (0 #0)))]]
+ (0 #1 [[dummy-location (7 #0 ["lux" "doc"])]
+ [dummy-location (5 #0 "A potentially empty list of values.")]]
(0 #0))))]
["Nil" "Cons"]
#1)
@@ -70,9 +70,9 @@
("lux check type"
(9 #1 ["lux" "Bit"]
(0 #0 "#Bit" #Nil)))
- [dummy-cursor
- (9 #1 (#Cons [[dummy-cursor (7 #0 ["lux" "doc"])]
- [dummy-cursor (5 #0 "Your standard, run-of-the-mill boolean values (as bits).")]]
+ [dummy-location
+ (9 #1 (#Cons [[dummy-location (7 #0 ["lux" "doc"])]
+ [dummy-location (5 #0 "Your standard, run-of-the-mill boolean values (as bits).")]]
#Nil))]
#1)
@@ -81,9 +81,9 @@
(9 #1 ["lux" "I64"]
(7 #0 (0 #0)
(0 #0 "#I64" (#Cons (4 #0 1) #Nil)))))
- [dummy-cursor
- (9 #1 (#Cons [[dummy-cursor (7 #0 ["lux" "doc"])]
- [dummy-cursor (5 #0 "64-bit integers without any semantics.")]]
+ [dummy-location
+ (9 #1 (#Cons [[dummy-location (7 #0 ["lux" "doc"])]
+ [dummy-location (5 #0 "64-bit integers without any semantics.")]]
#Nil))]
#1)
@@ -91,11 +91,11 @@
("lux check type"
(9 #1 ["lux" "Nat"]
(0 #0 "#I64" (#Cons (0 #0 "#Nat" #Nil) #Nil))))
- [dummy-cursor
- (9 #1 (#Cons [[dummy-cursor (7 #0 ["lux" "doc"])]
- [dummy-cursor (5 #0 ("lux text concat"
- ("lux text concat" "Natural numbers (unsigned integers)." __paragraph)
- "They start at zero (0) and extend in the positive direction."))]]
+ [dummy-location
+ (9 #1 (#Cons [[dummy-location (7 #0 ["lux" "doc"])]
+ [dummy-location (5 #0 ("lux text concat"
+ ("lux text concat" "Natural numbers (unsigned integers)." __paragraph)
+ "They start at zero (0) and extend in the positive direction."))]]
#Nil))]
#1)
@@ -103,9 +103,9 @@
("lux check type"
(9 #1 ["lux" "Int"]
(0 #0 "#I64" (#Cons (0 #0 "#Int" #Nil) #Nil))))
- [dummy-cursor
- (9 #1 (#Cons [[dummy-cursor (7 #0 ["lux" "doc"])]
- [dummy-cursor (5 #0 "Your standard, run-of-the-mill integer numbers.")]]
+ [dummy-location
+ (9 #1 (#Cons [[dummy-location (7 #0 ["lux" "doc"])]
+ [dummy-location (5 #0 "Your standard, run-of-the-mill integer numbers.")]]
#Nil))]
#1)
@@ -113,11 +113,11 @@
("lux check type"
(9 #1 ["lux" "Rev"]
(0 #0 "#I64" (#Cons (0 #0 "#Rev" #Nil) #Nil))))
- [dummy-cursor
- (9 #1 (#Cons [[dummy-cursor (7 #0 ["lux" "doc"])]
- [dummy-cursor (5 #0 ("lux text concat"
- ("lux text concat" "Fractional numbers that live in the interval [0,1)." __paragraph)
- "Useful for probability, and other domains that work within that interval."))]]
+ [dummy-location
+ (9 #1 (#Cons [[dummy-location (7 #0 ["lux" "doc"])]
+ [dummy-location (5 #0 ("lux text concat"
+ ("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))]
#1)
@@ -125,9 +125,9 @@
("lux check type"
(9 #1 ["lux" "Frac"]
(0 #0 "#Frac" #Nil)))
- [dummy-cursor
- (9 #1 (#Cons [[dummy-cursor (7 #0 ["lux" "doc"])]
- [dummy-cursor (5 #0 "Your standard, run-of-the-mill floating-point (fractional) numbers.")]]
+ [dummy-location
+ (9 #1 (#Cons [[dummy-location (7 #0 ["lux" "doc"])]
+ [dummy-location (5 #0 "Your standard, run-of-the-mill floating-point (fractional) numbers.")]]
#Nil))]
#1)
@@ -135,9 +135,9 @@
("lux check type"
(9 #1 ["lux" "Text"]
(0 #0 "#Text" #Nil)))
- [dummy-cursor
- (9 #1 (#Cons [[dummy-cursor (7 #0 ["lux" "doc"])]
- [dummy-cursor (5 #0 "Your standard, run-of-the-mill string values.")]]
+ [dummy-location
+ (9 #1 (#Cons [[dummy-location (7 #0 ["lux" "doc"])]
+ [dummy-location (5 #0 "Your standard, run-of-the-mill string values.")]]
#Nil))]
#1)
@@ -145,9 +145,9 @@
("lux check type"
(9 #1 ["lux" "Name"]
(2 #0 Text Text)))
- [dummy-cursor
- (9 #1 (#Cons [[dummy-cursor (7 #0 ["lux" "doc"])]
- [dummy-cursor (5 #0 "A name. It is used as part of Lux syntax to represent identifiers and tags.")]]
+ [dummy-location
+ (9 #1 (#Cons [[dummy-location (7 #0 ["lux" "doc"])]
+ [dummy-location (5 #0 "A name. It is used as part of Lux syntax to represent identifiers and tags.")]]
#Nil))]
#1)
@@ -161,11 +161,11 @@
Any
## "lux.Some"
(4 #0 1))))
- [dummy-cursor
- (9 #1 (#Cons [[dummy-cursor (7 #0 ["lux" "type-args"])]
- [dummy-cursor (9 #0 (#Cons [dummy-cursor (5 #0 "a")] #Nil))]]
- (#Cons [[dummy-cursor (7 #0 ["lux" "doc"])]
- [dummy-cursor (5 #0 "A potentially missing value.")]]
+ [dummy-location
+ (9 #1 (#Cons [[dummy-location (7 #0 ["lux" "type-args"])]
+ [dummy-location (9 #0 (#Cons [dummy-location (5 #0 "a")] #Nil))]]
+ (#Cons [[dummy-location (7 #0 ["lux" "doc"])]
+ [dummy-location (5 #0 "A potentially missing value.")]]
#Nil)))]
["None" "Some"]
#1)
@@ -215,25 +215,25 @@
("lux check type" (2 #0 Type Type)))}
("lux check type" (9 #0 Type List)))}
("lux check type" (9 #0 (4 #0 1) (4 #0 0)))))
- [dummy-cursor
- (9 #1 (#Cons [[dummy-cursor (7 #0 ["lux" "doc"])]
- [dummy-cursor (5 #0 "This type represents the data-structures that are used to specify types themselves.")]]
- (#Cons [[dummy-cursor (7 #0 ["lux" "type-rec?"])]
- [dummy-cursor (0 #0 #1)]]
+ [dummy-location
+ (9 #1 (#Cons [[dummy-location (7 #0 ["lux" "doc"])]
+ [dummy-location (5 #0 "This type represents the data-structures that are used to specify types themselves.")]]
+ (#Cons [[dummy-location (7 #0 ["lux" "type-rec?"])]
+ [dummy-location (0 #0 #1)]]
#Nil)))]
["Primitive" "Sum" "Product" "Function" "Parameter" "Var" "Ex" "UnivQ" "ExQ" "Apply" "Named"]
#1)
-## (type: Cursor
+## (type: Location
## {#module Text
## #line Nat
## #column Nat})
-("lux def type tagged" Cursor
- (#Named ["lux" "Cursor"]
+("lux def type tagged" Location
+ (#Named ["lux" "Location"]
(#Product Text (#Product Nat Nat)))
- [dummy-cursor
- (9 #1 (#Cons [[dummy-cursor (7 #0 ["lux" "doc"])]
- [dummy-cursor (5 #0 "Cursors are for specifying the location of Code nodes in Lux files during compilation.")]]
+ [dummy-location
+ (9 #1 (#Cons [[dummy-location (7 #0 ["lux" "doc"])]
+ [dummy-location (5 #0 "Locations are for specifying the location of Code nodes in Lux files during compilation.")]]
#Nil))]
["module" "line" "column"]
#1)
@@ -247,11 +247,11 @@
(#UnivQ #Nil
(#Product (#Parameter 3)
(#Parameter 1)))))
- [dummy-cursor
- (9 #1 (#Cons [[dummy-cursor (7 #0 ["lux" "doc"])]
- [dummy-cursor (5 #0 "The type of things that can be annotated with meta-data of arbitrary types.")]]
- (#Cons [[dummy-cursor (7 #0 ["lux" "type-args"])]
- [dummy-cursor (9 #0 (#Cons [dummy-cursor (5 #0 "m")] (#Cons [dummy-cursor (5 #0 "v")] #Nil)))]]
+ [dummy-location
+ (9 #1 (#Cons [[dummy-location (7 #0 ["lux" "doc"])]
+ [dummy-location (5 #0 "The type of things that can be annotated with meta-data of arbitrary types.")]]
+ (#Cons [[dummy-location (7 #0 ["lux" "type-args"])]
+ [dummy-location (9 #0 (#Cons [dummy-location (5 #0 "m")] (#Cons [dummy-location (5 #0 "v")] #Nil)))]]
#Nil)))]
["meta" "datum"]
#1)
@@ -301,111 +301,111 @@
("lux check type" (#Apply (#Apply (#Parameter 1)
(#Parameter 0))
(#Parameter 1)))))
- [dummy-cursor
- (9 #1 (#Cons [[dummy-cursor (7 #0 ["lux" "type-args"])]
- [dummy-cursor (9 #0 (#Cons [dummy-cursor (5 #0 "w")] #Nil))]]
+ [dummy-location
+ (9 #1 (#Cons [[dummy-location (7 #0 ["lux" "type-args"])]
+ [dummy-location (9 #0 (#Cons [dummy-location (5 #0 "w")] #Nil))]]
#Nil))]
["Bit" "Nat" "Int" "Rev" "Frac" "Text" "Identifier" "Tag" "Form" "Tuple" "Record"]
#1)
## (type: Code
-## (Ann Cursor (Code' (Ann Cursor))))
+## (Ann Location (Code' (Ann Location))))
("lux def" Code
(#Named ["lux" "Code"]
({w
(#Apply (#Apply w Code') w)}
- ("lux check type" (#Apply Cursor Ann))))
- [dummy-cursor
- (#Record (#Cons [[dummy-cursor (#Tag ["lux" "doc"])]
- [dummy-cursor (#Text "The type of Code nodes for Lux syntax.")]]
+ ("lux check type" (#Apply Location Ann))))
+ [dummy-location
+ (#Record (#Cons [[dummy-location (#Tag ["lux" "doc"])]
+ [dummy-location (#Text "The type of Code nodes for Lux syntax.")]]
#Nil))]
#1)
("lux def" _ann
- ("lux check" (#Function (#Apply (#Apply Cursor Ann)
+ ("lux check" (#Function (#Apply (#Apply Location Ann)
Code')
Code)
([_ data]
- [dummy-cursor data]))
- [dummy-cursor (#Record #Nil)]
+ [dummy-location data]))
+ [dummy-location (#Record #Nil)]
#0)
("lux def" bit$
("lux check" (#Function Bit Code)
([_ value] (_ann (#Bit value))))
- [dummy-cursor (#Record #Nil)]
+ [dummy-location (#Record #Nil)]
#0)
("lux def" nat$
("lux check" (#Function Nat Code)
([_ value] (_ann (#Nat value))))
- [dummy-cursor (#Record #Nil)]
+ [dummy-location (#Record #Nil)]
#0)
("lux def" int$
("lux check" (#Function Int Code)
([_ value] (_ann (#Int value))))
- [dummy-cursor (#Record #Nil)]
+ [dummy-location (#Record #Nil)]
#0)
("lux def" rev$
("lux check" (#Function Rev Code)
([_ value] (_ann (#Rev value))))
- [dummy-cursor (#Record #Nil)]
+ [dummy-location (#Record #Nil)]
#0)
("lux def" frac$
("lux check" (#Function Frac Code)
([_ value] (_ann (#Frac value))))
- [dummy-cursor (#Record #Nil)]
+ [dummy-location (#Record #Nil)]
#0)
("lux def" text$
("lux check" (#Function Text Code)
([_ text] (_ann (#Text text))))
- [dummy-cursor (#Record #Nil)]
+ [dummy-location (#Record #Nil)]
#0)
("lux def" identifier$
("lux check" (#Function Name Code)
([_ name] (_ann (#Identifier name))))
- [dummy-cursor (#Record #Nil)]
+ [dummy-location (#Record #Nil)]
#0)
("lux def" local-identifier$
("lux check" (#Function Text Code)
([_ name] (_ann (#Identifier ["" name]))))
- [dummy-cursor (#Record #Nil)]
+ [dummy-location (#Record #Nil)]
#0)
("lux def" tag$
("lux check" (#Function Name Code)
([_ name] (_ann (#Tag name))))
- [dummy-cursor (#Record #Nil)]
+ [dummy-location (#Record #Nil)]
#0)
("lux def" local-tag$
("lux check" (#Function Text Code)
([_ name] (_ann (#Tag ["" name]))))
- [dummy-cursor (#Record #Nil)]
+ [dummy-location (#Record #Nil)]
#0)
("lux def" form$
("lux check" (#Function (#Apply Code List) Code)
([_ tokens] (_ann (#Form tokens))))
- [dummy-cursor (#Record #Nil)]
+ [dummy-location (#Record #Nil)]
#0)
("lux def" tuple$
("lux check" (#Function (#Apply Code List) Code)
([_ tokens] (_ann (#Tuple tokens))))
- [dummy-cursor (#Record #Nil)]
+ [dummy-location (#Record #Nil)]
#0)
("lux def" record$
("lux check" (#Function (#Apply (#Product Code Code) List) Code)
([_ tokens] (_ann (#Record tokens))))
- [dummy-cursor (#Record #Nil)]
+ [dummy-location (#Record #Nil)]
#0)
## (type: Definition
@@ -518,11 +518,11 @@
#1)
## (type: Source
-## [Cursor Nat Text])
+## [Location Nat Text])
("lux def" Source
("lux check type"
(#Named ["lux" "Source"]
- (#Product Cursor (#Product Nat Text))))
+ (#Product Location (#Product Nat Text))))
(record$ #Nil)
#1)
@@ -644,7 +644,7 @@
## (type: Lux
## {#info Info
## #source Source
-## #cursor Cursor
+## #location Location
## #current-module (Maybe Text)
## #modules (List [Text Module])
## #scopes (List Scope)
@@ -660,8 +660,8 @@
Info
(#Product ## "lux.source"
Source
- (#Product ## "lux.cursor"
- Cursor
+ (#Product ## "lux.location"
+ Location
(#Product ## "lux.current-module"
(#Apply Text Maybe)
(#Product ## "lux.modules"
@@ -687,7 +687,7 @@
("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.")))]
#Nil))
- ["info" "source" "cursor" "current-module" "modules" "scopes" "type-context" "expected" "seed" "scope-type-vars" "extensions" "host"]
+ ["info" "source" "location" "current-module" "modules" "scopes" "type-context" "expected" "seed" "scope-type-vars" "extensions" "host"]
#1)
## (type: (Meta a)
@@ -805,7 +805,7 @@
(record$ #.Nil)
#0)
-("lux def" cursor-code
+("lux def" location-code
("lux check" Code
(tuple$ (#Cons (text$ "") (#Cons (nat$ 0) (#Cons (nat$ 0) #Nil)))))
(record$ #Nil)
@@ -815,7 +815,7 @@
("lux check" (#Function Name (#Function Code Code))
([_ tag]
([_ value]
- (tuple$ (#Cons cursor-code
+ (tuple$ (#Cons location-code
(#Cons (form$ (#Cons (tag$ tag) (#Cons value #Nil)))
#Nil))))))
(record$ #Nil)
@@ -1723,7 +1723,7 @@
(let' [[module name] full-name
{#info info #source source #current-module _ #modules modules
#scopes scopes #type-context types #host host
- #seed seed #expected expected #cursor cursor #extensions extensions
+ #seed seed #expected expected #location location #extensions extensions
#scope-type-vars scope-type-vars} state]
({(#Some {#module-hash _ #module-aliases _ #definitions definitions #imports _ #tags tags #types types #module-annotations _ #module-state _})
({(#Some constant)
@@ -1907,7 +1907,7 @@
($' Meta Text)
({{#info info #source source #current-module current-module #modules modules
#scopes scopes #type-context types #host host
- #seed seed #expected expected #cursor cursor #extensions extensions
+ #seed seed #expected expected #location location #extensions extensions
#scope-type-vars scope-type-vars}
({(#Some module-name)
(#Right [state module-name])
@@ -2331,7 +2331,7 @@
({{#info info #source source #current-module _ #modules modules
#scopes scopes #type-context types #host host
#seed seed #expected expected
- #cursor cursor #extensions extensions
+ #location location #extensions extensions
#scope-type-vars scope-type-vars}
(#Right state (find-macro' modules current-module module name))}
state)))))
@@ -2595,12 +2595,12 @@
({{#info info #source source #current-module _ #modules modules
#scopes scopes #type-context types #host host
#seed seed #expected expected
- #cursor cursor #extensions extensions
+ #location location #extensions extensions
#scope-type-vars scope-type-vars}
(#Right {#info info #source source #current-module _ #modules modules
#scopes scopes #type-context types #host host
#seed ("lux i64 +" 1 seed) #expected expected
- #cursor cursor #extensions extensions
+ #location location #extensions extensions
#scope-type-vars scope-type-vars}
(local-identifier$ ($_ text@compose "__gensym__" prefix (nat@encode seed))))}
state))
@@ -2679,7 +2679,7 @@
?type)]
(return (list (` ("lux def" (~ name)
(~ body'')
- [(~ cursor-code)
+ [(~ location-code)
(#.Record #.Nil)]
(~ (bit$ export?)))))))
@@ -2983,10 +2983,10 @@
meta
_
- (` (#.Cons [[(~ cursor-code) (#.Tag ["lux" "func-args"])]
- [(~ cursor-code) (#.Tuple (.list (~+ (list@map (function (_ arg)
- (` [(~ cursor-code) (#.Text (~ (text$ (code@encode arg))))]))
- args))))]]
+ (` (#.Cons [[(~ location-code) (#.Tag ["lux" "func-args"])]
+ [(~ location-code) (#.Tuple (.list (~+ (list@map (function (_ arg)
+ (` [(~ location-code) (#.Text (~ (text$ (code@encode arg))))]))
+ args))))]]
(~ meta)))))
(def:' (with-type-args args)
@@ -3067,7 +3067,7 @@
=meta (process-def-meta meta)]
(return (list (` ("lux def" (~ name)
(~ body)
- [(~ cursor-code)
+ [(~ location-code)
(#.Record (~ (with-func-args args =meta)))]
(~ (bit$ exported?)))))))
@@ -3077,8 +3077,8 @@
(def: (meta-code-add addition meta)
(-> [Code Code] Code Code)
(case [addition meta]
- [[name value] [cursor (#Record pairs)]]
- [cursor (#Record (#Cons [name value] pairs))]
+ [[name value] [location (#Record pairs)]]
+ [location (#Record (#Cons [name value] pairs))]
_
meta))
@@ -3086,7 +3086,7 @@
(def: (meta-code-merge addition base)
(-> Code Code Code)
(case addition
- [cursor (#Record pairs)]
+ [location (#Record pairs)]
(list@fold meta-code-add base pairs)
_
@@ -3135,7 +3135,7 @@
=meta (process-def-meta meta)]
(return (list (` ("lux def" (~ name)
(~ body)
- [(~ cursor-code)
+ [(~ location-code)
(#Record (~ =meta))]
(~ (bit$ exported?)))))))
@@ -3159,11 +3159,11 @@
(let [[exported? tokens'] (export^ tokens)
?parts (: (Maybe [Name (List Code) Code (List Code)])
(case tokens'
- (^ (list& [_ (#Form (list& [_ (#Identifier name)] args))] [meta-rec-cursor (#Record meta-rec-parts)] sigs))
- (#Some name args [meta-rec-cursor (#Record meta-rec-parts)] sigs)
+ (^ (list& [_ (#Form (list& [_ (#Identifier name)] args))] [meta-rec-location (#Record meta-rec-parts)] sigs))
+ (#Some name args [meta-rec-location (#Record meta-rec-parts)] sigs)
- (^ (list& [_ (#Identifier name)] [meta-rec-cursor (#Record meta-rec-parts)] sigs))
- (#Some name #Nil [meta-rec-cursor (#Record meta-rec-parts)] sigs)
+ (^ (list& [_ (#Identifier name)] [meta-rec-location (#Record meta-rec-parts)] sigs))
+ (#Some name #Nil [meta-rec-location (#Record meta-rec-parts)] sigs)
(^ (list& [_ (#Form (list& [_ (#Identifier name)] args))] sigs))
(#Some name args (` {}) sigs)
@@ -3260,7 +3260,7 @@
"(default +20 #.None) ## => +20"))}
(case tokens
(^ (list else maybe))
- (let [g!temp (: Code [dummy-cursor (#Identifier ["" ""])])
+ (let [g!temp (: Code [dummy-location (#Identifier ["" ""])])
code (` (case (~ maybe)
(#.Some (~ g!temp))
(~ g!temp)
@@ -3418,7 +3418,7 @@
(function (_ state)
(let [{#info info #source source #current-module _ #modules modules
#scopes scopes #type-context types #host host
- #seed seed #expected expected #cursor cursor #extensions extensions
+ #seed seed #expected expected #location location #extensions extensions
#scope-type-vars scope-type-vars} state]
(case (get name modules)
(#Some module)
@@ -3481,7 +3481,7 @@
(function (_ state)
(let [{#info info #source source #current-module _ #modules modules
#scopes scopes #type-context types #host host
- #seed seed #expected expected #cursor cursor #extensions extensions
+ #seed seed #expected expected #location location #extensions extensions
#scope-type-vars scope-type-vars} state]
(case expected
(#Some type)
@@ -3553,11 +3553,11 @@
(let [[exported? tokens'] (export^ tokens)
?parts (: (Maybe [Code (List Code) Code Code (List Code)])
(case tokens'
- (^ (list& [_ (#Form (list& name args))] [meta-rec-cursor (#Record meta-rec-parts)] type definitions))
- (#Some name args type [meta-rec-cursor (#Record meta-rec-parts)] definitions)
+ (^ (list& [_ (#Form (list& name args))] [meta-rec-location (#Record meta-rec-parts)] type definitions))
+ (#Some name args type [meta-rec-location (#Record meta-rec-parts)] definitions)
- (^ (list& name [meta-rec-cursor (#Record meta-rec-parts)] type definitions))
- (#Some name #Nil type [meta-rec-cursor (#Record meta-rec-parts)] definitions)
+ (^ (list& name [meta-rec-location (#Record meta-rec-parts)] type definitions))
+ (#Some name #Nil type [meta-rec-location (#Record meta-rec-parts)] definitions)
(^ (list& [_ (#Form (list& name args))] type definitions))
(#Some name args type (` {}) definitions)
@@ -3599,19 +3599,19 @@
[#0 tokens'])
parts (: (Maybe [Text (List Code) (List [Code Code]) (List Code)])
(case tokens'
- (^ (list [_ (#Identifier "" name)] [meta-cursor (#Record meta-parts)] [type-cursor (#Record type-parts)]))
- (#Some [name #Nil meta-parts (list [type-cursor (#Record type-parts)])])
+ (^ (list [_ (#Identifier "" name)] [meta-location (#Record meta-parts)] [type-location (#Record type-parts)]))
+ (#Some [name #Nil meta-parts (list [type-location (#Record type-parts)])])
- (^ (list& [_ (#Identifier "" name)] [meta-cursor (#Record meta-parts)] type-code1 type-codes))
+ (^ (list& [_ (#Identifier "" name)] [meta-location (#Record meta-parts)] type-code1 type-codes))
(#Some [name #Nil meta-parts (#Cons type-code1 type-codes)])
(^ (list& [_ (#Identifier "" name)] type-codes))
(#Some [name #Nil (list) type-codes])
- (^ (list [_ (#Form (#Cons [_ (#Identifier "" name)] args))] [meta-cursor (#Record meta-parts)] [type-cursor (#Record type-parts)]))
- (#Some [name args meta-parts (list [type-cursor (#Record type-parts)])])
+ (^ (list [_ (#Form (#Cons [_ (#Identifier "" name)] args))] [meta-location (#Record meta-parts)] [type-location (#Record type-parts)]))
+ (#Some [name args meta-parts (list [type-location (#Record type-parts)])])
- (^ (list& [_ (#Form (#Cons [_ (#Identifier "" name)] args))] [meta-cursor (#Record meta-parts)] type-code1 type-codes))
+ (^ (list& [_ (#Form (#Cons [_ (#Identifier "" name)] args))] [meta-location (#Record meta-parts)] type-code1 type-codes))
(#Some [name args meta-parts (#Cons type-code1 type-codes)])
(^ (list& [_ (#Form (#Cons [_ (#Identifier "" name)] args))] type-codes))
@@ -3645,7 +3645,7 @@
meta (if rec?
(` (#.Cons (~ (flag-meta "type-rec?")) (~ meta)))
meta)]
- (` [(~ cursor-code)
+ (` [(~ location-code)
(#.Record (~ meta))]))]
(case type'
(#Some type'')
@@ -3958,7 +3958,7 @@
(let [[current-module modules] (case state
{#info info #source source #current-module current-module #modules modules
#scopes scopes #type-context types #host host
- #seed seed #expected expected #cursor cursor #extensions extensions
+ #seed seed #expected expected #location location #extensions extensions
#scope-type-vars scope-type-vars}
[current-module modules])]
(case (get module modules)
@@ -4026,7 +4026,7 @@
(case state
{#info info #source source #current-module _ #modules modules
#scopes scopes #type-context types #host host
- #seed seed #expected expected #cursor cursor #extensions extensions
+ #seed seed #expected expected #location location #extensions extensions
#scope-type-vars scope-type-vars}
(find (: (-> Scope (Maybe Type))
(function (_ env)
@@ -4049,7 +4049,7 @@
(let [[v-prefix v-name] name
{#info info #source source #current-module _ #modules modules
#scopes scopes #type-context types #host host
- #seed seed #expected expected #cursor cursor #extensions extensions
+ #seed seed #expected expected #location location #extensions extensions
#scope-type-vars scope-type-vars} state]
(case (get v-prefix modules)
#None
@@ -4073,7 +4073,7 @@
(let [[v-prefix v-name] name
{#info info #source source #current-module _ #modules modules
#scopes scopes #type-context types #host host
- #seed seed #expected expected #cursor cursor #extensions extensions
+ #seed seed #expected expected #location location #extensions extensions
#scope-type-vars scope-type-vars} state]
(case (get v-prefix modules)
#None
@@ -4131,7 +4131,7 @@
(#Right [compiler (#Var type-id)])
(let [{#info _ #source _ #current-module _ #modules _
#scopes _ #type-context type-context #host _
- #seed _ #expected _ #cursor _ #extensions extensions
+ #seed _ #expected _ #location _ #extensions extensions
#scope-type-vars _} compiler
{#ex-counter _ #var-counter _ #var-bindings var-bindings} type-context]
(case (find-type-var type-id var-bindings)
@@ -4367,7 +4367,7 @@
_
(return (list (` ("lux def" (~ (local-identifier$ (de-alias "" short alias)))
(~ source+)
- [(~ cursor-code) (#.Record #Nil)]
+ [(~ location-code) (#.Record #Nil)]
#0)))))))
(macro: #export (open: tokens)
@@ -4406,7 +4406,7 @@
(do meta-monad
[g!struct (gensym "struct")]
(return (list (` ("lux def" (~ g!struct) (~ struct)
- [(~ cursor-code) (#.Record #Nil)]
+ [(~ location-code) (#.Record #Nil)]
#0))
(` (..open: (~ (text$ alias)) (~ g!struct)))))))
@@ -4584,7 +4584,7 @@
(function (_ [m-name m-alias =refer])
(refer-to-code m-name m-alias =refer)))
imports)
- =module (` ("lux def module" [(~ cursor-code)
+ =module (` ("lux def module" [(~ location-code)
(#.Record (~ (process-def-meta _meta)))]
(~ =imports)))]]
(wrap (#Cons =module =refers))))
@@ -4888,8 +4888,8 @@
(#Cons x (repeat ("lux i64 +" -1 n) x))
#Nil))
-(def: (cursor-padding baseline [_ old-line old-column] [_ new-line new-column])
- (-> Nat Cursor Cursor Text)
+(def: (location-padding baseline [_ old-line old-column] [_ new-line new-column])
+ (-> Nat Location Location Text)
(if ("lux i64 =" old-line new-line)
(text@join-with "" (repeat (.int ("lux i64 -" old-column new-column)) " "))
(let [extra-lines (text@join-with "" (repeat (.int ("lux i64 -" old-line new-line)) ..new-line))
@@ -4900,26 +4900,26 @@
(-> Text Nat)
("lux text size" x))
-(def: (update-cursor [file line column] code-text)
- (-> Cursor Text Cursor)
+(def: (update-location [file line column] code-text)
+ (-> Location Text Location)
[file line ("lux i64 +" column (text@size code-text))])
-(def: (delim-update-cursor [file line column])
- (-> Cursor Cursor)
+(def: (delim-update-location [file line column])
+ (-> Location Location)
[file line (inc column)])
(def: rejoin-all-pairs
(-> (List [Code Code]) (List Code))
(|>> (list@map rejoin-pair) list@join))
-(def: (doc-example->Text prev-cursor baseline example)
- (-> Cursor Nat Code [Cursor Text])
+(def: (doc-example->Text prev-location baseline example)
+ (-> Location Nat Code [Location Text])
(case example
(^template [<tag> <encode>]
- [new-cursor (<tag> value)]
+ [new-location (<tag> value)]
(let [as-text (<encode> value)]
- [(update-cursor new-cursor as-text)
- (text@compose (cursor-padding baseline prev-cursor new-cursor)
+ [(update-location new-location as-text)
+ (text@compose (location-padding baseline prev-location new-location)
as-text)]))
([#Bit bit@encode]
[#Nat nat@encode]
@@ -4930,14 +4930,14 @@
[#Tag tag@encode])
(^template [<tag> <open> <close> <prep>]
- [group-cursor (<tag> parts)]
- (let [[group-cursor' parts-text] (list@fold (function (_ part [last-cursor text-accum])
- (let [[part-cursor part-text] (doc-example->Text last-cursor baseline part)]
- [part-cursor (text@compose text-accum part-text)]))
- [(delim-update-cursor group-cursor) ""]
- (<prep> parts))]
- [(delim-update-cursor group-cursor')
- ($_ text@compose (cursor-padding baseline prev-cursor group-cursor)
+ [group-location (<tag> parts)]
+ (let [[group-location' parts-text] (list@fold (function (_ part [last-location text-accum])
+ (let [[part-location part-text] (doc-example->Text last-location baseline part)]
+ [part-location (text@compose text-accum part-text)]))
+ [(delim-update-location group-location) ""]
+ (<prep> parts))]
+ [(delim-update-location group-location')
+ ($_ text@compose (location-padding baseline prev-location group-location)
<open>
parts-text
<close>)]))
@@ -4945,12 +4945,12 @@
[#Tuple "[" "]" ..function@identity]
[#Record "{" "}" rejoin-all-pairs])
- [new-cursor (#Rev value)]
+ [new-location (#Rev value)]
("lux io error" "Undefined behavior.")
))
(def: (with-baseline baseline [file line column])
- (-> Nat Cursor Cursor)
+ (-> Nat Location Location)
[file line baseline])
(def: (doc-fragment->Text fragment)
@@ -4964,8 +4964,8 @@
(#Doc-Example example)
(let [baseline (find-baseline-column example)
- [cursor _] example
- [_ text] (doc-example->Text (with-baseline baseline cursor) baseline example)]
+ [location _] example
+ [_ text] (doc-example->Text (with-baseline baseline location) baseline example)]
(text@compose text __paragraph))))
(macro: #export (doc tokens)
@@ -4980,7 +4980,7 @@
" (if (< +10 count)" ..new-line
" (recur (inc count) (f x))" ..new-line
" x)))"))}
- (return (list (` [(~ cursor-code)
+ (return (list (` [(~ location-code)
(#.Text (~ (|> tokens
(list@map (|>> identify-doc-fragment doc-fragment->Text))
(text@join-with "")
@@ -5140,14 +5140,14 @@
(#Some (list target)))
(^template [<tag>]
- [cursor (<tag> elems)]
+ [location (<tag> elems)]
(do maybe-monad
[placements (monad@map maybe-monad (place-tokens label tokens) elems)]
- (wrap (list [cursor (<tag> (list@join placements))]))))
+ (wrap (list [location (<tag> (list@join placements))]))))
([#Tuple]
[#Form])
- [cursor (#Record pairs)]
+ [location (#Record pairs)]
(do maybe-monad
[=pairs (monad@map maybe-monad
(: (-> [Code Code] (Maybe [Code Code]))
@@ -5162,7 +5162,7 @@
_
#None))))
pairs)]
- (wrap (list [cursor (#Record =pairs)])))
+ (wrap (list [location (#Record =pairs)])))
))
(macro: #export (with-expansions tokens)
@@ -5416,7 +5416,7 @@
(case state
{#info info #source source #current-module _ #modules modules
#scopes scopes #type-context types #host host
- #seed seed #expected expected #cursor cursor #extensions extensions
+ #seed seed #expected expected #location location #extensions extensions
#scope-type-vars scope-type-vars}
(#Right state scope-type-vars)
))
@@ -5856,8 +5856,8 @@
_
(fail (..wrong-syntax-error (name-of ..^code)))))
-(def: #export (cursor-description [file line column])
- (-> Cursor Text)
+(def: #export (location-description [file line column])
+ (-> Location Text)
(let [separator ", "
fields ($_ "lux text concat"
(text@encode file) separator
diff --git a/stdlib/source/lux/abstract/comonad.lux b/stdlib/source/lux/abstract/comonad.lux
index 874b96913..14515da25 100644
--- a/stdlib/source/lux/abstract/comonad.lux
+++ b/stdlib/source/lux/abstract/comonad.lux
@@ -24,8 +24,6 @@
{#.doc "The CoFree CoMonad."}
[a (F (CoFree F a))])
-(def: _cursor Cursor ["" 0 0])
-
(macro: #export (be tokens state)
{#.doc (doc "A co-monadic parallel to the 'do' macro."
(let [square (function (_ n) (* n n))]
@@ -46,7 +44,7 @@
(if (|> bindings list.size (n.% 2) (n.= 0))
(let [[module short] (name-of ..be)
gensym (: (-> Text Code)
- (|>> ($_ "lux text concat" module " " short " ") [""] #.Identifier [_cursor]))
+ (|>> ($_ "lux text concat" module " " short " ") [""] #.Identifier [.dummy-location]))
g!_ (gensym "_")
g!map (gensym "map")
g!split (gensym "split")
@@ -64,7 +62,7 @@
(list.reverse (list.as-pairs bindings)))]
(#.Right [state (list (case ?name
(#.Some name)
- (let [name [_cursor (#.Identifier ["" name])]]
+ (let [name [.dummy-location (#.Identifier ["" name])]]
(` ({(~ name)
({[(~ g!map) (~' unwrap) (~ g!split)]
(~ body')}
diff --git a/stdlib/source/lux/abstract/monad.lux b/stdlib/source/lux/abstract/monad.lux
index 4c03e937c..c2b19362d 100644
--- a/stdlib/source/lux/abstract/monad.lux
+++ b/stdlib/source/lux/abstract/monad.lux
@@ -50,8 +50,6 @@
(-> (m (m a)) (m a)))
join))
-(def: _cursor Cursor ["" 0 0])
-
(macro: #export (do tokens state)
{#.doc (doc "Macro for easy concatenation of monadic operations."
(do monad
@@ -72,7 +70,7 @@
(if (|> bindings list@size .int ("lux i64 %" +2) ("lux i64 =" +0))
(let [[module short] (name-of ..do)
gensym (: (-> Text Code)
- (|>> ($_ "lux text concat" module " " short " ") [""] #.Identifier [_cursor]))
+ (|>> ($_ "lux text concat" module " " short " ") [""] #.Identifier [.dummy-location]))
g!_ (gensym "_")
g!map (gensym "map")
g!join (gensym "join")
@@ -90,7 +88,7 @@
(reverse (as-pairs bindings)))]
(#.Right [state (list (case ?name
(#.Some name)
- (let [name [_cursor (#.Identifier ["" name])]]
+ (let [name [.dummy-location (#.Identifier ["" name])]]
(` ({(~ name)
({[(~ g!map) (~' wrap) (~ g!join)]
(~ body')}
diff --git a/stdlib/source/lux/control/parser/binary.lux b/stdlib/source/lux/control/parser/binary.lux
index ed698ccd1..905afba3f 100644
--- a/stdlib/source/lux/control/parser/binary.lux
+++ b/stdlib/source/lux/control/parser/binary.lux
@@ -249,8 +249,8 @@
[9 #.Apply pair]
[10 #.Named (//.and ..name type)]])))))
-(def: #export cursor
- (Parser Cursor)
+(def: #export location
+ (Parser Location)
($_ //.and ..text ..nat ..nat))
(def: #export code
@@ -258,7 +258,7 @@
(..rec
(function (_ recur)
(let [sequence (..list recur)]
- (//.and ..cursor
+ (//.and ..location
(!variant [[0 #.Bit ..bit]
[1 #.Nat ..nat]
[2 #.Int ..int]
diff --git a/stdlib/source/lux/control/try.lux b/stdlib/source/lux/control/try.lux
index f22da7a1b..74707c51b 100644
--- a/stdlib/source/lux/control/try.lux
+++ b/stdlib/source/lux/control/try.lux
@@ -143,7 +143,7 @@
(#..Success (~' g!temp))
(~' g!temp)
- (#..Failure (~ [dummy-cursor (#.Identifier ["" ""])]))
+ (#..Failure (~ [.dummy-location (#.Identifier ["" ""])]))
(~ else))))])
_
diff --git a/stdlib/source/lux/data/format/binary.lux b/stdlib/source/lux/data/format/binary.lux
index ece895c38..f629f8b52 100644
--- a/stdlib/source/lux/data/format/binary.lux
+++ b/stdlib/source/lux/data/format/binary.lux
@@ -254,8 +254,8 @@
[10 #.Named (..and ..name recur)])
))))))
-(def: #export cursor
- (Writer Cursor)
+(def: #export location
+ (Writer Location)
($_ ..and ..text ..nat ..nat))
(def: #export code
@@ -263,7 +263,7 @@
(..rec
(function (_ recur)
(let [sequence (..list recur)]
- (..and ..cursor
+ (..and ..location
(function (_ altV)
(case altV
(^template [<number> <tag> <writer>]
diff --git a/stdlib/source/lux/data/lazy.lux b/stdlib/source/lux/data/lazy.lux
index 705e88682..db0293413 100644
--- a/stdlib/source/lux/data/lazy.lux
+++ b/stdlib/source/lux/data/lazy.lux
@@ -43,19 +43,26 @@
(structure: #export (equivalence (^open "_@."))
(All [a] (-> (Equivalence a) (Equivalence (Lazy a))))
+
(def: (= left right)
(_@= (..thaw left) (..thaw right))))
-(structure: #export functor (Functor Lazy)
+(structure: #export functor
+ (Functor Lazy)
+
(def: (map f fa)
(freeze (f (thaw fa)))))
-(structure: #export apply (Apply Lazy)
+(structure: #export apply
+ (Apply Lazy)
+
(def: &functor ..functor)
(def: (apply ff fa)
(freeze ((thaw ff) (thaw fa)))))
-(structure: #export monad (Monad Lazy)
+(structure: #export monad
+ (Monad Lazy)
+
(def: &functor ..functor)
(def: wrap (|>> freeze))
(def: join thaw))
diff --git a/stdlib/source/lux/data/maybe.lux b/stdlib/source/lux/data/maybe.lux
index 2afd4cb60..2e7912550 100644
--- a/stdlib/source/lux/data/maybe.lux
+++ b/stdlib/source/lux/data/maybe.lux
@@ -123,7 +123,7 @@
+20)}
(case tokens
(^ (list else maybe))
- (let [g!temp (: Code [dummy-cursor (#.Identifier ["" ""])])
+ (let [g!temp (: Code [.dummy-location (#.Identifier ["" ""])])
code (` (case (~ maybe)
(#.Some (~ g!temp))
(~ g!temp)
diff --git a/stdlib/source/lux/data/number.lux b/stdlib/source/lux/data/number.lux
index 07e093849..48a931637 100644
--- a/stdlib/source/lux/data/number.lux
+++ b/stdlib/source/lux/data/number.lux
@@ -14,13 +14,13 @@
(macro: (encoding-doc tokens state)
(case tokens
- (^ (list [cursor (#.Text encoding)] example-1 example-2))
+ (^ (list [location (#.Text encoding)] example-1 example-2))
(let [encoding ($_ "lux text concat"
"Given syntax for a "
encoding
" number, generates a Nat, an Int, a Rev or a Frac.")
commas "Allows for the presence of commas among the digits."
- description [cursor (#.Text ($_ "lux text concat" encoding " " commas))]]
+ description [location (#.Text ($_ "lux text concat" encoding " " commas))]]
(#try.Success [state (list (` (doc (~ description)
(~ example-1)
(~ example-2))))]))
diff --git a/stdlib/source/lux/data/store.lux b/stdlib/source/lux/data/store.lux
index 36cc3e67d..fa3e45f00 100644
--- a/stdlib/source/lux/data/store.lux
+++ b/stdlib/source/lux/data/store.lux
@@ -15,13 +15,17 @@
{#cursor (get@ #cursor wa)
#peek (function (_ s) (f (set@ #cursor s wa)))})
-(structure: #export functor (All [s] (Functor (Store s)))
+(structure: #export functor
+ (All [s] (Functor (Store s)))
+
(def: (map f fa)
(extend (function (_ store)
(f (:: store peek (:: store cursor))))
fa)))
-(structure: #export comonad (All [s] (CoMonad (Store s)))
+(structure: #export comonad
+ (All [s] (CoMonad (Store s)))
+
(def: &functor ..functor)
(def: (unwrap wa) (::: peek (::: cursor)))
diff --git a/stdlib/source/lux/data/text/format.lux b/stdlib/source/lux/data/text/format.lux
index 392e3ee42..388bd3638 100644
--- a/stdlib/source/lux/data/text/format.lux
+++ b/stdlib/source/lux/data/text/format.lux
@@ -71,7 +71,7 @@
[instant instant.Instant (:: instant.codec encode)]
[duration duration.Duration (:: duration.codec encode)]
[date date.Date (:: date.codec encode)]
- [cursor Cursor .cursor-description]
+ [location Location .location-description]
)
(def: #export (mod modular)
diff --git a/stdlib/source/lux/macro/code.lux b/stdlib/source/lux/macro/code.lux
index 3f7e5f970..7678852a6 100644
--- a/stdlib/source/lux/macro/code.lux
+++ b/stdlib/source/lux/macro/code.lux
@@ -28,14 +28,12 @@
## (#.Record (List [(w (Code' w)) (w (Code' w))])))
## (type: Code
-## (Ann Cursor (Code' (Ann Cursor))))
-
-(def: _cursor Cursor ["" 0 0])
+## (Ann Location (Code' (Ann Location))))
(template [<name> <type> <tag>]
[(def: #export (<name> x)
(-> <type> Code)
- [_cursor (<tag> x)])]
+ [.dummy-location (<tag> x)])]
[bit Bit #.Bit]
[nat Nat #.Nat]
@@ -54,7 +52,7 @@
[(def: #export (<name> name)
{#.doc <doc>}
(-> Text Code)
- [_cursor (<tag> ["" name])])]
+ [.dummy-location (<tag> ["" name])])]
[local-identifier #.Identifier "Produces a local identifier (an identifier with no module prefix)."]
[local-tag #.Tag "Produces a local tag (a tag with no module prefix)."])
@@ -143,16 +141,16 @@
substitute
(case ast
(^template [<tag>]
- [cursor (<tag> parts)]
- [cursor (<tag> (list@map (replace original substitute) parts))])
+ [location (<tag> parts)]
+ [location (<tag> (list@map (replace original substitute) parts))])
([#.Form]
[#.Tuple])
- [cursor (#.Record parts)]
- [cursor (#.Record (list@map (function (_ [left right])
- [(replace original substitute left)
- (replace original substitute right)])
- parts))]
+ [location (#.Record parts)]
+ [location (#.Record (list@map (function (_ [left right])
+ [(replace original substitute left)
+ (replace original substitute right)])
+ parts))]
_
ast)))
diff --git a/stdlib/source/lux/meta.lux b/stdlib/source/lux/meta.lux
index 4a05763ce..ec23805c5 100644
--- a/stdlib/source/lux/meta.lux
+++ b/stdlib/source/lux/meta.lux
@@ -548,11 +548,11 @@
_
(wrap #.None))))
-(def: #export cursor
- {#.doc "The cursor of the current expression being analyzed."}
- (Meta Cursor)
+(def: #export location
+ {#.doc "The location of the current expression being analyzed."}
+ (Meta Location)
(function (_ compiler)
- (#try.Success [compiler (get@ #.cursor compiler)])))
+ (#try.Success [compiler (get@ #.location compiler)])))
(def: #export expected-type
{#.doc "The expected type of the current expression being analyzed."}
@@ -682,9 +682,9 @@
#.None))
(#.Some [omit? token])
(do ..monad
- [cursor ..cursor
+ [location ..location
output (<func> token)
- #let [_ (log! ($_ text@compose (name@encode (name-of <macro>)) " @ " (.cursor-description cursor)))
+ #let [_ (log! ($_ text@compose (name@encode (name-of <macro>)) " @ " (.location-description location)))
_ (list@map (|>> code.to-text log!)
output)
_ (log! "")]]
diff --git a/stdlib/source/lux/target/js.lux b/stdlib/source/lux/target/js.lux
index 16a6d77da..bc4b3949d 100644
--- a/stdlib/source/lux/target/js.lux
+++ b/stdlib/source/lux/target/js.lux
@@ -1,5 +1,5 @@
(.module:
- [lux (#- Code or and function if cond undefined for comment not int)
+ [lux (#- Location Code or and function if cond undefined for comment not int)
[control
[pipe (#+ case>)]]
[data
diff --git a/stdlib/source/lux/tool/compiler/default/init.lux b/stdlib/source/lux/tool/compiler/default/init.lux
index f25f22035..ed4150b73 100644
--- a/stdlib/source/lux/tool/compiler/default/init.lux
+++ b/stdlib/source/lux/tool/compiler/default/init.lux
@@ -79,7 +79,7 @@
(type: Reader
(-> Source (Either [Source Text] [Source Code])))
-(def: (reader current-module aliases [cursor offset source-code])
+(def: (reader current-module aliases [location offset source-code])
(-> Module Aliases Source (///analysis.Operation Reader))
(function (_ [bundle state])
(#try.Success [[bundle state]
@@ -93,10 +93,10 @@
(#try.Failure error)
(#.Right [source' output])
- (let [[cursor _] output]
+ (let [[location _] output]
(#try.Success [[bundle (|> compiler
(set@ #.source source')
- (set@ #.cursor cursor))]
+ (set@ #.location location))]
[source' output]])))))
(type: (Operation a)
diff --git a/stdlib/source/lux/tool/compiler/language/lux/analysis.lux b/stdlib/source/lux/tool/compiler/language/lux/analysis.lux
index 598f34db5..96296a39a 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/analysis.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/analysis.lux
@@ -441,29 +441,29 @@
(set@ #.current-module)
(function.constant (#.Some name))))
-(def: #export (with-cursor cursor action)
- (All [a] (-> Cursor (Operation a) (Operation a)))
- (if (text@= "" (product.left cursor))
+(def: #export (with-location location action)
+ (All [a] (-> Location (Operation a) (Operation a)))
+ (if (text@= "" (product.left location))
action
(function (_ [bundle state])
- (let [old-cursor (get@ #.cursor state)]
- (case (action [bundle (set@ #.cursor cursor state)])
+ (let [old-location (get@ #.location state)]
+ (case (action [bundle (set@ #.location location state)])
(#try.Success [[bundle' state'] output])
- (#try.Success [[bundle' (set@ #.cursor old-cursor state')]
+ (#try.Success [[bundle' (set@ #.location old-location state')]
output])
(#try.Failure error)
(#try.Failure error))))))
-(def: (locate-error cursor error)
- (-> Cursor Text Text)
- (format "@ " (%.cursor cursor) text.new-line
+(def: (locate-error location error)
+ (-> Location Text Text)
+ (format "@ " (%.location location) text.new-line
error))
(def: #export (fail error)
(-> Text Operation)
(function (_ [bundle state])
- (#try.Failure (locate-error (get@ #.cursor state) error))))
+ (#try.Failure (locate-error (get@ #.location state) error))))
(def: #export (throw exception parameters)
(All [e] (-> (Exception e) e Operation))
@@ -478,7 +478,7 @@
(def: #export (fail' error)
(-> Text (phase.Operation Lux))
(function (_ state)
- (#try.Failure (locate-error (get@ #.cursor state) error))))
+ (#try.Failure (locate-error (get@ #.location state) error))))
(def: #export (throw' exception parameters)
(All [e] (-> (Exception e) e (phase.Operation Lux)))
@@ -494,7 +494,7 @@
(#try.Failure error)
(let [[bundle state] bundle,state]
- (#try.Failure (locate-error (get@ #.cursor state) error))))))
+ (#try.Failure (locate-error (get@ #.location state) error))))))
(def: #export (install state)
(-> .Lux (Operation Any))
@@ -507,22 +507,22 @@
(-> <type> (Operation Any))
(extension.update (set@ <field> <value>)))]
- [set-source-code Source #.source value]
- [set-current-module Text #.current-module (#.Some value)]
- [set-cursor Cursor #.cursor value]
+ [set-source-code Source #.source value]
+ [set-current-module Text #.current-module (#.Some value)]
+ [set-location Location #.location value]
)
-(def: #export (cursor file)
- (-> Text Cursor)
+(def: #export (location file)
+ (-> Text Location)
[file 1 0])
(def: #export (source file code)
(-> Text Text Source)
- [(cursor file) 0 code])
+ [(location file) 0 code])
(def: dummy-source
Source
- [.dummy-cursor 0 ""])
+ [.dummy-location 0 ""])
(def: type-context
Type-Context
@@ -540,7 +540,7 @@
(-> Info Lux)
{#.info info
#.source ..dummy-source
- #.cursor .dummy-cursor
+ #.location .dummy-location
#.current-module #.None
#.modules (list)
#.scopes (list)
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/analysis.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/analysis.lux
index 8ca459028..a5978fcba 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/analysis.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/analysis.lux
@@ -36,7 +36,7 @@
(-> a a))
(def: (compile|primitive else code')
- (Fix (-> (Code' (Ann Cursor)) (Operation Analysis)))
+ (Fix (-> (Code' (Ann Location)) (Operation Analysis)))
(case code'
(^template [<tag> <analyser>]
(<tag> value)
@@ -52,7 +52,7 @@
(else code')))
(def: (compile|structure archive compile else code')
- (-> Archive Phase (Fix (-> (Code' (Ann Cursor)) (Operation Analysis))))
+ (-> Archive Phase (Fix (-> (Code' (Ann Location)) (Operation Analysis))))
(case code'
(^ (#.Form (list& [_ (#.Tag tag)]
values)))
@@ -91,7 +91,7 @@
(else code')))
(def: (compile|others expander archive compile code')
- (-> Expander Archive Phase (-> (Code' (Ann Cursor)) (Operation Analysis)))
+ (-> Expander Archive Phase (-> (Code' (Ann Location)) (Operation Analysis)))
(case code'
(#.Identifier reference)
(/reference.reference reference)
@@ -128,15 +128,15 @@
(/function.apply compile argsC+ functionT functionA archive functionC)))
_
- (//.throw unrecognized-syntax [.dummy-cursor code'])))
+ (//.throw unrecognized-syntax [.dummy-location code'])))
(def: #export (phase expander)
(-> Expander Phase)
(function (compile archive code)
- (let [[cursor code'] code]
- ## The cursor must be set in the state for the sake
+ (let [[location code'] code]
+ ## The location must be set in the state for the sake
## of having useful error messages.
- (/.with-cursor cursor
+ (/.with-location location
(compile|primitive (compile|structure archive compile
(compile|others expander archive compile))
code')))))
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/analysis/case.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/analysis/case.lux
index 01afd6142..3c563d300 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/analysis/case.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/analysis/case.lux
@@ -131,9 +131,9 @@
_
(:: ///.monad wrap (re-quantify envs caseT)))))
-(def: (analyse-primitive type inputT cursor output next)
- (All [a] (-> Type Type Cursor Pattern (Operation a) (Operation [Pattern a])))
- (/.with-cursor cursor
+(def: (analyse-primitive type inputT location output next)
+ (All [a] (-> Type Type Location Pattern (Operation a) (Operation [Pattern a])))
+ (/.with-location location
(do ///.monad
[_ (//type.with-env
(check.check inputT type))
@@ -159,8 +159,8 @@
(def: (analyse-pattern num-tags inputT pattern next)
(All [a] (-> (Maybe Nat) Type Code (Operation a) (Operation [Pattern a])))
(.case pattern
- [cursor (#.Identifier ["" name])]
- (/.with-cursor cursor
+ [location (#.Identifier ["" name])]
+ (/.with-location location
(do ///.monad
[outputA (//scope.with-local [name inputT]
next)
@@ -168,8 +168,8 @@
(wrap [(#/.Bind idx) outputA])))
(^template [<type> <input> <output>]
- [cursor <input>]
- (analyse-primitive <type> inputT cursor (#/.Simple <output>) next))
+ [location <input>]
+ (analyse-primitive <type> inputT location (#/.Simple <output>) next))
([Bit (#.Bit pattern-value) (#/.Bit pattern-value)]
[Nat (#.Nat pattern-value) (#/.Nat pattern-value)]
[Int (#.Int pattern-value) (#/.Int pattern-value)]
@@ -178,11 +178,11 @@
[Text (#.Text pattern-value) (#/.Text pattern-value)]
[Any (#.Tuple #.Nil) #/.Unit])
- (^ [cursor (#.Tuple (list singleton))])
+ (^ [location (#.Tuple (list singleton))])
(analyse-pattern #.None inputT singleton next)
- [cursor (#.Tuple sub-patterns)]
- (/.with-cursor cursor
+ [location (#.Tuple sub-patterns)]
+ (/.with-location location
(do {@ ///.monad}
[inputT' (simplify-case inputT)]
(.case inputT'
@@ -222,7 +222,7 @@
(/.throw ..cannot-match-with-pattern [inputT' pattern])
)))
- [cursor (#.Record record)]
+ [location (#.Record record)]
(do ///.monad
[record (//structure.normalize record)
[members recordT] (//structure.order record)
@@ -233,14 +233,14 @@
_
(wrap []))]
- (analyse-pattern (#.Some (list.size members)) inputT [cursor (#.Tuple members)] next))
+ (analyse-pattern (#.Some (list.size members)) inputT [location (#.Tuple members)] next))
- [cursor (#.Tag tag)]
- (/.with-cursor cursor
+ [location (#.Tag tag)]
+ (/.with-location location
(analyse-pattern #.None inputT (` ((~ pattern))) next))
- (^ [cursor (#.Form (list& [_ (#.Nat lefts)] [_ (#.Bit right?)] values))])
- (/.with-cursor cursor
+ (^ [location (#.Form (list& [_ (#.Nat lefts)] [_ (#.Bit right?)] values))])
+ (/.with-location location
(do ///.monad
[inputT' (simplify-case inputT)]
(.case inputT'
@@ -278,8 +278,8 @@
_
(/.throw ..cannot-match-with-pattern [inputT' pattern]))))
- (^ [cursor (#.Form (list& [_ (#.Tag tag)] values))])
- (/.with-cursor cursor
+ (^ [location (#.Form (list& [_ (#.Tag tag)] values))])
+ (/.with-location location
(do ///.monad
[tag (///extension.lift (macro.normalize tag))
[idx group variantT] (///extension.lift (macro.resolve-tag tag))
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/analysis/inference.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/analysis/inference.lux
index 38f1d3bd3..bcde262d2 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/analysis/inference.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/analysis/inference.lux
@@ -86,17 +86,17 @@
_
type))
-(def: (named-type cursor id)
- (-> Cursor Nat Type)
- (let [name (format "{New Type @ " (.cursor-description cursor) " " (%.nat id) "}")]
+(def: (named-type location id)
+ (-> Location Nat Type)
+ (let [name (format "{New Type @ " (.location-description location) " " (%.nat id) "}")]
(#.Primitive name (list))))
(def: new-named-type
(Operation Type)
(do ///.monad
- [cursor (///extension.lift macro.cursor)
+ [location (///extension.lift macro.location)
[ex-id _] (//type.with-env check.existential)]
- (wrap (named-type cursor ex-id))))
+ (wrap (named-type location ex-id))))
## Type-inference works by applying some (potentially quantified) type
## to a sequence of values.
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/directive.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/directive.lux
index 988d599b7..55cd0d1b5 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/directive.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/directive.lux
@@ -34,7 +34,7 @@
(exception.report
["Name" (%.name name)]))
-(with-expansions [<lux_def_module> (as-is [|form-cursor| (#.Form (list& [|text-cursor| (#.Text "lux def module")] annotations))])]
+(with-expansions [<lux_def_module> (as-is [|form-location| (#.Form (list& [|text-location| (#.Text "lux def module")] annotations))])]
(def: #export (phase expander)
(-> Expander Phase)
(let [analyze (//analysis.phase expander)]
diff --git a/stdlib/source/lux/tool/compiler/language/lux/syntax.lux b/stdlib/source/lux/tool/compiler/language/lux/syntax.lux
index 8b6808a2c..eb85bc9ca 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/syntax.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/syntax.lux
@@ -8,20 +8,20 @@
## its position within the input data.
## That is, the parser takes into account the line and column
## information in the input text (it doesn't really touch the
-## file-name aspect of the cursor, leaving it intact in whatever
-## base-line cursor it is given).
+## file-name aspect of the location, leaving it intact in whatever
+## base-line location it is given).
## This particular piece of functionality is not located in one
## function, but it is instead scattered throughout several parsers,
-## since the logic for how to update the cursor varies, depending on
+## since the logic for how to update the location varies, depending on
## what is being parsed, and the rules involved.
## You will notice that several parsers have a "where" parameter, that
-## tells them the cursor position prior to the parser being run.
+## tells them the location position prior to the parser being run.
## They are supposed to produce some parsed output, alongside an
-## updated cursor pointing to the end position, after the parser was run.
+## updated location pointing to the end position, after the parser was run.
-## Lux Code nodes/tokens are annotated with cursor meta-data
+## Lux Code nodes/tokens are annotated with location meta-data
## [file-name, line, column] to keep track of their provenance and
## location, which is helpful for documentation and debugging.
(.module:
@@ -54,10 +54,10 @@
## TODO: Make an extension to take advantage of java/lang/String::indexOf<int,int>
## to get better performance than the current "lux text index" extension.
-## TODO: Instead of always keeping a "where" cursor variable, keep the
+## TODO: Instead of always keeping a "where" location variable, keep the
## individual components (i.e. file, line and column) separate, so
## that updated the "where" only involved updating the components, and
-## producing the cursors only involved building them, without any need
+## producing the locations only involved building them, without any need
## for pattern-matching and de-structuring.
(type: Char Nat)
@@ -137,7 +137,7 @@
(let [end (|> start (!n/+ amount-of-input-shown) (n.min ("lux text size" input)))]
(!clip start end input)))
-(exception: #export (unrecognized-input {[file line column] Cursor} {context Text} {input Text} {offset Offset})
+(exception: #export (unrecognized-input {[file line column] Location} {context Text} {input Text} {offset Offset})
(exception.report
["File" file]
["Line" (%.nat line)]
@@ -184,12 +184,12 @@
source-code])
(template: (!new-line where)
- ## (-> Cursor Cursor)
+ ## (-> Location Location)
(let [[where::file where::line where::column] where]
[where::file (!inc where::line) 0]))
(template: (!forward length where)
- ## (-> Nat Cursor Cursor)
+ ## (-> Nat Location Location)
(let [[where::file where::line where::column] where]
[where::file where::line (!n/+ length where::column)]))
@@ -251,7 +251,7 @@
(exception.construct ..text-cannot-contain-new-lines content)])))
(def: (parse-text where offset source-code)
- (-> Cursor Nat Text (Either [Source Text] [Source Code]))
+ (-> Location Nat Text (Either [Source Text] [Source Code]))
(case ("lux text index" offset (static ..text-delimiter) source-code)
(#.Some g!end)
(let [g!content (!clip offset g!end source-code)]
@@ -361,7 +361,7 @@
(template [<parser> <codec> <tag>]
[(def: (<parser> source-code//size start where offset source-code)
- (-> Nat Nat Cursor Nat Text (Either [Source Text] [Source Code]))
+ (-> Nat Nat Location Nat Text (Either [Source Text] [Source Code]))
(loop [g!end offset]
(<| (!with-char+ source-code//size source-code g!end g!char (!number-output start g!end <codec> <tag>))
(if (!digit?+ g!char)
diff --git a/stdlib/source/lux/type.lux b/stdlib/source/lux/type.lux
index ed0dc3ce9..f7170adc4 100644
--- a/stdlib/source/lux/type.lux
+++ b/stdlib/source/lux/type.lux
@@ -358,10 +358,10 @@
(case input
(#.Left valueN)
(do meta.monad
- [cursor meta.cursor
+ [location meta.location
valueT (meta.find-type valueN)
#let [_ (log! ($_ text@compose
- (name@encode (name-of ..:log!)) " @ " (.cursor-description cursor) text.new-line
+ (name@encode (name-of ..:log!)) " @ " (.location-description location) text.new-line
"Value: " (name@encode valueN) text.new-line
" Type: " (..to-text valueT) text.new-line))]]
(wrap (list (code.identifier valueN))))
@@ -419,13 +419,13 @@
{(~ extraction)
(:assume [])}))))))
-(exception: #export (hole-type {location Cursor} {type Type})
+(exception: #export (hole-type {location Location} {type Type})
(exception.report
- ["Location" (.cursor-description location)]
+ ["Location" (.location-description location)]
["Type" (..to-text type)]))
(syntax: #export (:hole)
(do meta.monad
- [cursor meta.cursor
+ [location meta.location
expectedT meta.expected-type]
- (meta.fail (exception.construct ..hole-type [cursor expectedT]))))
+ (meta.fail (exception.construct ..hole-type [location expectedT]))))
diff --git a/stdlib/source/test/aedifex/parser.lux b/stdlib/source/test/aedifex/parser.lux
index 497533fbf..97895a201 100644
--- a/stdlib/source/test/aedifex/parser.lux
+++ b/stdlib/source/test/aedifex/parser.lux
@@ -205,7 +205,9 @@
(def: #export test
Test
(<| (_.covering /._)
- (_.with-cover [/.project]
+ (_.covering //format._)
+ (_.with-cover [/.project
+ //format.Format //format.profile //format.project]
($_ _.and
..single-profile
..multiple-profiles
diff --git a/stdlib/source/test/lux/control/parser/binary.lux b/stdlib/source/test/lux/control/parser/binary.lux
index 8bc24976e..11875d19f 100644
--- a/stdlib/source/test/lux/control/parser/binary.lux
+++ b/stdlib/source/test/lux/control/parser/binary.lux
@@ -69,8 +69,8 @@
(Random Name)
(random.and ..random-text ..random-text))
-(structure: cursor-equivalence
- (Equivalence Cursor)
+(structure: location-equivalence
+ (Equivalence Location)
(def: (= [expected-module expected-line expected-column]
[sample-module sample-line sample-column])
@@ -78,8 +78,8 @@
(n.= expected-line sample-line)
(n.= expected-column sample-column))))
-(def: random-cursor
- (Random Cursor)
+(def: random-location
+ (Random Location)
($_ random.and
..random-text
random.nat
@@ -93,8 +93,8 @@
[size (:: @ map (n.% 2) random.nat)]
(random.list size recur))]
($_ random.and
- ..random-cursor
- (: (Random (Code' (Ann Cursor)))
+ ..random-location
+ (: (Random (Code' (Ann Location)))
($_ random.or
random.bit
random.nat
@@ -240,7 +240,7 @@
(!expect (^multi (#try.Success actual)
(:: <equivalence> = expected actual))))))]
- [/.cursor format.cursor random-cursor cursor-equivalence]
+ [/.location format.location random-location location-equivalence]
[/.code format.code random-code code.equivalence]
[/.type format.type random-type type.equivalence]
))
diff --git a/stdlib/source/test/lux/data/lazy.lux b/stdlib/source/test/lux/data/lazy.lux
index b31953a9f..440aa0316 100644
--- a/stdlib/source/test/lux/data/lazy.lux
+++ b/stdlib/source/test/lux/data/lazy.lux
@@ -10,11 +10,10 @@
["$." monad]
["$." equivalence]]}]
[data
- ["%" text/format (#+ format)]
[number
["n" nat]]]
[math
- ["r" random (#+ Random)]]]
+ ["." random (#+ Random)]]]
{1
["." / (#+ Lazy)]})
@@ -29,28 +28,35 @@
(def: #export lazy
(All [a] (-> (Random a) (Random (Lazy a))))
- (:: r.functor map (|>> /.freeze)))
+ (:: random.functor map (|>> /.freeze)))
(def: #export test
Test
- (<| (_.context (%.name (name-of /.Lazy)))
- (do r.monad
- [left r.nat
- right r.nat
- #let [lazy (/.freeze (n.* left right))
- expected (n.* left right)]]
- ($_ _.and
- ($equivalence.spec (/.equivalence n.equivalence) (..lazy r.nat))
- ($functor.spec ..injection ..comparison /.functor)
- ($apply.spec ..injection ..comparison /.apply)
- ($monad.spec ..injection ..comparison /.monad)
+ (<| (_.covering /._)
+ (do random.monad
+ [left random.nat
+ right random.nat
+ #let [expected (n.* left right)]]
+ (_.with-cover [/.Lazy]
+ ($_ _.and
+ (_.with-cover [/.equivalence]
+ ($equivalence.spec (/.equivalence n.equivalence) (..lazy random.nat)))
+ (_.with-cover [/.functor]
+ ($functor.spec ..injection ..comparison /.functor))
+ (_.with-cover [/.apply]
+ ($apply.spec ..injection ..comparison /.apply))
+ (_.with-cover [/.monad]
+ ($monad.spec ..injection ..comparison /.monad))
- (_.test "Freezing does not alter the expected value."
- (n.= expected
- (/.thaw lazy)))
- (_.test "Lazy values only evaluate once."
- (and (not (is? expected
- (/.thaw lazy)))
- (is? (/.thaw lazy)
+ (_.cover [/.freeze]
+ (let [lazy (/.freeze (n.* left right))]
+ (n.= expected
(/.thaw lazy))))
- ))))
+
+ (_.cover [/.thaw]
+ (let [lazy (/.freeze (n.* left right))]
+ (and (not (is? expected
+ (/.thaw lazy)))
+ (is? (/.thaw lazy)
+ (/.thaw lazy)))))
+ )))))
diff --git a/stdlib/source/test/lux/data/maybe.lux b/stdlib/source/test/lux/data/maybe.lux
index a10e0154e..24114f6c0 100644
--- a/stdlib/source/test/lux/data/maybe.lux
+++ b/stdlib/source/test/lux/data/maybe.lux
@@ -6,6 +6,7 @@
{[0 #spec]
[/
["$." equivalence]
+ ["$." monoid]
["$." functor]
["$." apply]
["$." monad]]}]
@@ -13,58 +14,64 @@
["." io ("#@." monad)]
pipe]
[data
- ["." text
- ["%" format (#+ format)]]
+ ["." text]
[number
- ["n" nat]]]
+ ["n" nat]]
+ [collection
+ ["." list]]]
[math
- ["r" random (#+ Random)]]]
+ ["." random (#+ Random)]]]
{1
["." / ("#@." monoid monad)]})
-(def: #export maybe
- (All [a] (-> (Random a) (Random (Maybe a))))
- (:: r.functor map (|>> #.Some)))
-
(def: #export test
Test
- (<| (_.context (%.name (name-of .Maybe)))
- ($_ _.and
- ($equivalence.spec (/.equivalence n.equivalence) (..maybe r.nat))
- ($functor.spec /@wrap /.equivalence /.functor)
- ($apply.spec /@wrap /.equivalence /.apply)
- ($monad.spec /@wrap /.equivalence /.monad)
-
- (do r.monad
- [left r.nat
- right r.nat
- #let [expected (n.+ left right)]]
- (let [lift (/.lift io.monad)]
- (_.test "Can add maybe functionality to any monad."
- (|> (io.run (do (/.with io.monad)
- [a (lift (io@wrap left))
- b (wrap right)]
- (wrap (n.+ a b))))
- (case> (#.Some actual)
- (n.= expected actual)
+ (<| (_.covering /._)
+ (_.with-cover [.Maybe]
+ ($_ _.and
+ (_.with-cover [/.equivalence]
+ ($equivalence.spec (/.equivalence n.equivalence) (random.maybe random.nat)))
+ (_.with-cover [/.monoid]
+ ($monoid.spec (/.equivalence n.equivalence) /.monoid (random.maybe random.nat)))
+ (_.with-cover [/.functor]
+ ($functor.spec /@wrap /.equivalence /.functor))
+ (_.with-cover [/.apply]
+ ($apply.spec /@wrap /.equivalence /.apply))
+ (_.with-cover [/.monad]
+ ($monad.spec /@wrap /.equivalence /.monad))
+
+ (do random.monad
+ [left random.nat
+ right random.nat
+ #let [expected (n.+ left right)]]
+ (let [lift (/.lift io.monad)]
+ (_.cover [/.with /.lift]
+ (|> (io.run (do (/.with io.monad)
+ [a (lift (io@wrap left))
+ b (wrap right)]
+ (wrap (n.+ a b))))
+ (case> (#.Some actual)
+ (n.= expected actual)
- _
- false)))))
- (let [(^open "/@.") (/.equivalence text.equivalence)
- (^open "/@.") /.monoid]
- (_.test "Monoid respects Maybe."
- (and (/@= #.None /@identity)
- (/@= (#.Some "yolo") (/@compose (#.Some "yolo") (#.Some "lol")))
- (/@= (#.Some "yolo") (/@compose (#.Some "yolo") #.None))
- (/@= (#.Some "lol") (/@compose #.None (#.Some "lol")))
- (/@= #.None (: (Maybe Text) (/@compose #.None #.None))))))
- (do r.monad
- [default r.nat
- value r.nat]
- (_.test "Can have defaults for Maybe values."
- (and (is? default (/.default default
- #.None))
+ _
+ false)))))
+ (do random.monad
+ [default random.nat
+ value random.nat]
+ (_.cover [/.default]
+ (and (is? default (/.default default
+ #.None))
- (is? value (/.default default
- (#.Some value))))))
- )))
+ (is? value (/.default default
+ (#.Some value))))))
+ (do random.monad
+ [value random.nat]
+ (_.cover [/.assume]
+ (is? value (/.assume (#.Some value)))))
+ (do random.monad
+ [value random.nat]
+ (_.cover [/.to-list]
+ (:: (list.equivalence n.equivalence) =
+ (list value)
+ (/.to-list (#.Some value)))))
+ ))))
diff --git a/stdlib/source/test/lux/macro/code.lux b/stdlib/source/test/lux/macro/code.lux
index 0cdbc9610..eec419644 100644
--- a/stdlib/source/test/lux/macro/code.lux
+++ b/stdlib/source/test/lux/macro/code.lux
@@ -69,7 +69,7 @@
syntax.no-aliases
(text.size source-code))
start (: Source
- [.dummy-cursor 0 source-code])]
+ [.dummy-location 0 source-code])]
(case (parse start)
(#.Left [end error])
(#try.Failure error)
@@ -132,7 +132,7 @@
(#try.Failure error)
false)
(:: /.equivalence =
- [.dummy-cursor (<tag> expected)]
+ [.dummy-location (<tag> expected)]
(<coverage> expected)))))]
[/.bit random.bit #.Bit]
@@ -159,7 +159,7 @@
(#try.Failure error)
false)
(:: /.equivalence =
- [.dummy-cursor (<tag> ["" expected])]
+ [.dummy-location (<tag> ["" expected])]
(<coverage> expected)))
))]
diff --git a/stdlib/source/test/lux/meta.lux b/stdlib/source/test/lux/meta.lux
index ec400d5e3..1f5e2c5fa 100644
--- a/stdlib/source/test/lux/meta.lux
+++ b/stdlib/source/test/lux/meta.lux
@@ -46,8 +46,8 @@
#let [expected-lux {#.info {#.target target
#.version version
#.mode #.Build}
- #.source [..dummy-cursor 0 source-code]
- #.cursor ..dummy-cursor
+ #.source [.dummy-location 0 source-code]
+ #.location .dummy-location
#.current-module (#.Some expected-current-module)
#.modules (list)
#.scopes (list)
@@ -93,8 +93,8 @@
#let [expected-lux {#.info {#.target target
#.version version
#.mode #.Build}
- #.source [..dummy-cursor 0 source-code]
- #.cursor ..dummy-cursor
+ #.source [.dummy-location 0 source-code]
+ #.location .dummy-location
#.current-module (#.Some expected-current-module)
#.modules (list)
#.scopes (list)
@@ -167,8 +167,8 @@
#let [expected-lux {#.info {#.target target
#.version version
#.mode #.Build}
- #.source [..dummy-cursor 0 source-code]
- #.cursor ..dummy-cursor
+ #.source [.dummy-location 0 source-code]
+ #.location .dummy-location
#.current-module (#.Some expected-current-module)
#.modules (list)
#.scopes (list)
@@ -199,8 +199,8 @@
(is? expected-short actual-short)))))))
)))
-(def: random-cursor
- (Random Cursor)
+(def: random-location
+ (Random Location)
($_ random.and
(random.ascii/upper-alpha 1)
random.nat
@@ -241,12 +241,12 @@
dummy-module (random.filter (|>> (text@= expected-current-module) not)
(random.ascii/upper-alpha 1))
expected-gensym (random.ascii/upper-alpha 1)
- expected-cursor ..random-cursor
+ expected-location ..random-location
#let [expected-lux {#.info {#.target target
#.version version
#.mode #.Build}
- #.source [.dummy-cursor 0 source-code]
- #.cursor expected-cursor
+ #.source [.dummy-location 0 source-code]
+ #.location expected-location
#.current-module (#.Some expected-current-module)
#.modules (list)
#.scopes (list)
@@ -285,11 +285,11 @@
(!expect (^multi (#try.Success actual-gensym)
(and (text.contains? expected-gensym actual-gensym)
(text.contains? (%.nat expected-seed) actual-gensym))))))
- (_.cover [/.cursor]
- (|> /.cursor
+ (_.cover [/.location]
+ (|> /.location
(/.run expected-lux)
- (!expect (^multi (#try.Success actual-cursor)
- (is? expected-cursor actual-cursor)))))
+ (!expect (^multi (#try.Success actual-location)
+ (is? expected-location actual-location)))))
(_.cover [/.expected-type]
(|> /.expected-type
(/.run expected-lux)
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/syntax.lux b/stdlib/source/test/lux/tool/compiler/language/lux/syntax.lux
index 103dc069e..c6ac62bc5 100644
--- a/stdlib/source/test/lux/tool/compiler/language/lux/syntax.lux
+++ b/stdlib/source/test/lux/tool/compiler/language/lux/syntax.lux
@@ -22,12 +22,6 @@
{1
["." /]})
-(def: default-cursor
- Cursor
- {#.module ""
- #.line 0
- #.column 0})
-
(def: name-part^
(Random Text)
(do {@ r.monad}
@@ -83,7 +77,7 @@
(_.test "Can parse Lux code."
(case (let [source-code (%.code sample)]
(/.parse "" (dictionary.new text.hash) (text.size source-code)
- [default-cursor 0 source-code]))
+ [.dummy-location 0 source-code]))
(#.Left error)
false
@@ -95,7 +89,7 @@
(let [source-code (format (%.code sample) " " (%.code other))
source-code//size (text.size source-code)]
(case (/.parse "" (dictionary.new text.hash) source-code//size
- [default-cursor 0 source-code])
+ [.dummy-location 0 source-code])
(#.Left error)
false
@@ -133,7 +127,7 @@
(case (let [source-code (format comment (%.code sample))
source-code//size (text.size source-code)]
(/.parse "" (dictionary.new text.hash) source-code//size
- [default-cursor 0 source-code]))
+ [.dummy-location 0 source-code]))
(#.Left error)
false