(.module:
lux
(lux (control [monad #+ do])
(data [text]
text/format)
[macro])
(luxc ["&" lang]
(lang [synthesis #+ Synthesis]
(host [python #+ Expression Statement])))
[//]
(// [".T" runtime]))
(def: #export (translate-tuple translate elemsS+)
(-> (-> Synthesis (Meta Expression)) (List Synthesis) (Meta Expression))
(case elemsS+
#.Nil
(:: macro.Monad wrap runtimeT.unit)
(#.Cons singletonS #.Nil)
(translate singletonS)
_
(do macro.Monad
[elemsT+ (monad.map @ translate elemsS+)]
(wrap (python.tuple elemsT+)))))
(def: #export (translate-variant translate tag tail? valueS)
(-> (-> Synthesis (Meta Expression)) Nat Bit Synthesis (Meta Expression))
(do macro.Monad
[valueT (translate valueS)]
(wrap (runtimeT.variant tag tail? valueT))))