aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
authorEduardo Julian2017-12-04 18:51:25 -0400
committerEduardo Julian2017-12-04 18:51:25 -0400
commit880b1a68c0b92a9271ebe028202dd9d71e8e69c6 (patch)
tree4c52113628ca11a727a969c4f5bdca0d9903b9b6 /stdlib/source
parent07af667db0ca6b831cf6e24ba6bc288886c95dd8 (diff)
- Re-named "Def" to "Definition".
Diffstat (limited to 'stdlib/source')
-rw-r--r--stdlib/source/lux.lux74
-rw-r--r--stdlib/source/lux/macro.lux22
-rw-r--r--stdlib/source/lux/macro/syntax/common.lux2
-rw-r--r--stdlib/source/lux/macro/syntax/common/reader.lux12
-rw-r--r--stdlib/source/lux/macro/syntax/common/writer.lux4
-rw-r--r--stdlib/source/lux/type/abstract.lux56
-rw-r--r--stdlib/source/lux/type/implicit.lux36
7 files changed, 103 insertions, 103 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux
index cdfe0e313..17eb44933 100644
--- a/stdlib/source/lux.lux
+++ b/stdlib/source/lux.lux
@@ -484,10 +484,10 @@
#Nil))
(record$ #Nil))
-## (type: Def
+## (type: Definition
## [Type Code Top])
-("lux def" Def
- (#Named ["lux" "Def"]
+("lux def" Definition
+ (#Named ["lux" "Definition"]
(#Product Type (#Product Code Top)))
(record$ (#Cons [(tag$ ["lux" "doc"])
(text$ "Represents all the data associated with a definition: its type, its annotations, and its value.")]
@@ -595,11 +595,11 @@
## (type: Module
## {#module-hash Nat
## #module-aliases (List [Text Text])
-## #defs (List [Text Def])
+## #definitions (List [Text Definition])
## #imports (List Text)
## #tags (List [Text [Nat (List Ident) Bool Type]])
## #types (List [Text [(List Ident) Bool Type]])
-## #module-anns (Maybe Anns)
+## #module-anns (Maybe Code)
## #module-state Module-State})
("lux def" Module
(#Named ["lux" "Module"]
@@ -607,8 +607,8 @@
Nat
(#Product ## "lux.module-aliases"
(#Apply (#Product Text Text) List)
- (#Product ## "lux.defs"
- (#Apply (#Product Text Def) List)
+ (#Product ## "lux.definitions"
+ (#Apply (#Product Text Definition) List)
(#Product ## "lux.imports"
(#Apply Text List)
(#Product ## "lux.tags"
@@ -631,7 +631,7 @@
(record$ (#Cons [(tag$ ["lux" "tags"])
(tuple$ (#Cons (text$ "module-hash")
(#Cons (text$ "module-aliases")
- (#Cons (text$ "defs")
+ (#Cons (text$ "definitions")
(#Cons (text$ "imports")
(#Cons (text$ "tags")
(#Cons (text$ "types")
@@ -1811,8 +1811,8 @@
#seed seed #expected expected #cursor cursor
#scope-type-vars scope-type-vars} state]
("lux case" (get module modules)
- {(#Some {#module-hash _ #module-aliases _ #defs defs #imports _ #tags tags #types types #module-annotations _ #module-state _})
- ("lux case" (get name defs)
+ {(#Some {#module-hash _ #module-aliases _ #definitions definitions #imports _ #tags tags #types types #module-annotations _ #module-state _})
+ ("lux case" (get name definitions)
{(#Some [def-type def-meta def-value])
("lux case" (get-meta ["lux" "alias"] def-meta)
{(#Some [_ (#Symbol real-name)])
@@ -2419,9 +2419,9 @@
($' Maybe Macro))
(do Monad<Maybe>
[$module (get module modules)
- gdef (let' [{#module-hash _ #module-aliases _ #defs bindings #imports _ #tags tags #types types #module-annotations _ #module-state _} ("lux check" Module $module)]
+ gdef (let' [{#module-hash _ #module-aliases _ #definitions bindings #imports _ #tags tags #types types #module-annotations _ #module-state _} ("lux check" Module $module)]
(get name bindings))]
- (let' [[def-type def-meta def-value] ("lux check" Def gdef)]
+ (let' [[def-type def-meta def-value] ("lux check" Definition gdef)]
("lux case" (get-meta ["lux" "macro?"] def-meta)
{(#Some [_ (#Bool true)])
("lux case" (get-meta ["lux" "export?"] def-meta)
@@ -3594,7 +3594,7 @@
(-> Ident (Meta [Nat (List Ident) Bool Type]))
(do Monad<Meta>
[=module (find-module module)
- #let [{#module-hash _ #module-aliases _ #defs bindings #imports _ #tags tags-table #types types #module-annotations _ #module-state _} =module]]
+ #let [{#module-hash _ #module-aliases _ #definitions bindings #imports _ #tags tags-table #types types #module-annotations _ #module-state _} =module]]
(case (get name tags-table)
(#Some output)
(return output)
@@ -3617,7 +3617,7 @@
(#Named [module name] unnamed)
(do Monad<Meta>
[=module (find-module module)
- #let [{#module-hash _ #module-aliases _ #defs bindings #imports _ #tags tags #types types #module-annotations _ #module-state _} =module]]
+ #let [{#module-hash _ #module-aliases _ #definitions bindings #imports _ #tags tags #types types #module-annotations _ #module-state _} =module]]
(case (get name types)
(#Some [tags exported? (#Named _ _type)])
(case (resolve-struct-type _type)
@@ -3701,22 +3701,22 @@
(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 defs))
- (#Some name args type [meta-rec-cursor (#Record meta-rec-parts)] defs)
+ (^ (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& name [meta-rec-cursor (#Record meta-rec-parts)] type defs))
- (#Some name #Nil type [meta-rec-cursor (#Record meta-rec-parts)] defs)
+ (^ (list& name [meta-rec-cursor (#Record meta-rec-parts)] type definitions))
+ (#Some name #Nil type [meta-rec-cursor (#Record meta-rec-parts)] definitions)
- (^ (list& [_ (#Form (list& name args))] type defs))
- (#Some name args type (` {}) defs)
+ (^ (list& [_ (#Form (list& name args))] type definitions))
+ (#Some name args type (` {}) definitions)
- (^ (list& name type defs))
- (#Some name #Nil type (` {}) defs)
+ (^ (list& name type definitions))
+ (#Some name #Nil type (` {}) definitions)
_
#None))]
(case ?parts
- (#Some [name args type meta defs])
+ (#Some [name args type meta definitions])
(case (case name
[_ (#Symbol ["" "_"])]
(case type
@@ -3754,7 +3754,7 @@
(~ (meta-code-merge (` {#.struct? true})
meta))
(~ type)
- (struct (~+ defs)))))))
+ (struct (~+ definitions)))))))
#None
(fail "Cannot infer name, so struct must have a name other than \"_\"!"))
@@ -4160,7 +4160,7 @@
imports)]
(wrap (list/join imports'))))
-(def: (exported-defs module state)
+(def: (exported-definitions module state)
(-> Text (Meta (List Text)))
(let [modules (case state
{#info info #source source #current-module _ #modules modules
@@ -4170,7 +4170,7 @@
modules)]
(case (get module modules)
(#Some =module)
- (let [to-alias (list/map (: (-> [Text Def]
+ (let [to-alias (list/map (: (-> [Text Definition]
(List Text))
(function [[name [def-type def-meta def-value]]]
(case (get-meta ["lux" "export?"] def-meta)
@@ -4179,8 +4179,8 @@
_
(list))))
- (let [{#module-hash _ #module-aliases _ #defs defs #imports _ #tags tags #types types #module-annotations _ #module-state _} =module]
- defs))]
+ (let [{#module-hash _ #module-aliases _ #definitions definitions #imports _ #tags tags #types types #module-annotations _ #module-state _} =module]
+ definitions))]
(#Right state (list/join to-alias)))
#None
@@ -4248,8 +4248,8 @@
#None
#None
- (#Some {#defs defs #module-hash _ #module-aliases _ #imports _ #tags tags #types types #module-annotations _ #module-state _})
- (case (get v-name defs)
+ (#Some {#definitions definitions #module-hash _ #module-aliases _ #imports _ #tags tags #types types #module-annotations _ #module-state _})
+ (case (get v-name definitions)
#None
#None
@@ -4267,8 +4267,8 @@
#None
(#Left (text/compose "Unknown definition: " (ident/encode name)))
- (#Some {#defs defs #module-hash _ #module-aliases _ #imports _ #tags tags #types types #module-annotations _ #module-state _})
- (case (get v-name defs)
+ (#Some {#definitions definitions #module-hash _ #module-aliases _ #imports _ #tags tags #types types #module-annotations _ #module-state _})
+ (case (get v-name definitions)
#None
(#Left (text/compose "Unknown definition: " (ident/encode name)))
@@ -4612,7 +4612,7 @@
(-> Text Text (Meta Bool))
(do Monad<Meta>
[module (find-module module-name)
- #let [{#module-hash _ #module-aliases _ #defs _ #imports imports #tags _ #types _ #module-annotations _ #module-state _} module]]
+ #let [{#module-hash _ #module-aliases _ #definitions _ #imports imports #tags _ #types _ #module-annotations _ #module-state _} module]]
(wrap (is-member? imports import-name))))
(def: (read-refer module-name options)
@@ -4659,17 +4659,17 @@
referred-defs)))]
defs' (case r-defs
#All
- (exported-defs module-name)
+ (exported-definitions module-name)
(#Only +defs)
(do Monad<Meta>
- [*defs (exported-defs module-name)
+ [*defs (exported-definitions module-name)
_ (test-referrals module-name *defs +defs)]
(wrap +defs))
(#Exclude -defs)
(do Monad<Meta>
- [*defs (exported-defs module-name)
+ [*defs (exported-definitions module-name)
_ (test-referrals module-name *defs -defs)]
(wrap (filter (|>> (is-member? -defs) not) *defs)))
@@ -5501,7 +5501,7 @@
))
(macro: #export (^~ tokens)
- {#.doc (doc "Use global defs with simple values, such as text, int, frac and bool in place of literals in patterns."
+ {#.doc (doc "Use global definitions with simple values, such as text, int, frac and bool in place of literals in patterns."
"The definitions must be properly-qualified (though you may use one of the short-cuts Lux provides)."
(def: (empty?' node)
(All [K V] (-> (Node K V) Bool))
diff --git a/stdlib/source/lux/macro.lux b/stdlib/source/lux/macro.lux
index aa2429ae7..b32fc0aa1 100644
--- a/stdlib/source/lux/macro.lux
+++ b/stdlib/source/lux/macro.lux
@@ -247,7 +247,7 @@
(Maybe Macro))
(do maybe.Monad<Maybe>
[$module (get module modules)
- [def-type def-anns def-value] (: (Maybe Def) (|> (: Module $module) (get@ #.defs) (get name)))]
+ [def-type def-anns def-value] (: (Maybe Definition) (|> (: Module $module) (get@ #.definitions) (get name)))]
(if (and (macro? def-anns)
(or (export? def-anns) (text/= module this-module)))
(#.Some (:! Macro def-value))
@@ -454,15 +454,15 @@
(def: #export (find-def name)
{#.doc "Looks-up a definition's whole data in the available modules (including the current one)."}
- (-> Ident (Meta Def))
+ (-> Ident (Meta Definition))
(do Monad<Meta>
[name (normalize name)]
(function [compiler]
- (case (: (Maybe Def)
+ (case (: (Maybe Definition)
(do maybe.Monad<Maybe>
[#let [[v-prefix v-name] name]
- (^slots [#.defs]) (get v-prefix (get@ #.modules compiler))]
- (get v-name defs)))
+ (^slots [#.definitions]) (get v-prefix (get@ #.modules compiler))]
+ (get v-name definitions)))
(#.Some definition)
(#e.Success [compiler definition])
@@ -508,23 +508,23 @@
[[def-type def-data def-value] (find-def name)]
(wrap (:! Type def-value))))
-(def: #export (defs module-name)
+(def: #export (definitions module-name)
{#.doc "The entire list of definitions in a module (including the unexported/private ones)."}
- (-> Text (Meta (List [Text Def])))
+ (-> Text (Meta (List [Text Definition])))
(function [compiler]
(case (get module-name (get@ #.modules compiler))
#.None (#e.Error ($_ text/compose "Unknown module: " module-name))
- (#.Some module) (#e.Success [compiler (get@ #.defs module)])
+ (#.Some module) (#e.Success [compiler (get@ #.definitions module)])
)))
(def: #export (exports module-name)
{#.doc "All the exported definitions in a module."}
- (-> Text (Meta (List [Text Def])))
+ (-> Text (Meta (List [Text Definition])))
(do Monad<Meta>
- [defs (defs module-name)]
+ [definitions (definitions module-name)]
(wrap (list.filter (function [[name [def-type def-anns def-value]]]
(export? def-anns))
- defs))))
+ definitions))))
(def: #export modules
{#.doc "All the available modules (including the current one)."}
diff --git a/stdlib/source/lux/macro/syntax/common.lux b/stdlib/source/lux/macro/syntax/common.lux
index 9de36fe5d..fa3d975db 100644
--- a/stdlib/source/lux/macro/syntax/common.lux
+++ b/stdlib/source/lux/macro/syntax/common.lux
@@ -1,7 +1,7 @@
(.module: {#.doc "Commons syntax readers and writers.
The goal is to be able to reuse common syntax in macro definitions across libraries."}
- lux)
+ [lux #- Definition])
(type: #export Declaration
{#declaration-name Text
diff --git a/stdlib/source/lux/macro/syntax/common/reader.lux b/stdlib/source/lux/macro/syntax/common/reader.lux
index 0e8b5df9a..bb2e128e6 100644
--- a/stdlib/source/lux/macro/syntax/common/reader.lux
+++ b/stdlib/source/lux/macro/syntax/common/reader.lux
@@ -8,7 +8,7 @@
[maybe])
[macro]
(macro ["s" syntax #+ syntax: Syntax]))
- [// #*])
+ [//])
## Exports
(def: #export export
@@ -22,7 +22,7 @@
"Such as:"
quux
(foo bar baz))}
- (Syntax Declaration)
+ (Syntax //.Declaration)
(p.either (p.seq s.local-symbol
(p/wrap (list)))
(s.form (p.seq s.local-symbol
@@ -31,7 +31,7 @@
## Annotations
(def: #export annotations
{#.doc "Reader for the common annotations syntax used by def: statements."}
- (Syntax Annotations)
+ (Syntax //.Annotations)
(s.record (p.some (p.seq s.tag s.any))))
## Definitions
@@ -50,7 +50,7 @@
(s.tuple (p.seq s.text s.text)))
(def: (_definition-anns^ _)
- (-> Top (Syntax Annotations))
+ (-> Top (Syntax //.Annotations))
(p.alt (s.this (' #.Nil))
(s.form (do p.Monad<Parser>
[_ (s.this (' #.Cons))
@@ -101,7 +101,7 @@
(def: #export (definition compiler)
{#.doc "A reader that first macro-expands and then analyses the input Code, to ensure it's a definition."}
- (-> Compiler (Syntax Definition))
+ (-> Compiler (Syntax //.Definition))
(do p.Monad<Parser>
[definition-raw s.any
me-definition-raw (s.on compiler
@@ -123,7 +123,7 @@
(def: #export (typed-definition compiler)
{#.doc "A reader for definitions that ensures the input syntax is typed."}
- (-> Compiler (Syntax Definition))
+ (-> Compiler (Syntax //.Definition))
(do p.Monad<Parser>
[_definition (definition compiler)
_ (case (get@ #//.definition-type _definition)
diff --git a/stdlib/source/lux/macro/syntax/common/writer.lux b/stdlib/source/lux/macro/syntax/common/writer.lux
index 5b5ab9ab5..34f911842 100644
--- a/stdlib/source/lux/macro/syntax/common/writer.lux
+++ b/stdlib/source/lux/macro/syntax/common/writer.lux
@@ -3,7 +3,7 @@
(lux (data (coll [list "list/" Functor<List>])
[product])
(macro [code]))
- [// #*])
+ [//])
## Exports
(def: #export (export exported?)
@@ -14,5 +14,5 @@
## Annotations
(def: #export (annotations anns)
- (-> Annotations Code)
+ (-> //.Annotations Code)
(|> anns (list/map (product.both code.tag id)) code.record))
diff --git a/stdlib/source/lux/type/abstract.lux b/stdlib/source/lux/type/abstract.lux
index cf6f1b4e4..9a991a2a9 100644
--- a/stdlib/source/lux/type/abstract.lux
+++ b/stdlib/source/lux/type/abstract.lux
@@ -66,32 +66,32 @@
abstract-declaration (` ((~ (code.local-symbol name)) (~+ type-varsC)))
representation-declaration (` ((~ (code.local-symbol (representation-name name))) (~+ type-varsC)))
this-module (|> this-module
- (update@ #.defs (put down-cast (: Def
- [Macro macro-anns
- (: Macro
- (function [tokens]
- (case tokens
- (^ (list value))
- (wrap (list (` ((: (All [(~+ type-varsC)]
- (-> (~ representation-declaration) (~ abstract-declaration)))
- (|>> :!!))
- (~ value)))))
-
- _
- (macro.fail ($_ text/compose "Wrong syntax for " down-cast)))))])))
- (update@ #.defs (put up-cast (: Def
- [Macro macro-anns
- (: Macro
- (function [tokens]
- (case tokens
- (^ (list value))
- (wrap (list (` ((: (All [(~+ type-varsC)]
- (-> (~ abstract-declaration) (~ representation-declaration)))
- (|>> :!!))
- (~ value)))))
-
- _
- (macro.fail ($_ text/compose "Wrong syntax for " up-cast)))))]))))]]
+ (update@ #.definitions (put down-cast (: Definition
+ [Macro macro-anns
+ (: Macro
+ (function [tokens]
+ (case tokens
+ (^ (list value))
+ (wrap (list (` ((: (All [(~+ type-varsC)]
+ (-> (~ representation-declaration) (~ abstract-declaration)))
+ (|>> :!!))
+ (~ value)))))
+
+ _
+ (macro.fail ($_ text/compose "Wrong syntax for " down-cast)))))])))
+ (update@ #.definitions (put up-cast (: Definition
+ [Macro macro-anns
+ (: Macro
+ (function [tokens]
+ (case tokens
+ (^ (list value))
+ (wrap (list (` ((: (All [(~+ type-varsC)]
+ (-> (~ abstract-declaration) (~ representation-declaration)))
+ (|>> :!!))
+ (~ value)))))
+
+ _
+ (macro.fail ($_ text/compose "Wrong syntax for " up-cast)))))]))))]]
(function [compiler]
(#E.Success [(update@ #.modules (put this-module-name this-module) compiler)
[]]))))
@@ -101,8 +101,8 @@
(do macro.Monad<Meta>
[this-module (macro.find-module this-module-name)
#let [this-module (|> this-module
- (update@ #.defs (remove down-cast))
- (update@ #.defs (remove up-cast)))]]
+ (update@ #.definitions (remove down-cast))
+ (update@ #.definitions (remove up-cast)))]]
(function [compiler]
(#E.Success [(update@ #.modules (put this-module-name this-module) compiler)
[]]))))
diff --git a/stdlib/source/lux/type/implicit.lux b/stdlib/source/lux/type/implicit.lux
index 7fe8d02d9..a28db6058 100644
--- a/stdlib/source/lux/type/implicit.lux
+++ b/stdlib/source/lux/type/implicit.lux
@@ -15,7 +15,7 @@
(macro [code]
["s" syntax #+ syntax: Syntax])
(lang [type]
- (type ["tc" check #+ Check Monad<Check>]))
+ (type ["tc" check #+ Check]))
))
(def: (find-type-var id env)
@@ -65,12 +65,12 @@
(#.Product left right)
(if (n/= +0 idx)
- (:: Monad<Check> wrap left)
+ (:: tc.Monad<Check> wrap left)
(find-member-type (n/dec idx) right))
_
(if (n/= +0 idx)
- (:: Monad<Check> wrap sig-type)
+ (:: tc.Monad<Check> wrap sig-type)
(tc.fail (format "Cannot find member type " (%n idx) " for " (%type sig-type))))))
(def: (find-member-name member)
@@ -108,9 +108,9 @@
[idx tag-list sig-type] (macro.resolve-tag member)]
(wrap [idx sig-type])))
-(def: (prepare-defs this-module-name defs)
- (-> Text (List [Text Def]) (List [Ident Type]))
- (|> defs
+(def: (prepare-definitions this-module-name definitions)
+ (-> Text (List [Text Definition]) (List [Ident Type]))
+ (|> definitions
(list.filter (function [[name [def-type def-anns def-value]]]
(macro.struct? def-anns)))
(list/map (function [[name [def-type def-anns def-value]]]
@@ -133,8 +133,8 @@
(Meta (List [Ident Type]))
(do Monad<Meta>
[this-module-name macro.current-module-name
- defs (macro.defs this-module-name)]
- (wrap (prepare-defs this-module-name defs))))
+ definitions (macro.definitions this-module-name)]
+ (wrap (prepare-definitions this-module-name definitions))))
(def: import-structs
(Meta (List [Ident Type]))
@@ -144,7 +144,7 @@
export-batches (monad.map @ (function [imp-mod]
(do @
[exports (macro.exports imp-mod)]
- (wrap (prepare-defs imp-mod exports))))
+ (wrap (prepare-definitions imp-mod exports))))
imp-mods)]
(wrap (list/join export-batches))))
@@ -155,13 +155,13 @@
(apply-function-type func' arg)
(#.UnivQ _)
- (do Monad<Check>
+ (do tc.Monad<Check>
[[id var] tc.var]
(apply-function-type (maybe.assume (type.apply (list var) func))
arg))
(#.Function input output)
- (do Monad<Check>
+ (do tc.Monad<Check>
[_ (tc.check input arg)]
(wrap output))
@@ -172,19 +172,19 @@
(-> Type (Check [(List Nat) Type]))
(case type
(#.UnivQ _)
- (do Monad<Check>
+ (do tc.Monad<Check>
[[id var] tc.var
[ids final-output] (concrete-type (maybe.assume (type.apply (list var) type)))]
(wrap [(#.Cons id ids)
final-output]))
_
- (:: Monad<Check> wrap [(list) type])))
+ (:: tc.Monad<Check> wrap [(list) type])))
(def: (check-apply member-type input-types output-type)
(-> Type (List Type) Type (Check []))
- (do Monad<Check>
- [member-type' (monad.fold Monad<Check>
+ (do tc.Monad<Check>
+ [member-type' (monad.fold tc.Monad<Check>
(function [input member]
(apply-function-type member input))
member-type
@@ -204,7 +204,7 @@
(case (|> alts
(list/map (function [[alt-name alt-type]]
(case (tc.run context
- (do Monad<Check>
+ (do tc.Monad<Check>
[[tvars alt-type] (concrete-type alt-type)
#let [[deps alt-type] (type.flatten-function alt-type)]
_ (tc.check dep alt-type)
@@ -239,7 +239,7 @@
(tc.fail (format "No candidates for provisioning: " (%type dep)))
(#.Cons winner #.Nil)
- (:: Monad<Check> wrap winner)
+ (:: tc.Monad<Check> wrap winner)
_
(tc.fail (format "Too many candidates for provisioning: " (%type dep) " --- " (%list (|>> product.left %ident) candidates))))
@@ -253,7 +253,7 @@
(case (|> alts
(list/map (function [[alt-name alt-type]]
(case (tc.run context
- (do Monad<Check>
+ (do tc.Monad<Check>
[[tvars alt-type] (concrete-type alt-type)
#let [[deps alt-type] (type.flatten-function alt-type)]
_ (tc.check alt-type sig-type)