ddc-source-tetra-0.4.2.1: DDC/Source/Tetra/Parser/Param.hs
-- | Desugaring of function parameter syntax in Source Tetra.
module DDC.Source.Tetra.Parser.Param
( ParamSpec (..)
, funTypeOfParams
, pBindParamSpec
, expOfParams)
where
import DDC.Source.Tetra.Exp.Annot
import DDC.Core.Parser
( ParamSpec(..)
, funTypeOfParams
, pBindParamSpec)
-- | Build the expression of a function from specifications of its parameters,
-- and the expression for the body.
expOfParams
:: a
-> [ParamSpec Name] -- ^ Spec of parameters.
-> Exp a -- ^ Body of function.
-> Exp a -- ^ Expression of whole function.
expOfParams _ [] xBody = xBody
expOfParams a (p:ps) xBody
= case p of
ParamType b
-> XLAM a b $ expOfParams a ps xBody
ParamWitness b
-> XLam a b $ expOfParams a ps xBody
ParamValue b _ _
-> XLam a b $ expOfParams a ps xBody