module CondCompile (condCompile) where
import Curry.Base.Monad
import Curry.CondCompile.Transform (condTransform)
import CompilerOpts (CppOpts (..))
condCompile :: CppOpts -> FilePath -> String -> CYIO String
condCompile :: CppOpts -> FilePath -> FilePath -> CYIO FilePath
condCompile opts :: CppOpts
opts fn :: FilePath
fn p :: FilePath
p
| Bool -> Bool
not (CppOpts -> Bool
cppRun CppOpts
opts) = FilePath -> CYIO FilePath
forall (m :: * -> *) a. Monad m => a -> m a
return FilePath
p
| Bool
otherwise = (Message -> CYIO FilePath)
-> (FilePath -> CYIO FilePath)
-> Either Message FilePath
-> CYIO FilePath
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either ([Message] -> CYIO FilePath
forall (m :: * -> *) a. Monad m => [Message] -> CYT m a
failMessages ([Message] -> CYIO FilePath)
-> (Message -> [Message]) -> Message -> CYIO FilePath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Message -> [Message] -> [Message]
forall a. a -> [a] -> [a]
: []))
FilePath -> CYIO FilePath
forall (m :: * -> *) a. Monad m => a -> CYT m a
ok
(CCState -> FilePath -> FilePath -> Either Message FilePath
condTransform (CppOpts -> CCState
cppDefinitions CppOpts
opts) FilePath
fn FilePath
p)