aboutsummaryrefslogtreecommitdiff
path: root/source/lux.lux
diff options
context:
space:
mode:
authorEduardo Julian2015-05-22 23:06:19 -0400
committerEduardo Julian2015-05-22 23:06:19 -0400
commit1f0be2351bc76b0de15d97691f8ea0728d9ab321 (patch)
tree1b1f82ad9c585d6abe493476178fe8fa51935456 /source/lux.lux
parentf52eb6df2e57f67e7cf30d85c6340ce00f923d6f (diff)
- Added a simple optimization based on the idea of avoiding to compare 2 type-functions which are most-likely the same, due to their name (remembering that when you define types using deftype, the type-function's name will correspond to the def's).
- Gave empty environments to top-level type-functions, instead of leaving them with unset environments.
Diffstat (limited to '')
-rw-r--r--source/lux.lux70
1 files changed, 35 insertions, 35 deletions
diff --git a/source/lux.lux b/source/lux.lux
index e3f3ba243..9b5601eb4 100644
--- a/source/lux.lux
+++ b/source/lux.lux
@@ -37,10 +37,10 @@
## (| #Nil
## (#Cons (, a (List a)))))
(_lux_def List
- (#AllT [#None "List" "a"
+ (#AllT [(#Some #Nil) "lux;List" "a"
(#VariantT (#Cons [["lux;Nil" (#TupleT #Nil)]
(#Cons [["lux;Cons" (#TupleT (#Cons [(#BoundT "a")
- (#Cons [(#AppT [(#BoundT "List") (#BoundT "a")])
+ (#Cons [(#AppT [(#BoundT "lux;List") (#BoundT "a")])
#Nil])]))]
#Nil])]))]))
(_lux_export List)
@@ -49,7 +49,7 @@
## (| #None
## (#Some a)))
(_lux_def Maybe
- (#AllT [#None "Maybe" "a"
+ (#AllT [(#Some #Nil) "lux;Maybe" "a"
(#VariantT (#Cons [["lux;None" (#TupleT #Nil)]
(#Cons [["lux;Some" (#BoundT "a")]
#Nil])]))]))
@@ -70,7 +70,7 @@
Type
(_lux_case (#AppT [List (#TupleT (#Cons [Text (#Cons [Type #Nil])]))])
TypeEnv
- (#AppT [(#AllT [#None "Type" "_"
+ (#AppT [(#AllT [(#Some #Nil) "Type" "_"
(#VariantT (#Cons [["lux;DataT" Text]
(#Cons [["lux;TupleT" (#AppT [List Type])]
(#Cons [["lux;VariantT" TypeEnv]
@@ -89,7 +89,7 @@
## (& #counter Int
## #mappings (List (, k v))))
(_lux_def Bindings
- (#AllT [#None "Bindings" "k"
+ (#AllT [(#Some #Nil) "lux;Bindings" "k"
(#AllT [#None "" "v"
(#RecordT (#Cons [["lux;counter" Int]
(#Cons [["lux;mappings" (#AppT [List
@@ -104,7 +104,7 @@
## #locals (Bindings k v)
## #closure (Bindings k v)))
(_lux_def Env
- (#AllT [#None "Env" "k"
+ (#AllT [(#Some #Nil) "lux;Env" "k"
(#AllT [#None "" "v"
(#RecordT (#Cons [["lux;name" Text]
(#Cons [["lux;inner-closures" Int]
@@ -122,7 +122,7 @@
## (deftype (Meta m v)
## (| (#Meta (, m v))))
(_lux_def Meta
- (#AllT [#None "Meta" "m"
+ (#AllT [(#Some #Nil) "lux;Meta" "m"
(#AllT [#None "" "v"
(#VariantT (#Cons [["lux;Meta" (#TupleT (#Cons [(#BoundT "m")
(#Cons [(#BoundT "v")
@@ -143,12 +143,12 @@
## (#RecordS (List (, (w (Syntax' w)) (w (Syntax' w)))))))
(_lux_def Syntax'
(_lux_case (#AppT [(#BoundT "w")
- (#AppT [(#BoundT "Syntax'")
+ (#AppT [(#BoundT "lux;Syntax'")
(#BoundT "w")])])
Syntax
(_lux_case (#AppT [List Syntax])
SyntaxList
- (#AllT [#None "Syntax'" "w"
+ (#AllT [(#Some #Nil) "lux;Syntax'" "w"
(#VariantT (#Cons [["lux;BoolS" Bool]
(#Cons [["lux;IntS" Int]
(#Cons [["lux;RealS" Real]
@@ -178,7 +178,7 @@
## (| (#Left l)
## (#Right r)))
(_lux_def Either
- (#AllT [#None "_" "l"
+ (#AllT [(#Some #Nil) "lux;Either" "l"
(#AllT [#None "" "r"
(#VariantT (#Cons [["lux;Left" (#BoundT "l")]
(#Cons [["lux;Right" (#BoundT "r")]
@@ -188,7 +188,7 @@
## (deftype (StateE s a)
## (-> s (Either Text (, s a))))
(_lux_def StateE
- (#AllT [#None "StateE" "s"
+ (#AllT [(#Some #Nil) "lux;StateE" "s"
(#AllT [#None "" "a"
(#LambdaT [(#BoundT "s")
(#AppT [(#AppT [Either Text])
@@ -218,7 +218,7 @@
## (#MacroD m)
## (#AliasD Ident)))
(_lux_def DefData'
- (#AllT [#None "DefData'" ""
+ (#AllT [(#Some #Nil) "lux;DefData'" ""
(#VariantT (#Cons [["lux;TypeD" (#TupleT #Nil)]
(#Cons [["lux;ValueD" Type]
(#Cons [["lux;MacroD" (#BoundT "")]
@@ -234,20 +234,20 @@
#Nil])])))
(_lux_export LuxVar)
-## (deftype #rec CompilerState
+## (deftype #rec Compiler
## (& #source Reader
-## #modules (List (, Text (List (, Text (, Bool (DefData' (-> (List Syntax) (StateE CompilerState (List Syntax)))))))))
+## #modules (List (, Text (List (, Text (, Bool (DefData' (-> (List Syntax) (StateE Compiler (List Syntax)))))))))
## #module-aliases (List Void)
## #envs (List (Env Text (, LuxVar Type)))
## #types (Bindings Int Type)
## #host HostState))
-(_lux_def CompilerState
- (#AppT [(#AllT [#None "CompilerState" ""
+(_lux_def Compiler
+ (#AppT [(#AllT [(#Some #Nil) "lux;Compiler" ""
(#RecordT (#Cons [["lux;source" Reader]
(#Cons [["lux;modules" (#AppT [List (#TupleT (#Cons [Text
(#Cons [(#AppT [List (#TupleT (#Cons [Text
(#Cons [(#TupleT (#Cons [Bool (#Cons [(#AppT [DefData' (#LambdaT [SyntaxList
- (#AppT [(#AppT [StateE (#AppT [(#BoundT "CompilerState")
+ (#AppT [(#AppT [StateE (#AppT [(#BoundT "lux;Compiler")
(#BoundT "")])])
SyntaxList])])])
#Nil])]))
@@ -261,13 +261,13 @@
(#Cons [["lux;seed" Int]
#Nil])])])])])])]))])
Void]))
-(_lux_export CompilerState)
+(_lux_export Compiler)
## (deftype Macro
-## (-> (List Syntax) (StateE CompilerState (List Syntax))))
+## (-> (List Syntax) (StateE Compiler (List Syntax))))
(_lux_def Macro
(#LambdaT [SyntaxList
- (#AppT [(#AppT [StateE CompilerState])
+ (#AppT [(#AppT [StateE Compiler])
SyntaxList])]))
(_lux_export Macro)
@@ -284,15 +284,15 @@
## (def (return x)
## (All [a]
-## (-> a CompilerState
-## (Either Text (, CompilerState a))))
+## (-> a Compiler
+## (Either Text (, Compiler a))))
## ...)
(_lux_def return
- (_lux_: (#AllT [#None "" "a"
+ (_lux_: (#AllT [(#Some #Nil) "" "a"
(#LambdaT [(#BoundT "a")
- (#LambdaT [CompilerState
+ (#LambdaT [Compiler
(#AppT [(#AppT [Either Text])
- (#TupleT (#Cons [CompilerState
+ (#TupleT (#Cons [Compiler
(#Cons [(#BoundT "a")
#Nil])]))])])])])
(_lux_lambda _ val
@@ -301,15 +301,15 @@
## (def (fail msg)
## (All [a]
-## (-> Text CompilerState
-## (Either Text (, CompilerState a))))
+## (-> Text Compiler
+## (Either Text (, Compiler a))))
## ...)
(_lux_def fail
- (_lux_: (#AllT [#None "" "a"
+ (_lux_: (#AllT [(#Some #Nil) "" "a"
(#LambdaT [Text
- (#LambdaT [CompilerState
+ (#LambdaT [Compiler
(#AppT [(#AppT [Either Text])
- (#TupleT (#Cons [CompilerState
+ (#TupleT (#Cons [Compiler
(#Cons [(#BoundT "a")
#Nil])]))])])])])
(_lux_lambda _ msg
@@ -911,11 +911,11 @@
(fail "Wrong syntax for if")))
## (deftype (Lux a)
-## (-> CompilerState (Either Text (, CompilerState a))))
+## (-> Compiler (Either Text (, Compiler a))))
(def__ #export Lux
Type
(All' [a]
- (->' CompilerState ($' Either Text (#TupleT (list CompilerState (B' a)))))))
+ (->' Compiler ($' Either Text (#TupleT (list Compiler (B' a)))))))
## (defsig (Monad m)
## (: (All [a] (-> a (m a)))
@@ -1246,7 +1246,7 @@
(replace-syntax replacements body)
(reverse targs))]
(return (_lux_: SyntaxList
- (list (`' (#;AllT [#;None (~ ($text self-ident)) (~ ($text harg)) (~ body')])))))))
+ (list (`' (#;AllT [(#;Some #;Nil) (~ ($text self-ident)) (~ ($text harg)) (~ body')])))))))
#None
(fail "'All' arguments must be symbols."))
@@ -1281,7 +1281,7 @@
(#Right [state module-name]))))
(def__ (find-macro' modules current-module module name)
- (-> ($' List (, Text ($' List (, Text (, Bool ($' DefData' (-> ($' List Syntax) ($' StateE CompilerState ($' List Syntax)))))))))
+ (-> ($' List (, Text ($' List (, Text (, Bool ($' DefData' (-> ($' List Syntax) ($' StateE Compiler ($' List Syntax)))))))))
Text Text Text
($' Maybe Macro))
(do Maybe:Monad
@@ -1949,7 +1949,7 @@
#seed seed}
(case (get "lux" modules)
(#Some lux)
- (let [to-alias (map (: (-> (, Text (, Bool (DefData' (-> (List Syntax) (StateE CompilerState (List Syntax))))))
+ (let [to-alias (map (: (-> (, Text (, Bool (DefData' (-> (List Syntax) (StateE Compiler (List Syntax))))))
(List Text))
(lambda [gdef]
(let [[name [export? _]] gdef]