diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/compiler/default/phase/synthesis.lux | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/stdlib/source/lux/compiler/default/phase/synthesis.lux b/stdlib/source/lux/compiler/default/phase/synthesis.lux index 29c2189c3..bf60c9798 100644 --- a/stdlib/source/lux/compiler/default/phase/synthesis.lux +++ b/stdlib/source/lux/compiler/default/phase/synthesis.lux @@ -3,8 +3,11 @@ [control [monad (#+ do)]] [data [error (#+ Error)] + ["." text + format] [collection - ["dict" dictionary (#+ Dictionary)]]]] + [list ("list/." Functor<List>)] + ["." dictionary (#+ Dictionary)]]]] ["." // ["." analysis (#+ Environment Arity Analysis)] ["." extension (#+ Extension)] @@ -21,7 +24,7 @@ (def: #export fresh-resolver Resolver - (dict.new reference.Hash<Variable>)) + (dictionary.new reference.Hash<Variable>)) (def: #export init State @@ -268,3 +271,30 @@ [function/abstraction #..Function #..Abstraction] [function/apply #..Function #..Apply] ) + +(def: #export (%synthesis value) + (Format Synthesis) + (case value + (^template [<pattern> <format>] + (^ (<pattern> value)) + (<format> value)) + ([..bit %b] + [..f64 %f] + [..text %t]) + + (^ (..i64 value)) + (%n (.nat value)) + + (^ (..variant [lefts right? content])) + (|> (%synthesis content) + (format (%n lefts) " " (%b right?) " ") + (text.enclose ["(" ")"])) + + (^ (..tuple members)) + (|> members + (list/map %synthesis) + (text.join-with " ") + (text.enclose ["[" "]"])) + + _ + "???")) |