module FreeC.Backend.Coq.Converter.FuncDecl where
import Control.Monad.Extra ( concatMapM )
import FreeC.Backend.Coq.Converter.FuncDecl.NonRec
import FreeC.Backend.Coq.Converter.FuncDecl.Rec
import qualified FreeC.Backend.Coq.Syntax as Coq
import FreeC.IR.DependencyGraph
import qualified FreeC.IR.Syntax as IR
import FreeC.Monad.Converter
convertFuncDecls :: [IR.FuncDecl] -> Converter [Coq.Sentence]
convertFuncDecls funcDecls = do
let components = valueDependencyComponents funcDecls
concatMapM convertFuncComponent components
convertFuncComponent
:: DependencyComponent IR.FuncDecl -> Converter [Coq.Sentence]
convertFuncComponent (NonRecursive decl)
= return <$> convertNonRecFuncDecl decl
convertFuncComponent (Recursive decls) = convertRecFuncDecls decls