(.module:
lux
(lux (control [monad #+ do])
(data [text]
text/format)
[macro])
(luxc ["&" lang]
(lang [synthesis #+ Synthesis]
(host [r #+ 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 (r.list elemsT+)))))
(def: #export (translate-variant translate tag tail? valueS)
(-> (-> Synthesis (Meta Expression)) Nat Bool Synthesis (Meta Expression))
(do macro.Monad
[valueT (translate valueS)]
(wrap (runtimeT.variant tag tail? valueT))))