From 3c93d7a3aabaa49c67f9a498bc0d70f0af7f09d0 Mon Sep 17 00:00:00 2001
From: Eduardo Julian
Date: Sat, 5 May 2018 20:42:41 -0400
Subject: - Removed Void and Unit as kinds of types. - Changed the value of
"unit" in the old LuxC to match the one in new-luxc.
---
stdlib/source/lux.lux | 283 ++++++++++-------------
stdlib/source/lux/cli.lux | 6 +-
stdlib/source/lux/concurrency/actor.lux | 4 +-
stdlib/source/lux/concurrency/frp.lux | 2 +-
stdlib/source/lux/concurrency/promise.lux | 4 +-
stdlib/source/lux/concurrency/semaphore.lux | 18 +-
stdlib/source/lux/concurrency/stm.lux | 26 +--
stdlib/source/lux/concurrency/task.lux | 4 +-
stdlib/source/lux/control/concatenative.lux | 4 +-
stdlib/source/lux/control/parser.lux | 4 +-
stdlib/source/lux/control/pipe.lux | 2 +-
stdlib/source/lux/control/region.lux | 6 +-
stdlib/source/lux/control/state.lux | 8 +-
stdlib/source/lux/control/thread.lux | 2 +-
stdlib/source/lux/control/writer.lux | 2 +-
stdlib/source/lux/data/format/json.lux | 14 +-
stdlib/source/lux/data/format/xml.lux | 4 +-
stdlib/source/lux/data/text/lexer.lux | 4 +-
stdlib/source/lux/data/text/regex.lux | 2 +-
stdlib/source/lux/host.jvm.lux | 48 ++--
stdlib/source/lux/io.lux | 10 +-
stdlib/source/lux/lang/syntax.lux | 2 +-
stdlib/source/lux/lang/type.lux | 20 +-
stdlib/source/lux/lang/type/check.lux | 27 +--
stdlib/source/lux/macro.lux | 2 +-
stdlib/source/lux/macro/poly.lux | 29 +--
stdlib/source/lux/macro/poly/eq.lux | 2 +-
stdlib/source/lux/macro/poly/json.lux | 31 ++-
stdlib/source/lux/macro/syntax.lux | 4 +-
stdlib/source/lux/macro/syntax/common/reader.lux | 3 +-
stdlib/source/lux/math/constructive.lux | 2 +-
stdlib/source/lux/math/random.lux | 2 +-
stdlib/source/lux/test.lux | 2 +-
stdlib/source/lux/type/abstract.lux | 4 +-
stdlib/source/lux/type/object/interface.lux | 14 +-
stdlib/source/lux/type/resource.lux | 6 +-
stdlib/source/lux/world/blob.jvm.lux | 8 +-
stdlib/source/lux/world/console.lux | 4 +-
stdlib/source/lux/world/file.lux | 2 +-
stdlib/source/lux/world/net/tcp.jvm.lux | 10 +-
stdlib/source/lux/world/net/udp.jvm.lux | 6 +-
41 files changed, 278 insertions(+), 359 deletions(-)
(limited to 'stdlib/source')
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux
index dc469633f..6bec61741 100644
--- a/stdlib/source/lux.lux
+++ b/stdlib/source/lux.lux
@@ -1,23 +1,57 @@
## Basic types
("lux def" dummy-cursor
- ("lux check" (+4 (+0 "#Text" (+0)) (+4 (+0 "#Nat" (+0)) (+0 "#Nat" (+0))))
+ ("lux check" (+2 (+0 "#Text" (+0))
+ (+2 (+0 "#Nat" (+0))
+ (+0 "#Nat" (+0))))
["" +0 +0])
[["" +0 +0]
(+10 (+1 [[["" +0 +0] (+7 ["lux" "export?"])]
[["" +0 +0] (+0 true)]]
(+0)))])
+## (type: Top
+## (Ex [a] a))
+("lux def" Top
+ (+10 ["lux" "Top"]
+ (+8 (+0) (+4 +1)))
+ [dummy-cursor
+ (+10 (+1 [[dummy-cursor (+7 ["lux" "type?"])]
+ [dummy-cursor (+0 true)]]
+ (+1 [[dummy-cursor (+7 ["lux" "export?"])]
+ [dummy-cursor (+0 true)]]
+ (+1 [[dummy-cursor (+7 ["lux" "doc"])]
+ [dummy-cursor (+5 "The type of things whose type does not matter.
+
+ It can be used to write functions or data-structures that can take, or return, anything.")]]
+ (+0)))))])
+
+## (type: Bottom
+## (All [a] a))
+("lux def" Bottom
+ (+10 ["lux" "Bottom"]
+ (+7 (+0) (+4 +1)))
+ [dummy-cursor
+ (+10 (+1 [[dummy-cursor (+7 ["lux" "type?"])]
+ [dummy-cursor (+0 true)]]
+ (+1 [[dummy-cursor (+7 ["lux" "export?"])]
+ [dummy-cursor (+0 true)]]
+ (+1 [[dummy-cursor (+7 ["lux" "doc"])]
+ [dummy-cursor (+5 "The type of things whose type is unknown or undefined.
+
+ Useful for expressions that cause errors or other \"extraordinary\" conditions.")]]
+ (+0)))))])
+
## (type: (List a)
## #Nil
## (#Cons a (List a)))
("lux def" List
- (+12 ["lux" "List"]
- (+9 (+0)
- (+3 ## "lux.Nil"
- (+2)
+ (+10 ["lux" "List"]
+ (+7 (+0)
+ (+1 ## "lux.Nil"
+ Top
## "lux.Cons"
- (+4 (+6 +1)
- (+11 (+6 +1) (+6 +0))))))
+ (+2 (+4 +1)
+ (+9 (+4 +1) (+4 +0))))))
[dummy-cursor
(+10 (+1 [[dummy-cursor (+7 ["lux" "type?"])]
[dummy-cursor (+0 true)]]
@@ -32,7 +66,7 @@
(+0)))))))])
("lux def" Bool
- (+12 ["lux" "Bool"]
+ (+10 ["lux" "Bool"]
(+0 "#Bool" #Nil))
[dummy-cursor
(+10 (#Cons [[dummy-cursor (+7 ["lux" "type?"])]
@@ -44,7 +78,7 @@
#Nil))))])
("lux def" Nat
- (+12 ["lux" "Nat"]
+ (+10 ["lux" "Nat"]
(+0 "#Nat" #Nil))
[dummy-cursor
(+10 (#Cons [[dummy-cursor (+7 ["lux" "type?"])]
@@ -58,7 +92,7 @@
#Nil))))])
("lux def" Int
- (+12 ["lux" "Int"]
+ (+10 ["lux" "Int"]
(+0 "#Int" #Nil))
[dummy-cursor
(+10 (#Cons [[dummy-cursor (+7 ["lux" "type?"])]
@@ -70,7 +104,7 @@
#Nil))))])
("lux def" Frac
- (+12 ["lux" "Frac"]
+ (+10 ["lux" "Frac"]
(+0 "#Frac" #Nil))
[dummy-cursor
(+10 (#Cons [[dummy-cursor (+7 ["lux" "type?"])]
@@ -82,7 +116,7 @@
#Nil))))])
("lux def" Deg
- (+12 ["lux" "Deg"]
+ (+10 ["lux" "Deg"]
(+0 "#Deg" #Nil))
[dummy-cursor
(+10 (#Cons [[dummy-cursor (+7 ["lux" "type?"])]
@@ -96,7 +130,7 @@
#Nil))))])
("lux def" Text
- (+12 ["lux" "Text"]
+ (+10 ["lux" "Text"]
(+0 "#Text" #Nil))
[dummy-cursor
(+10 (#Cons [[dummy-cursor (+7 ["lux" "type?"])]
@@ -107,33 +141,9 @@
[dummy-cursor (+5 "Your standard, run-of-the-mill string values.")]]
#Nil))))])
-("lux def" Void
- (+12 ["lux" "Void"]
- (+1))
- [dummy-cursor
- (+10 (#Cons [[dummy-cursor (+7 ["lux" "type?"])]
- [dummy-cursor (+0 true)]]
- (#Cons [[dummy-cursor (+7 ["lux" "export?"])]
- [dummy-cursor (+0 true)]]
- (#Cons [[dummy-cursor (+7 ["lux" "doc"])]
- [dummy-cursor (+5 "An unusual type that possesses no value, and thus cannot be instantiated.")]]
- #Nil))))])
-
-("lux def" Unit
- (+12 ["lux" "Unit"]
- (+2))
- [dummy-cursor
- (+10 (#Cons [[dummy-cursor (+7 ["lux" "type?"])]
- [dummy-cursor (+0 true)]]
- (#Cons [[dummy-cursor (+7 ["lux" "export?"])]
- [dummy-cursor (+0 true)]]
- (#Cons [[dummy-cursor (+7 ["lux" "doc"])]
- [dummy-cursor (+5 "An unusual type that only possesses a single value: []")]]
- #Nil))))])
-
("lux def" Ident
- (+12 ["lux" "Ident"]
- (+4 Text Text))
+ (+10 ["lux" "Ident"]
+ (+2 Text Text))
[dummy-cursor
(+10 (#Cons [[dummy-cursor (+7 ["lux" "type?"])]
[dummy-cursor (+0 true)]]
@@ -149,12 +159,12 @@
## #None
## (#Some a))
("lux def" Maybe
- (+12 ["lux" "Maybe"]
- (+9 #Nil
- (+3 ## "lux.None"
- (+2)
+ (+10 ["lux" "Maybe"]
+ (+7 #Nil
+ (+1 ## "lux.None"
+ Top
## "lux.Some"
- (+6 +1))))
+ (+4 +1))))
[dummy-cursor
(+10 (#Cons [[dummy-cursor (+7 ["lux" "type?"])]
[dummy-cursor (+0 true)]]
@@ -170,8 +180,6 @@
## (type: #rec Type
## (#Primitive Text (List Type))
-## #Void
-## #Unit
## (#Sum Type Type)
## (#Product Type Type)
## (#Function Type Type)
@@ -184,41 +192,37 @@
## (#Named Ident Type)
## )
("lux def" Type
- (+12 ["lux" "Type"]
- ("lux case" ("lux check type" (+11 (+6 +1) (+6 +0)))
+ (+10 ["lux" "Type"]
+ ("lux case" ("lux check type" (+9 (+4 +1) (+4 +0)))
{Type
- ("lux case" ("lux check type" (+11 Type List))
+ ("lux case" ("lux check type" (+9 Type List))
{Type-List
- ("lux case" ("lux check type" (+4 Type Type))
+ ("lux case" ("lux check type" (+2 Type Type))
{Type-Pair
- (+11 Void
- (+9 #Nil
- (+3 ## "lux.Primitive"
- (+4 Text Type-List)
- (+3 ## "lux.Void"
- (+2)
- (+3 ## "lux.Unit"
- (+2)
- (+3 ## "lux.Sum"
- Type-Pair
- (+3 ## "lux.Product"
- Type-Pair
- (+3 ## "lux.Function"
- Type-Pair
- (+3 ## "lux.Bound"
- Nat
- (+3 ## "lux.Var"
- Nat
- (+3 ## "lux.Ex"
- Nat
- (+3 ## "lux.UnivQ"
- (+4 Type-List Type)
- (+3 ## "lux.ExQ"
- (+4 Type-List Type)
- (+3 ## "lux.Apply"
- Type-Pair
- ## "lux.Named"
- (+4 Ident Type)))))))))))))))})})}))
+ (+9 Bottom
+ (+7 #Nil
+ (+1 ## "lux.Primitive"
+ (+2 Text Type-List)
+ (+1 ## "lux.Sum"
+ Type-Pair
+ (+1 ## "lux.Product"
+ Type-Pair
+ (+1 ## "lux.Function"
+ Type-Pair
+ (+1 ## "lux.Bound"
+ Nat
+ (+1 ## "lux.Var"
+ Nat
+ (+1 ## "lux.Ex"
+ Nat
+ (+1 ## "lux.UnivQ"
+ (+2 Type-List Type)
+ (+1 ## "lux.ExQ"
+ (+2 Type-List Type)
+ (+1 ## "lux.Apply"
+ Type-Pair
+ ## "lux.Named"
+ (+2 Ident Type)))))))))))))})})}))
[dummy-cursor
(+10 (#Cons [[dummy-cursor (+7 ["lux" "type?"])]
[dummy-cursor (+0 true)]]
@@ -226,57 +230,23 @@
[dummy-cursor (+0 true)]]
(#Cons [[dummy-cursor (+7 ["lux" "tags"])]
[dummy-cursor (+9 (#Cons [dummy-cursor (+5 "Primitive")]
- (#Cons [dummy-cursor (+5 "Void")]
- (#Cons [dummy-cursor (+5 "Unit")]
- (#Cons [dummy-cursor (+5 "Sum")]
- (#Cons [dummy-cursor (+5 "Product")]
- (#Cons [dummy-cursor (+5 "Function")]
- (#Cons [dummy-cursor (+5 "Bound")]
- (#Cons [dummy-cursor (+5 "Var")]
- (#Cons [dummy-cursor (+5 "Ex")]
- (#Cons [dummy-cursor (+5 "UnivQ")]
- (#Cons [dummy-cursor (+5 "ExQ")]
- (#Cons [dummy-cursor (+5 "Apply")]
- (#Cons [dummy-cursor (+5 "Named")]
- #Nil))))))))))))))]]
+ (#Cons [dummy-cursor (+5 "Sum")]
+ (#Cons [dummy-cursor (+5 "Product")]
+ (#Cons [dummy-cursor (+5 "Function")]
+ (#Cons [dummy-cursor (+5 "Bound")]
+ (#Cons [dummy-cursor (+5 "Var")]
+ (#Cons [dummy-cursor (+5 "Ex")]
+ (#Cons [dummy-cursor (+5 "UnivQ")]
+ (#Cons [dummy-cursor (+5 "ExQ")]
+ (#Cons [dummy-cursor (+5 "Apply")]
+ (#Cons [dummy-cursor (+5 "Named")]
+ #Nil))))))))))))]]
(#Cons [[dummy-cursor (+7 ["lux" "doc"])]
[dummy-cursor (+5 "This type represents the data-structures that are used to specify types themselves.")]]
(#Cons [[dummy-cursor (+7 ["lux" "type-rec?"])]
[dummy-cursor (+0 true)]]
#Nil))))))])
-## (type: Top
-## (Ex [a] a))
-("lux def" Top
- (#Named ["lux" "Top"]
- (#ExQ #Nil (#Bound +1)))
- [dummy-cursor
- (+10 (#Cons [[dummy-cursor (+7 ["lux" "type?"])]
- [dummy-cursor (+0 true)]]
- (#Cons [[dummy-cursor (+7 ["lux" "export?"])]
- [dummy-cursor (+0 true)]]
- (#Cons [[dummy-cursor (+7 ["lux" "doc"])]
- [dummy-cursor (+5 "The type of things whose type does not matter.
-
- It can be used to write functions or data-structures that can take, or return, anything.")]]
- #Nil))))])
-
-## (type: Bottom
-## (All [a] a))
-("lux def" Bottom
- (#Named ["lux" "Bottom"]
- (#UnivQ #Nil (#Bound +1)))
- [dummy-cursor
- (+10 (#Cons [[dummy-cursor (+7 ["lux" "type?"])]
- [dummy-cursor (+0 true)]]
- (#Cons [[dummy-cursor (+7 ["lux" "export?"])]
- [dummy-cursor (+0 true)]]
- (#Cons [[dummy-cursor (+7 ["lux" "doc"])]
- [dummy-cursor (+5 "The type of things whose type is unknown or undefined.
-
- Useful for expressions that cause errors or other \"extraordinary\" conditions.")]]
- #Nil))))])
-
## (type: Cursor
## {#module Text
## #line Nat
@@ -582,12 +552,12 @@
(#Named ["lux" "Module-State"]
(#Sum
## #Active
- Unit
+ Top
(#Sum
## #Compiled
- Unit
+ Top
## #Cached
- Unit)))
+ Top)))
(record$ (#Cons [(tag$ ["lux" "tags"])
(tuple$ (#Cons (text$ "Active") (#Cons (text$ "Compiled") (#Cons (text$ "Cached") #Nil))))]
default-def-meta-exported)))
@@ -669,11 +639,11 @@
("lux def" Mode
(#Named ["lux" "Mode"]
(#Sum ## Build
- #Unit
+ Top
(#Sum ## Eval
- #Unit
+ Top
## REPL
- #Unit)))
+ Top)))
(record$ (#Cons [(tag$ ["lux" "tags"])
(tuple$ (#Cons (text$ "Build")
(#Cons (text$ "Eval")
@@ -717,8 +687,8 @@
## #expected (Maybe Type)
## #seed Nat
## #scope-type-vars (List Nat)
-## #extensions Void
-## #host Void})
+## #extensions Bottom
+## #host Bottom})
("lux def" Compiler
(#Named ["lux" "Compiler"]
(#Product ## "lux.info"
@@ -742,9 +712,9 @@
(#Product ## scope-type-vars
(#Apply Nat List)
(#Product ## extensions
- Void
+ Bottom
## "lux.host"
- Void))))))))))))
+ Bottom))))))))))))
(record$ (#Cons [(tag$ ["lux" "tags"])
(tuple$ (#Cons (text$ "info")
(#Cons (text$ "source")
@@ -1210,7 +1180,7 @@
## A name can be provided, to specify a recursive type.
(All List [a]
- (| Unit
+ (| Top
[a (List a)]))")]
#Nil)
(let'' [self-name tokens] ("lux case" tokens
@@ -1363,12 +1333,12 @@
(text$ "## Tuple types:
(& Text Int Bool)
- ## The empty tuple, a.k.a. Unit.
+ ## Top.
(&)")]
#Nil)
("lux case" (list/reverse tokens)
{#Nil
- (return (list (tag$ ["lux" "Unit"])))
+ (return (list (symbol$ ["lux" "Top"])))
(#Cons last prevs)
(return (list (list/fold (function'' [left right] (form$ (list (tag$ ["lux" "Product"]) left right)))
@@ -1381,12 +1351,12 @@
(text$ "## Variant types:
(| Text Int Bool)
- ## The empty tuple, a.k.a. Void.
+ ## Bottom.
(|)")]
#Nil)
("lux case" (list/reverse tokens)
{#Nil
- (return (list (tag$ ["lux" "Void"])))
+ (return (list (symbol$ ["lux" "Bottom"])))
(#Cons last prevs)
(return (list (list/fold (function'' [left right] (form$ (list (tag$ ["lux" "Sum"]) left right)))
@@ -1763,7 +1733,7 @@
(text$ "Logs message to standard output.
Useful for debugging.")])
- (-> Text Unit)
+ (-> Text Top)
("lux io log" message))
(def:''' (text/compose x y)
@@ -2698,7 +2668,7 @@
(#Cons type #Nil)
("lux case" type
{[_ (#Tag "" member-name)]
- (return [(` #.Unit) (#Some (list member-name))])
+ (return [(` .Top) (#Some (list member-name))])
[_ (#Form (#Cons [_ (#Tag "" member-name)] member-types))]
(return [(` (& (~+ member-types))) (#Some (list member-name))])
@@ -2713,7 +2683,7 @@
(function' [case]
("lux case" case
{[_ (#Tag "" member-name)]
- (return [member-name (` Unit)])
+ (return [member-name (` .Top)])
[_ (#Form (#Cons [_ (#Tag "" member-name)] (#Cons member-type #Nil)))]
(return [member-name member-type])
@@ -2756,7 +2726,7 @@
{(#Cons [_ (#Symbol "" name)] (#Cons body #Nil))
(let' [body' (replace-syntax (list [name (` (#.Apply (~ (make-bound +1)) (~ (make-bound +0))))])
(update-bounds body))]
- (return (list (` (#.Apply #.Void (#.UnivQ #.Nil (~ body')))))))
+ (return (list (` (#.Apply .Bottom (#.UnivQ #.Nil (~ body')))))))
_
(fail "Wrong syntax for Rec")}))
@@ -3827,9 +3797,9 @@
(if (empty? args)
(let [g!param (symbol$ ["" ""])
prime-name (symbol$ ["" name])
- type+ (replace-syntax (list [name (` ((~ prime-name) #.Void))]) type)]
+ type+ (replace-syntax (list [name (` ((~ prime-name) .Bottom))]) type)]
(#Some (` ((All (~ prime-name) [(~ g!param)] (~ type+))
- #.Void))))
+ .Bottom))))
#None)
(case args
#Nil
@@ -4357,12 +4327,6 @@
_
($_ text/compose "(" name " " (|> params (list/map type/show) (interpose " ") list/reverse (list/fold text/compose "")) ")"))
- #Void
- "Void"
-
- #Unit
- "Unit"
-
(#Sum _)
($_ text/compose "(| " (|> (flatten-variant type) (list/map type/show) (interpose " ") list/reverse (list/fold text/compose "")) ")")
@@ -4630,10 +4594,10 @@
openings+options (parse-openings options)
#let [[openings options] openings+options]
current-module current-module-name
- #let [test-referrals (: (-> Text (List Text) (List Text) (Meta (List Unit)))
+ #let [test-referrals (: (-> Text (List Text) (List Text) (Meta (List Top)))
(function (_ module-name all-defs referred-defs)
(monad/map Monad
- (: (-> Text (Meta Unit))
+ (: (-> Text (Meta Top))
(function (_ _def)
(if (is-member? all-defs _def)
(return [])
@@ -4655,10 +4619,10 @@
(-> Text Refer (Meta (List Code)))
(do Monad
[current-module current-module-name
- #let [test-referrals (: (-> Text (List Text) (List Text) (Meta (List Unit)))
+ #let [test-referrals (: (-> Text (List Text) (List Text) (Meta (List Top)))
(function (_ module-name all-defs referred-defs)
(monad/map Monad
- (: (-> Text (Meta Unit))
+ (: (-> Text (Meta Top))
(function (_ _def)
(if (is-member? all-defs _def)
(return [])
@@ -5242,12 +5206,6 @@
(#Primitive name params)
(` (#Primitive (~ (text$ name)) (~ (untemplate-list (list/map type-to-code params)))))
- #Void
- (` #Void)
-
- #Unit
- (` #Unit)
-
(^template []
( left right)
(` ( (~ (type-to-code left)) (~ (type-to-code right)))))
@@ -5277,8 +5235,7 @@
(` (#Apply (~ (type-to-code arg)) (~ (type-to-code fun))))
(#Named [module name] type)
- (` (#Named [(~ (text$ module)) (~ (text$ name))] (~ (type-to-code type))))
- ))
+ (symbol$ [module name])))
(macro: #export (loop tokens)
{#.doc (doc "Allows arbitrary looping, using the \"recur\" form to re-start the loop."
@@ -5834,7 +5791,7 @@
))
(def: (parse-end tokens)
- (-> (List Code) (Meta Unit))
+ (-> (List Code) (Meta Top))
(case tokens
(^ (list))
(return [])
diff --git a/stdlib/source/lux/cli.lux b/stdlib/source/lux/cli.lux
index 7a88b84f8..466895876 100644
--- a/stdlib/source/lux/cli.lux
+++ b/stdlib/source/lux/cli.lux
@@ -53,7 +53,7 @@
(def: #export (this reference)
{#.doc "Checks that a token is in the inputs."}
- (-> Text (CLI Unit))
+ (-> Text (CLI Top))
(function (_ inputs)
(do E.Monad
[[remaining raw] (any inputs)]
@@ -83,7 +83,7 @@
(def: #export end
{#.doc "Ensures there are no more inputs."}
- (CLI Unit)
+ (CLI Top)
(function (_ inputs)
(case inputs
#.Nil (#E.Success [inputs []])
@@ -130,7 +130,7 @@
(#Parsed args)
(with-gensyms [g!args g!_ g!output g!message]
(wrap (list (` ("lux program" (~ g!args)
- (case ((: (~! (..CLI (io.IO Unit)))
+ (case ((: (~! (..CLI (io.IO .Top)))
((~! do) (~! p.Monad)
[(~+ (|> args
(list/map (function (_ [binding parser])
diff --git a/stdlib/source/lux/concurrency/actor.lux b/stdlib/source/lux/concurrency/actor.lux
index 0e85758ed..4fdb2c207 100644
--- a/stdlib/source/lux/concurrency/actor.lux
+++ b/stdlib/source/lux/concurrency/actor.lux
@@ -61,7 +61,7 @@
(type: #export (Behavior s)
{#.doc "An actor's behavior when messages are received."}
{#handle (-> (Message s) s (Actor s) (Task s))
- #end (-> Text s (Promise Unit))})
+ #end (-> Text s (Promise Top))})
(def: #export (spawn behavior init)
{#.doc "Given a behavior and initial state, spawns an actor and returns it."}
@@ -124,7 +124,7 @@
(message state self))
(def: (default-end cause state)
- (All [s] (-> Text s (Promise Unit)))
+ (All [s] (-> Text s (Promise Top)))
(promise/wrap []))
(def: #export default-behavior
diff --git a/stdlib/source/lux/concurrency/frp.lux b/stdlib/source/lux/concurrency/frp.lux
index e160fec12..caa1173c2 100644
--- a/stdlib/source/lux/concurrency/frp.lux
+++ b/stdlib/source/lux/concurrency/frp.lux
@@ -76,7 +76,7 @@
output)))
(def: #export (periodic time)
- (-> Nat (Channel Unit))
+ (-> Nat (Channel Top))
(let [output (channel [])]
(exec (io.run
(loop [_ []]
diff --git a/stdlib/source/lux/concurrency/promise.lux b/stdlib/source/lux/concurrency/promise.lux
index 0e3e0c695..63305f318 100644
--- a/stdlib/source/lux/concurrency/promise.lux
+++ b/stdlib/source/lux/concurrency/promise.lux
@@ -149,8 +149,8 @@
(def: #export (wait time)
{#.doc "Returns a promise that will be resolved after the specified amount of milliseconds."}
- (-> Nat (Promise Unit))
- (let [!out (: (Promise Unit) (promise #.None))]
+ (-> Nat (Promise Top))
+ (let [!out (: (Promise Top) (promise #.None))]
(exec ("lux process schedule" time (resolve [] !out))
!out)))
diff --git a/stdlib/source/lux/concurrency/semaphore.lux b/stdlib/source/lux/concurrency/semaphore.lux
index c4391fbc9..50a1a621c 100644
--- a/stdlib/source/lux/concurrency/semaphore.lux
+++ b/stdlib/source/lux/concurrency/semaphore.lux
@@ -9,7 +9,7 @@
(type: State
{#open-positions Nat
- #waiting-list (List (Promise Unit))})
+ #waiting-list (List (Promise Top))})
(abstract: #export Semaphore
{#.doc "A tool for controlling access to resources by multiple concurrent processes."}
@@ -22,10 +22,10 @@
#waiting-list (list)})))
(def: #export (wait semaphore)
- (Ex [k] (-> Semaphore (Promise Unit)))
+ (Ex [k] (-> Semaphore (Promise Top)))
(let [semaphore (@representation semaphore)]
(io.run
- (loop [signal (: (Promise Unit)
+ (loop [signal (: (Promise Top)
(promise.promise #.None))]
(do io.Monad
[state (atom.read semaphore)
@@ -44,13 +44,13 @@
(recur signal)))))))
(def: #export (signal semaphore)
- (Ex [k] (-> Semaphore (Promise Unit)))
+ (Ex [k] (-> Semaphore (Promise Top)))
(let [semaphore (@representation semaphore)]
(promise.future
(loop [_ []]
(do io.Monad
[state (atom.read semaphore)
- #let [[?signal state'] (: [(Maybe (Promise Unit)) State]
+ #let [[?signal state'] (: [(Maybe (Promise Top)) State]
(case (get@ #waiting-list state)
#.Nil
[#.None (update@ #open-positions n/inc state)]
@@ -80,11 +80,11 @@
(@abstraction (semaphore +1)))
(def: (acquire mutex)
- (-> Mutex (Promise Unit))
+ (-> Mutex (Promise Top))
(wait (@representation mutex)))
(def: (release mutex)
- (-> Mutex (Promise Unit))
+ (-> Mutex (Promise Top))
(signal (@representation mutex)))
(def: #export (synchronize mutex procedure)
@@ -125,7 +125,7 @@
(do-template [ ]
[(def: ( (^@representation barrier))
- (-> Barrier (Promise Unit))
+ (-> Barrier (Promise Top))
(do promise.Monad
[#let [limit (refinement.un-refine (get@ #limit barrier))
goal
@@ -140,7 +140,7 @@
)
(def: #export (block barrier)
- (-> Barrier (Promise Unit))
+ (-> Barrier (Promise Top))
(do promise.Monad
[_ (start barrier)]
(end barrier)))
diff --git a/stdlib/source/lux/concurrency/stm.lux b/stdlib/source/lux/concurrency/stm.lux
index 707512821..fb150d842 100644
--- a/stdlib/source/lux/concurrency/stm.lux
+++ b/stdlib/source/lux/concurrency/stm.lux
@@ -34,7 +34,7 @@
(:: io.Functor map product.left)))
(def: (write! new-value (^@representation var))
- (All [a] (-> a (Var a) (IO Unit)))
+ (All [a] (-> a (Var a) (IO Top)))
(do io.Monad
[(^@ old [_value _observers]) (atom.read var)
succeeded? (atom.compare-and-swap old [new-value _observers] var)]
@@ -76,8 +76,8 @@
(All [a] (-> (Var a) Tx (Maybe a)))
(|> tx
(list.find (function (_ [_var _original _current])
- (is? (:! (Var Unit) var)
- (:! (Var Unit) _var))))
+ (is? (:! (Var Top) var)
+ (:! (Var Top) _var))))
(:: maybe.Monad map (function (_ [_var _original _current])
_current))
(:!!)
@@ -102,11 +102,11 @@
#.Nil
(#.Cons [_var _original _current] tx')
- (if (is? (:! (Var Unit) var)
- (:! (Var Unit) _var))
- (#.Cons {#var (:! (Var Unit) _var)
- #original (:! Unit _original)
- #current (:! Unit value)}
+ (if (is? (:! (Var Top) var)
+ (:! (Var Top) _var))
+ (#.Cons {#var (:! (Var Top) _var)
+ #original (:! Top _original)
+ #current (:! Top value)}
tx')
(#.Cons {#var _var
#original _original
@@ -116,7 +116,7 @@
(def: #export (write value var)
{#.doc "Writes value to var."}
- (All [a] (-> a (Var a) (STM Unit)))
+ (All [a] (-> a (Var a) (STM Top)))
(function (_ tx)
(case (find-var-value var tx)
(#.Some _)
@@ -169,7 +169,7 @@
tx))
(def: (commit-var! [_var _original _current])
- (-> (Ex [a] (Tx-Frame a)) Unit)
+ (-> (Ex [a] (Tx-Frame a)) Top)
(if (is? _original _current)
[]
(io.run (write! _current _var))))
@@ -202,7 +202,7 @@
(recur tail)))))
(def: (process-commit [stm-proc output])
- (-> [(STM Unit) (Promise Unit)] Top)
+ (-> [(STM Top) (Promise Top)] Top)
(let [[finished-tx value] (stm-proc fresh-tx)]
(io.run (if (can-commit? finished-tx)
(exec (list/map commit-var! finished-tx)
@@ -210,7 +210,7 @@
(issue-commit [stm-proc output])))))
(def: init-processor!
- (IO Unit)
+ (IO Top)
(do io.Monad
[flag (atom.read commit-processor-flag)]
(if flag
@@ -220,7 +220,7 @@
(if was-first?
(exec (|> (io.run (atom.read pending-commits))
(promise.await (function (recur [head tail])
- (io (exec (process-commit (:! [(STM Unit) (Promise Unit)] head))
+ (io (exec (process-commit (:! [(STM Top) (Promise Top)] head))
(promise.await recur tail))))))
(wrap []))
(wrap [])))
diff --git a/stdlib/source/lux/concurrency/task.lux b/stdlib/source/lux/concurrency/task.lux
index 66cc12ff3..8d95842e9 100644
--- a/stdlib/source/lux/concurrency/task.lux
+++ b/stdlib/source/lux/concurrency/task.lux
@@ -70,8 +70,8 @@
ma))))
(syntax: #export (task {type s.any})
- {#.doc (doc "Makes an uninitialized Task (in this example, of Unit)."
- (task Unit))}
+ {#.doc (doc "Makes an uninitialized Task (in this example, of Top)."
+ (task Top))}
(wrap (list (` (: (..Task (~ type))
(P.promise #.None))))))
diff --git a/stdlib/source/lux/control/concatenative.lux b/stdlib/source/lux/control/concatenative.lux
index ee342ec22..1af41bbdb 100644
--- a/stdlib/source/lux/control/concatenative.lux
+++ b/stdlib/source/lux/control/concatenative.lux
@@ -86,10 +86,10 @@
(-> (~ (de-alias inputC))
(~ (de-alias outputC))))))))))))
-(def: begin! Unit [])
+(def: begin! Top [])
(def: end!
- (All [a] (-> [Unit a] a))
+ (All [a] (-> [Top a] a))
(function (_ [_ top])
top))
diff --git a/stdlib/source/lux/control/parser.lux b/stdlib/source/lux/control/parser.lux
index d46b166e4..3c1022fc8 100644
--- a/stdlib/source/lux/control/parser.lux
+++ b/stdlib/source/lux/control/parser.lux
@@ -59,7 +59,7 @@
## [Parsers]
(def: #export (assert message test)
{#.doc "Fails with the given message if the test is false."}
- (All [s] (-> Text Bool (Parser s Unit)))
+ (All [s] (-> Text Bool (Parser s Top)))
(function (_ input)
(if test
(#e.Success [input []])
@@ -192,7 +192,7 @@
)))
(def: #export (not p)
- (All [s a] (-> (Parser s a) (Parser s Unit)))
+ (All [s a] (-> (Parser s a) (Parser s Top)))
(function (_ input)
(case (p input)
(#e.Error msg)
diff --git a/stdlib/source/lux/control/pipe.lux b/stdlib/source/lux/control/pipe.lux
index 7e55fc447..4e84e7832 100644
--- a/stdlib/source/lux/control/pipe.lux
+++ b/stdlib/source/lux/control/pipe.lux
@@ -35,7 +35,7 @@
(~ body))))))
(def: _reverse_
- (Syntax Unit)
+ (Syntax Top)
(function (_ tokens)
(#e.Success [(list.reverse tokens) []])))
diff --git a/stdlib/source/lux/control/region.lux b/stdlib/source/lux/control/region.lux
index f21076ad0..e26a23ab9 100644
--- a/stdlib/source/lux/control/region.lux
+++ b/stdlib/source/lux/control/region.lux
@@ -9,7 +9,7 @@
(coll [list "list/" Fold]))))
(type: (Cleaner r m)
- (-> r (m (Error Unit))))
+ (-> r (m (Error Top))))
(type: #export (Region r m a)
(-> [r (List (Cleaner r m))]
@@ -36,7 +36,7 @@
error|output))))
(def: (combine-outcomes clean-up output)
- (All [a] (-> (Error Unit) (Error a) (Error a)))
+ (All [a] (-> (Error Top) (Error a) (Error a)))
(case clean-up
(#e.Success _)
output
@@ -55,7 +55,7 @@
(wrap (list/fold combine-outcomes output results))))
(def: #export (acquire Monad cleaner value)
- (All [m a] (-> (Monad m) (-> a (m (Error Unit))) a
+ (All [m a] (-> (Monad m) (-> a (m (Error Top))) a
(All [r] (Region r m a))))
(function (_ [region cleaners])
(:: Monad wrap [(#.Cons (function (_ region) (cleaner value))
diff --git a/stdlib/source/lux/control/state.lux b/stdlib/source/lux/control/state.lux
index 422cf4fc6..ab69ed9fe 100644
--- a/stdlib/source/lux/control/state.lux
+++ b/stdlib/source/lux/control/state.lux
@@ -52,13 +52,13 @@
(def: #export (put new-state)
{#.doc "Set the new state."}
- (All [s] (-> s (State s Unit)))
+ (All [s] (-> s (State s Top)))
(function (_ state)
[new-state []]))
(def: #export (update change)
{#.doc "Compute the new state."}
- (All [s] (-> (-> s s) (State s Unit)))
+ (All [s] (-> (-> s s) (State s Top)))
(function (_ state)
[(change state) []]))
@@ -134,7 +134,7 @@
(wrap [state a]))))
(def: #export (while condition body)
- (All [s] (-> (State s Bool) (State s Unit) (State s Unit)))
+ (All [s] (-> (State s Bool) (State s Top) (State s Top)))
(do Monad
[execute? condition]
(if execute?
@@ -144,7 +144,7 @@
(wrap []))))
(def: #export (do-while condition body)
- (All [s] (-> (State s Bool) (State s Unit) (State s Unit)))
+ (All [s] (-> (State s Bool) (State s Top) (State s Top)))
(do Monad
[_ body]
(while condition body)))
diff --git a/stdlib/source/lux/control/thread.lux b/stdlib/source/lux/control/thread.lux
index d79cc0d10..e44869043 100644
--- a/stdlib/source/lux/control/thread.lux
+++ b/stdlib/source/lux/control/thread.lux
@@ -23,7 +23,7 @@
("lux box read" box)))
(def: #export (write value box)
- (All [a] (-> a (All [!] (-> (Box ! a) (Thread ! Unit)))))
+ (All [a] (-> a (All [!] (-> (Box ! a) (Thread ! Top)))))
(function (_ !)
("lux box write" value box)))
diff --git a/stdlib/source/lux/control/writer.lux b/stdlib/source/lux/control/writer.lux
index c65a9b29e..7f23e2750 100644
--- a/stdlib/source/lux/control/writer.lux
+++ b/stdlib/source/lux/control/writer.lux
@@ -44,7 +44,7 @@
(def: #export (log l)
{#.doc "Set the log to a particular value."}
- (All [l] (-> l (Writer l Unit)))
+ (All [l] (-> l (Writer l Top)))
[l []])
(struct: #export (WriterT Monoid Monad)
diff --git a/stdlib/source/lux/data/format/json.lux b/stdlib/source/lux/data/format/json.lux
index 7dfb7be5e..c4dd43a1c 100644
--- a/stdlib/source/lux/data/format/json.lux
+++ b/stdlib/source/lux/data/format/json.lux
@@ -27,7 +27,7 @@
(do-template [ ]
[(type: #export )]
- [Null Unit]
+ [Null Top]
[Boolean Bool]
[Number Frac]
[String Text]
@@ -237,7 +237,7 @@
_
(fail ($_ text/compose "JSON value is not " ".")))))]
- [null Unit #Null "null"]
+ [null Top #Null "null"]
[boolean Bool #Boolean "boolean"]
[number Frac #Number "number"]
[string Text #String "string"]
@@ -258,7 +258,7 @@
(def: #export ( test)
{#.doc (code.text ($_ text/compose "Ensures a JSON value is a " "."))}
- (-> (Reader Unit))
+ (-> (Reader Top))
(do p.Monad
[head any]
(case head
@@ -398,7 +398,7 @@
(l.some l.space))
(def: data-sep
- (l.Lexer [Text Unit Text])
+ (l.Lexer [Text Top Text])
($_ p.seq space~ (l.this ",") space~))
(def: null~
@@ -470,7 +470,7 @@
(wrap chars))))
(def: (kv~ json~)
- (-> (-> Unit (l.Lexer JSON)) (l.Lexer [String JSON]))
+ (-> (-> Top (l.Lexer JSON)) (l.Lexer [String JSON]))
(do p.Monad
[key string~
_ space~
@@ -481,7 +481,7 @@
(do-template [ ]
[(def: ( json~)
- (-> (-> Unit (l.Lexer JSON)) (l.Lexer ))
+ (-> (-> Top (l.Lexer JSON)) (l.Lexer ))
(do p.Monad
[_ (l.this )
_ space~
@@ -495,7 +495,7 @@
)
(def: (json~' _)
- (-> Unit (l.Lexer JSON))
+ (-> Top (l.Lexer JSON))
($_ p.alt null~ boolean~ number~ string~ (array~ json~') (object~ json~')))
(struct: #export _ (Codec Text JSON)
diff --git a/stdlib/source/lux/data/format/xml.lux b/stdlib/source/lux/data/format/xml.lux
index 23b12a42d..d3c6292cd 100644
--- a/stdlib/source/lux/data/format/xml.lux
+++ b/stdlib/source/lux/data/format/xml.lux
@@ -304,7 +304,7 @@
(#E.Error error)))
(def: #export (node tag)
- (-> Ident (Reader Unit))
+ (-> Ident (Reader Top))
(function (_ docs)
(case docs
#.Nil
@@ -338,7 +338,7 @@
(wrap [tail output]))))))
(def: #export ignore
- (Reader Unit)
+ (Reader Top)
(function (_ docs)
(case docs
#.Nil
diff --git a/stdlib/source/lux/data/text/lexer.lux b/stdlib/source/lux/data/text/lexer.lux
index 338e2b5ac..980926b90 100644
--- a/stdlib/source/lux/data/text/lexer.lux
+++ b/stdlib/source/lux/data/text/lexer.lux
@@ -63,7 +63,7 @@
(def: #export (this reference)
{#.doc "Lex a text if it matches the given sample."}
- (-> Text (Lexer Unit))
+ (-> Text (Lexer Top))
(function (_ [offset tape])
(case (text.index-of' reference offset tape)
(#.Some where)
@@ -87,7 +87,7 @@
(def: #export end
{#.doc "Ensure the lexer's input is empty."}
- (Lexer Unit)
+ (Lexer Top)
(function (_ (^@ input [offset tape]))
(if (n/= offset (text.size tape))
(#e.Success [input []])
diff --git a/stdlib/source/lux/data/text/regex.lux b/stdlib/source/lux/data/text/regex.lux
index 102f9632f..4bdc6d3c0 100644
--- a/stdlib/source/lux/data/text/regex.lux
+++ b/stdlib/source/lux/data/text/regex.lux
@@ -309,7 +309,7 @@
))
(def: (unflatten^ lexer)
- (-> (l.Lexer Text) (l.Lexer [Text Unit]))
+ (-> (l.Lexer Text) (l.Lexer [Text Top]))
(p.seq lexer (:: p.Monad wrap [])))
(def: (|||^ left right)
diff --git a/stdlib/source/lux/host.jvm.lux b/stdlib/source/lux/host.jvm.lux
index 719f6dd6e..8bc565545 100644
--- a/stdlib/source/lux/host.jvm.lux
+++ b/stdlib/source/lux/host.jvm.lux
@@ -15,7 +15,7 @@
[macro #+ with-gensyms Functor Monad]
(macro [code]
["s" syntax #+ syntax: Syntax])
- (lang [type])
+ (lang [type "type/" Eq])
))
(do-template [ ]
@@ -246,7 +246,7 @@
["float" (primitive "java.lang.Float")]
["double" (primitive "java.lang.Double")]
["char" (primitive "java.lang.Character")]
- ["void" .Unit])
+ ["void" .Top])
_
#.None))
@@ -264,7 +264,7 @@
["long" .Int]
["float" .Frac]
["double" .Frac]
- ["void" .Unit])
+ ["void" .Top])
_
#.None))
@@ -530,7 +530,7 @@
(-> Text Text (Syntax Code))
(do p.Monad
[#let [dotted-name (format "::" field-name)]
- [_ _ value] (: (Syntax [Unit Unit Code])
+ [_ _ value] (: (Syntax [Top Top Code])
(s.form ($_ p.seq (s.this (' :=)) (s.this (code.symbol ["" dotted-name])) s.any)))]
(wrap (`' ((~ (code.text (format "jvm putfield" ":" class-name ":" field-name))) _jvm_this (~ value))))))
@@ -657,7 +657,7 @@
(s.this (' >))))
(def: (assert-no-periods name)
- (-> Text (Syntax Unit))
+ (-> Text (Syntax Top))
(p.assert "Names in class declarations cannot contain periods."
(not (text.contains? "." name))))
@@ -1809,8 +1809,8 @@
(` ((~ setter-name) (~ g!value)))
(` ((~ setter-name) (~ g!value) (~ g!obj))))
setter-type (if import-field-static?
- (` (All [(~+ tvar-asts)] (-> (~ typeC) (IO Unit))))
- (` (All [(~+ tvar-asts)] (-> (~ typeC) (~ classC) (IO Unit)))))
+ (` (All [(~+ tvar-asts)] (-> (~ typeC) (IO Top))))
+ (` (All [(~+ tvar-asts)] (-> (~ typeC) (~ classC) (IO Top)))))
setter-value (with-mode-field-set import-field-mode import-field-type g!value)
setter-value (if import-field-maybe?
(` (!!! (~ setter-value)))
@@ -1942,27 +1942,25 @@
(def: (type->class-name type)
(-> Type (Meta Text))
- (case type
- (#.Primitive name params)
- (:: Monad wrap name)
+ (if (type/= Top type)
+ (:: Monad wrap "java.lang.Object")
+ (case type
+ (#.Primitive name params)
+ (:: Monad wrap name)
- (#.Apply A F)
- (case (type.apply (list A) F)
- #.None
- (macro.fail (format "Cannot apply type: " (type.to-text F) " to " (type.to-text A)))
+ (#.Apply A F)
+ (case (type.apply (list A) F)
+ #.None
+ (macro.fail (format "Cannot apply type: " (type.to-text F) " to " (type.to-text A)))
- (#.Some type')
- (type->class-name type'))
-
- (#.Named _ type')
- (type->class-name type')
+ (#.Some type')
+ (type->class-name type'))
+
+ (#.Named _ type')
+ (type->class-name type')
- #.Unit
- (:: Monad wrap "java.lang.Object")
-
- (^or #.Void (#.Var _) (#.Ex _) (#.Bound _) (#.Sum _) (#.Product _) (#.Function _) (#.UnivQ _) (#.ExQ _))
- (macro.fail (format "Cannot convert to JvmType: " (type.to-text type)))
- ))
+ _
+ (macro.fail (format "Cannot convert to JvmType: " (type.to-text type))))))
(syntax: #export (array-read idx array)
{#.doc (doc "Loads an element from an array."
diff --git a/stdlib/source/lux/io.lux b/stdlib/source/lux/io.lux
index 613959b4f..72307c301 100644
--- a/stdlib/source/lux/io.lux
+++ b/stdlib/source/lux/io.lux
@@ -9,7 +9,7 @@
(type: #export (IO a)
{#.doc "A type that represents synchronous, effectful computations that may interact with the outside world."}
- (-> Void a))
+ (-> Bottom a))
(macro: #export (io tokens state)
{#.doc (doc "Delays the evaluation of an expression, by wrapping it in an IO 'thunk'."
@@ -27,13 +27,13 @@
(struct: #export _ (Functor IO)
(def: (map f ma)
- (io (f (ma (:! Void []))))))
+ (io (f (ma (:! Bottom []))))))
(struct: #export _ (Apply IO)
(def: functor Functor)
(def: (apply ff fa)
- (io ((ff (:! Void [])) (fa (:! Void []))))))
+ (io ((ff (:! Bottom [])) (fa (:! Bottom []))))))
(struct: #export _ (Monad IO)
(def: functor Functor)
@@ -42,12 +42,12 @@
(io x))
(def: (join mma)
- (io ((mma (:! Void [])) (:! Void [])))))
+ (io ((mma (:! Bottom [])) (:! Bottom [])))))
(def: #export (run action)
{#.doc "A way to execute IO computations and perform their side-effects."}
(All [a] (-> (IO a) a))
- (action (:! Void [])))
+ (action (:! Bottom [])))
## Process
(type: #export (Process a)
diff --git a/stdlib/source/lux/lang/syntax.lux b/stdlib/source/lux/lang/syntax.lux
index 0fefc1929..d30436533 100644
--- a/stdlib/source/lux/lang/syntax.lux
+++ b/stdlib/source/lux/lang/syntax.lux
@@ -82,7 +82,7 @@
## This is just a helper parser to find text which doesn't run into
## any special character sequences for multi-line comments.
(def: comment-bound^
- (l.Lexer Unit)
+ (l.Lexer Top)
($_ p.either
(l.this new-line)
(l.this ")#")
diff --git a/stdlib/source/lux/lang/type.lux b/stdlib/source/lux/lang/type.lux
index 35c2cd29c..48db0b928 100644
--- a/stdlib/source/lux/lang/type.lux
+++ b/stdlib/source/lux/lang/type.lux
@@ -53,11 +53,6 @@
true
(list.zip2 xparams yparams)))
- (^template []
- [ ]
- true)
- ([#.Void] [#.Unit])
-
(^template []
[( xid) ( yid)]
(n/= yid xid))
@@ -171,11 +166,6 @@
(` (#.Primitive (~ (code.text name))
(.list (~+ (list/map to-code params)))))
- (^template []
-
- (` ))
- ([#.Void] [#.Unit])
-
(^template []
( idx)
(` ( (~ (code.nat idx)))))
@@ -208,12 +198,6 @@
_
($_ text/compose "(primitive " name " " (|> params (list/map to-text) list.reverse (list.interpose " ") (list/fold text/compose "")) ")"))
- #.Void
- "Void"
-
- #.Unit
- "Unit"
-
(^template [ ]
( _)
($_ text/compose
@@ -290,8 +274,8 @@
(#.Cons type types')
( type ( types'))))]
- [variant Void #.Sum]
- [tuple Unit #.Product]
+ [variant Bottom #.Sum]
+ [tuple Top #.Product]
)
(def: #export (function inputs output)
diff --git a/stdlib/source/lux/lang/type/check.lux b/stdlib/source/lux/lang/type/check.lux
index f71ac4150..1853f0931 100644
--- a/stdlib/source/lux/lang/type/check.lux
+++ b/stdlib/source/lux/lang/type/check.lux
@@ -199,7 +199,7 @@
(ex.throw unknown-type-var id))))
(def: #export (write type id)
- (-> Type Var (Check Unit))
+ (-> Type Var (Check Top))
(function (_ context)
(case (|> context (get@ #.var-bindings) (var::get id))
(#.Some (#.Some bound))
@@ -213,7 +213,7 @@
(ex.throw unknown-type-var id))))
(def: (update type id)
- (-> Type Var (Check Unit))
+ (-> Type Var (Check Top))
(function (_ context)
(case (|> context (get@ #.var-bindings) (var::get id))
(#.Some _)
@@ -239,7 +239,7 @@
(get@ #.var-bindings context)])))
(def: (set-bindings value)
- (-> (List [Var (Maybe Type)]) (Check Unit))
+ (-> (List [Var (Maybe Type)]) (Check Top))
(function (_ context)
(#e.Success [(set@ #.var-bindings value context)
[]])))
@@ -315,7 +315,7 @@
(#e.Error message)))
(def: #export (assert message test)
- (-> Text Bool (Check Unit))
+ (-> Text Bool (Check Top))
(function (_ context)
(if test
(#e.Success [context []])
@@ -361,13 +361,13 @@
(else (maybe.default (#.Var id) ?bound)))))
(def: (link-2 left right)
- (-> Var Var (Check Unit))
+ (-> Var Var (Check Top))
(do Monad
[_ (write (#.Var right) left)]
(write (#.Var left) right)))
(def: (link-3 interpose to from)
- (-> Var Var Var (Check Unit))
+ (-> Var Var Var (Check Top))
(do Monad
[_ (update (#.Var interpose) from)]
(update (#.Var to) interpose)))
@@ -445,7 +445,7 @@
(check' etype atype assumptions))))))
(def: (with-error-stack on-error check)
- (All [a] (-> (-> Unit Text) (Check a) (Check a)))
+ (All [a] (-> (-> Top Text) (Check a) (Check a)))
(function (_ context)
(case (check context)
(#e.Error error)
@@ -592,16 +592,13 @@
(check/wrap assumptions))
(fail ""))
- (^template [ ]
- [ ]
- (check/wrap assumptions)
-
+ (^template []
[( eL eR) ( aL aR)]
(do Monad
[assumptions (check' eL aL assumptions)]
(check' eR aR assumptions)))
- ([#.Void #.Sum]
- [#.Unit #.Product])
+ ([#.Sum]
+ [#.Product])
[(#.Function eI eO) (#.Function aI aO)]
(do Monad
@@ -624,7 +621,7 @@
(def: #export (check expected actual)
{#.doc "Type-check to ensure that the 'expected' type subsumes the 'actual' type."}
- (-> Type Type (Check Unit))
+ (-> Type Type (Check Top))
(do Monad
[assumptions (check' expected actual (list))]
(wrap [])))
@@ -652,7 +649,7 @@
[paramsT+' (monad.map @ clean paramsT+)]
(wrap (#.Primitive name paramsT+')))
- (^or #.Void #.Unit (#.Bound _) (#.Ex _) (#.Named _))
+ (^or (#.Bound _) (#.Ex _) (#.Named _))
(:: Monad wrap inputT)
(^template []
diff --git a/stdlib/source/lux/macro.lux b/stdlib/source/lux/macro.lux
index 238028f52..9b2b5fac8 100644
--- a/stdlib/source/lux/macro.lux
+++ b/stdlib/source/lux/macro.lux
@@ -97,7 +97,7 @@
(def: #export (assert message test)
{#.doc "Fails with the given message if the test is false."}
- (-> Text Bool (Meta Unit))
+ (-> Text Bool (Meta Top))
(function (_ compiler)
(if test
(#e.Success [compiler []])
diff --git a/stdlib/source/lux/macro/poly.lux b/stdlib/source/lux/macro/poly.lux
index b9336139b..f3537d6f0 100644
--- a/stdlib/source/lux/macro/poly.lux
+++ b/stdlib/source/lux/macro/poly.lux
@@ -20,7 +20,7 @@
(syntax ["cs" common]
(common ["csr" reader]
["csw" writer])))
- (lang [type]
+ (lang [type "type/" Eq]
(type [check]))
))
@@ -117,7 +117,7 @@
(do-template [ ]
[(def: #export
- (Poly Unit)
+ (Poly Top)
(do p.Monad
[headT any]
(case (type.un-name headT)
@@ -127,8 +127,6 @@
_
(p.fail ($_ text/compose "Not " " type: " (type.to-text headT))))))]
- [void "Void" #.Void]
- [unit "Unit" #.Unit]
[bool "Bool" (#.Primitive "#Bool" #.Nil)]
[nat "Nat" (#.Primitive "#Nat" #.Nil)]
[int "Int" (#.Primitive "#Int" #.Nil)]
@@ -142,8 +140,6 @@
(do p.Monad
[headT any]
(case (run headT ($_ p.either
- void
- unit
bool
nat
int
@@ -206,7 +202,7 @@
list.reverse))))]
(recur (n/inc current-arg)
(|> env'
- (dict.put partialI [.Void partialC])
+ (dict.put partialI [.Bottom partialC])
(dict.put partial-varI [(#.Bound partial-varI) partial-varL]))
(#.Cons partial-varL all-varsL))))
[all-varsL env']))]]
@@ -236,10 +232,10 @@
(local (#.Cons funcT paramsT) poly))))
(def: #export (this expected)
- (-> Type (Poly Unit))
+ (-> Type (Poly Top))
(do p.Monad
[actual any]
- (if (check.checks? expected actual)
+ (if (type/= expected actual)
(wrap [])
(p.fail ($_ text/compose
"Types do not match." "\n"
@@ -271,7 +267,7 @@
(p.fail ($_ text/compose "Not a bound type: " (type.to-text headT))))))
(def: #export (var id)
- (-> Nat (Poly Unit))
+ (-> Nat (Poly Top))
(do p.Monad
[env ..env
headT any]
@@ -316,10 +312,10 @@
(do p.Monad
[headT any]
(case (type.un-name headT)
- (#.Apply #.Void (#.UnivQ _ headT'))
+ (#.Apply (#.Named ["lux" "Bottom"] _) (#.UnivQ _ headT'))
(do @
[[recT _ output] (|> poly
- (with-extension #.Void)
+ (with-extension .Bottom)
(with-extension headT)
(local (list headT')))]
(wrap [recT output]))
@@ -333,7 +329,7 @@
[env ..env
headT any]
(case (type.un-name headT)
- (^multi (#.Apply #.Void (#.Bound funcT-idx))
+ (^multi (#.Apply (#.Named ["lux" "Bottom"] _) (#.Bound funcT-idx))
(n/= +0 (adjusted-idx env funcT-idx))
[(dict.get +0 env) (#.Some [self-type self-call])])
(wrap self-call)
@@ -429,11 +425,6 @@
(` (#.Primitive (~ (code.text name))
(list (~+ (list/map (to-code env) params)))))
- (^template []
-
- (` ))
- ([#.Void] [#.Unit])
-
(^template []
( idx)
(` ( (~ (code.nat idx)))))
@@ -445,7 +436,7 @@
(|> (dict.get idx env) maybe.assume product.left (to-code env))
(` (.$ (~ (code.nat (n/dec idx)))))))
- (#.Apply #.Void (#.Bound idx))
+ (#.Apply (#.Named ["lux" "Bottom"] _) (#.Bound idx))
(let [idx (adjusted-idx env idx)]
(if (n/= +0 idx)
(|> (dict.get idx env) maybe.assume product.left (to-code env))
diff --git a/stdlib/source/lux/macro/poly/eq.lux b/stdlib/source/lux/macro/poly/eq.lux
index 7990bd3c4..6206c9861 100644
--- a/stdlib/source/lux/macro/poly/eq.lux
+++ b/stdlib/source/lux/macro/poly/eq.lux
@@ -45,7 +45,7 @@
(wrap (` (: (~ (@Eq inputT))
))))]
- [poly.unit (function ((~ g!_) (~ g!_) (~ g!_)) true)]
+ [(poly.this Top) (function ((~ g!_) (~ g!_) (~ g!_)) true)]
[poly.bool bool.Eq]
[poly.nat number.Eq]
[poly.int number.Eq]
diff --git a/stdlib/source/lux/macro/poly/json.lux b/stdlib/source/lux/macro/poly/json.lux
index 38bf86866..971048296 100644
--- a/stdlib/source/lux/macro/poly/json.lux
+++ b/stdlib/source/lux/macro/poly/json.lux
@@ -79,19 +79,19 @@
(poly: Codec//encode
(with-expansions
- [ (do-template [ ]
+ [ (do-template [ ]
[(do @
[#let [g!_ (code.local-symbol "_______")]
_ ]
(wrap (` (: (~ (@JSON//encode inputT))
))))]
- [Unit poly.unit (function ((~ g!_) (~ (code.symbol ["" "0"]))) #//.Null)]
- [Bool poly.bool (|>> #//.Boolean)]
- [Nat poly.nat (:: (~! ..Codec) (~' encode))]
- [Int poly.int (:: (~! ..Codec) (~' encode))]
- [Frac poly.frac (|>> #//.Number)]
- [Text poly.text (|>> #//.String)])
+ [(poly.this Top) (function ((~ g!_) (~ (code.symbol ["" "0"]))) #//.Null)]
+ [poly.bool (|>> #//.Boolean)]
+ [poly.nat (:: (~! ..Codec) (~' encode))]
+ [poly.int (:: (~! ..Codec) (~' encode))]
+ [poly.frac (|>> #//.Number)]
+ [poly.text (|>> #//.String)])