diff --git a/src-libinterfacetests/Main.hs b/src-libinterfacetests/Main.hs index 457a689..8334328 100644 --- a/src-libinterfacetests/Main.hs +++ b/src-libinterfacetests/Main.hs @@ -25,7 +25,7 @@ main = hspec $ do , " , 00000000000000000000000" , " ]" ] - output <- liftIO $ pureModuleTransform mempty input + output <- liftIO $ parsePrintModule staticDefaultConfig input input `shouldSatisfy` \_ -> case output of Right x | x == expected -> True _ -> False diff --git a/src-literatetests/Main.hs b/src-literatetests/Main.hs index 9196dba..fdac364 100644 --- a/src-literatetests/Main.hs +++ b/src-literatetests/Main.hs @@ -131,7 +131,7 @@ main = do roundTripEqual :: Text -> Expectation roundTripEqual t = fmap (fmap PPTextWrapper) - (parsePrintModule defaultTestConfig "TestFakeFileName.hs" t) + (parsePrintModuleTests defaultTestConfig "TestFakeFileName.hs" t) `shouldReturn` Right (PPTextWrapper t) newtype PPTextWrapper = PPTextWrapper Text diff --git a/src-unittests/TestUtils.hs b/src-unittests/TestUtils.hs index 9659e47..e94267a 100644 --- a/src-unittests/TestUtils.hs +++ b/src-unittests/TestUtils.hs @@ -23,7 +23,7 @@ import Data.Coerce ( coerce ) roundTripEqual :: Text -> Expectation roundTripEqual t = fmap (fmap PPTextWrapper) - (parsePrintModule defaultTestConfig "TestFakeFileName.hs" t) + (parsePrintModuleTests defaultTestConfig "TestFakeFileName.hs" t) `shouldReturn` Right (PPTextWrapper t) roundTripEqualWithTimeout :: Int -> Text -> Expectation @@ -31,7 +31,7 @@ roundTripEqualWithTimeout time t = timeout time (action >>= evaluate) >>= (`shouldSatisfy`Data.Maybe.isJust) where action = fmap (fmap PPTextWrapper) - (parsePrintModule defaultTestConfig "TestFakeFileName.hs" t) + (parsePrintModuleTests defaultTestConfig "TestFakeFileName.hs" t) newtype PPTextWrapper = PPTextWrapper Text deriving Eq diff --git a/src/Language/Haskell/Brittany.hs b/src/Language/Haskell/Brittany.hs index 67bae06..706984b 100644 --- a/src/Language/Haskell/Brittany.hs +++ b/src/Language/Haskell/Brittany.hs @@ -1,8 +1,15 @@ {-# LANGUAGE DataKinds #-} module Language.Haskell.Brittany - ( pureModuleTransform - , CConfig + ( parsePrintModule + , staticDefaultConfig + , Config + , CConfig(..) + , CDebugConfig(..) + , CLayoutConfig(..) + , CErrorHandlingConfig(..) + , CForwardOptions(..) + , CPreProcessorConfig(..) , BrittanyError(..) ) where diff --git a/src/Language/Haskell/Brittany/Internal.hs b/src/Language/Haskell/Brittany/Internal.hs index d799290..6ed1dd8 100644 --- a/src/Language/Haskell/Brittany/Internal.hs +++ b/src/Language/Haskell/Brittany/Internal.hs @@ -1,8 +1,8 @@ {-# LANGUAGE DataKinds #-} module Language.Haskell.Brittany.Internal - ( pureModuleTransform - , parsePrintModule + ( parsePrintModule + , parsePrintModuleTests , pPrintModule , pPrintModuleAndCheck -- re-export from utils: @@ -60,9 +60,8 @@ import qualified GHC.LanguageExtensions.Type as GHC -- -- Note that this function ignores/resets all config values regarding -- debugging, i.e. it will never use `trace`/write to stderr. -pureModuleTransform :: CConfig Option -> Text -> IO (Either [BrittanyError] Text) -pureModuleTransform oConfigRaw inputText = runEitherT $ do - let configRaw = cZipWith fromOptionIdentity staticDefaultConfig oConfigRaw +parsePrintModule :: Config -> Text -> IO (Either [BrittanyError] Text) +parsePrintModule configRaw inputText = runEitherT $ do let config = configRaw { _conf_debug = _conf_debug staticDefaultConfig } let ghcOptions = config & _conf_forward & _options_ghc & runIdentity let config_pp = config & _conf_preprocessor @@ -173,8 +172,9 @@ pPrintModuleAndCheck conf anns parsedModule = do -- used for testing mostly, currently. -parsePrintModule :: Config -> String -> Text -> IO (Either String Text) -parsePrintModule conf filename input = do +-- TODO: use parsePrintModule instead and remove this function. +parsePrintModuleTests :: Config -> String -> Text -> IO (Either String Text) +parsePrintModuleTests conf filename input = do let inputStr = Text.unpack input parseResult <- ExactPrint.Parsers.parseModuleFromString filename inputStr case parseResult of @@ -204,8 +204,8 @@ parsePrintModule conf filename input = do -- Unfortunately that does not exist yet, so we cannot provide a nominally -- pure interface. --- parsePrintModule :: Text -> Either String Text --- parsePrintModule input = do +-- parsePrintModuleTests :: Text -> Either String Text +-- parsePrintModuleTests input = do -- let dflags = GHC.unsafeGlobalDynFlags -- let fakeFileName = "SomeTestFakeFileName.hs" -- let pragmaInfo = GHC.getOptions