aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
authorEduardo Julian2016-12-18 15:35:28 -0400
committerEduardo Julian2016-12-18 15:35:28 -0400
commita6b97572ae0b3442f3996bdaf2742cd855ef0983 (patch)
treef12e0ebeaa38c4fd9cfe4b69c4fcd74d34f1c9e3 /stdlib/source
parent47e7627e05f2f961794e312e28bf8a437a1e0c78 (diff)
- Better formatting for types and lists.
Diffstat (limited to 'stdlib/source')
-rw-r--r--stdlib/source/lux/data/text/format.lux7
-rw-r--r--stdlib/source/lux/type.lux14
2 files changed, 13 insertions, 8 deletions
diff --git a/stdlib/source/lux/data/text/format.lux b/stdlib/source/lux/data/text/format.lux
index 743502d11..95dd10914 100644
--- a/stdlib/source/lux/data/text/format.lux
+++ b/stdlib/source/lux/data/text/format.lux
@@ -51,4 +51,9 @@
(def: #export (%list formatter)
(All [a] (-> (Formatter a) (Formatter (List a))))
(lambda [values]
- (format "(list " (text;join-with " " (map formatter values)) ")")))
+ (case values
+ #;Nil
+ "(list)"
+
+ _
+ (format "(list " (text;join-with " " (map formatter values)) ")"))))
diff --git a/stdlib/source/lux/type.lux b/stdlib/source/lux/type.lux
index 91b44bfd8..c81d5e23d 100644
--- a/stdlib/source/lux/type.lux
+++ b/stdlib/source/lux/type.lux
@@ -216,10 +216,10 @@
(#;HostT name params)
(case params
#;Nil
- ($_ Text/append "(^ " name ")")
+ ($_ Text/append "(host " name ")")
_
- ($_ Text/append "(^ " name " " (|> params (List/map to-text) list;reverse (list;interpose " ") (List/fold Text/append "")) ")"))
+ ($_ Text/append "(host " name " " (|> params (List/map to-text) list;reverse (list;interpose " ") (List/fold Text/append "")) ")"))
#;VoidT
"Void"
@@ -262,11 +262,11 @@
(let [[type-fun type-args] (flatten-application type)]
($_ Text/append "(" (to-text type-fun) " " (|> type-args (List/map to-text) list;reverse (list;interpose " ") (List/fold Text/append "")) ")"))
- (#;UnivQ env body)
- ($_ Text/append "(All " (to-text body) ")")
-
- (#;ExQ env body)
- ($_ Text/append "(Ex " (to-text body) ")")
+ (^template [<tag> <desc>]
+ (<tag> env body)
+ ($_ Text/append "(" <desc> " {" (|> env (List/map to-text) (text;join-with " ")) "} " (to-text body) ")"))
+ ([#;UnivQ "All"]
+ [#;ExQ "Ex"])
(#;NamedT [module name] type)
($_ Text/append module ";" name)