packages feed

phino-0.0.0.68 / src / Deps.hs

-- SPDX-FileCopyrightText: Copyright (c) 2025 Objectionary.com-- SPDX-License-Identifier: MIT-- The main goal of this module is breaking cyclic dependency:-- Dataize -> Functions -> Rewriter -> Dataize-- Here we provide custom type BuildTermFunc and add it to-- RewriteContext and DataizeContext. Now Dataize and Rewrite depends-- only on Term module. This allows us to use Rewriter and Dataize in-- Functions module because Rewriter does not depend on Functions anymore.module Deps whereimport ASTimport Logger (logDebug)import Matcherimport System.Directory (createDirectoryIfMissing)import System.FilePathimport Text.Printf (printf)import Yamldata Term  = TeExpression Expression  | TeAttribute Attribute  | TeBytes Bytes  | TeBindings [Binding]type BuildTermMethod = [ExtraArgument] -> Subst -> IO Termtype BuildTermFunc = String -> BuildTermMethodtype SaveStepFunc = Program -> Int -> IO ()saveStep :: Maybe FilePath -> String -> (Program -> IO String) -> SaveStepFuncsaveStep Nothing _ _ _ _ = pure ()saveStep (Just dir) ext render prog step = do  createDirectoryIfMissing True dir  let path = dir </> printf "%05d.%s" step ext  content <- render prog  writeFile path content  logDebug (printf "Saved step '%d' to '%s'" step path)dontSaveStep :: SaveStepFuncdontSaveStep = saveStep Nothing "" (\_ -> pure "")