module Jikka.Main.Subcommand.Debug (run) where import qualified Data.Text.IO as T (putStrLn, readFile) import Jikka.Common.Alpha import Jikka.Common.Error import qualified Jikka.Common.IOFormat as IOFormat import qualified Jikka.Core.Format as FormatCore import qualified Jikka.Python.Convert.ToRestrictedPython as ToRestrictedPython import qualified Jikka.Python.Parse as ParsePython import qualified Jikka.RestrictedPython.Convert as ToCore run :: FilePath -> ExceptT Error IO () run :: FilePath -> ExceptT Error IO () run FilePath path = (AlphaT (ExceptT Error IO) () -> Int -> ExceptT Error IO ()) -> Int -> AlphaT (ExceptT Error IO) () -> ExceptT Error IO () forall a b c. (a -> b -> c) -> b -> a -> c flip AlphaT (ExceptT Error IO) () -> Int -> ExceptT Error IO () forall (m :: * -> *) a. Functor m => AlphaT m a -> Int -> m a evalAlphaT Int 0 (AlphaT (ExceptT Error IO) () -> ExceptT Error IO ()) -> AlphaT (ExceptT Error IO) () -> ExceptT Error IO () forall a b. (a -> b) -> a -> b $ do Text prog <- IO Text -> AlphaT (ExceptT Error IO) Text forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO Text -> AlphaT (ExceptT Error IO) Text) -> IO Text -> AlphaT (ExceptT Error IO) Text forall a b. (a -> b) -> a -> b $ FilePath -> IO Text T.readFile FilePath path Program prog <- FilePath -> Text -> AlphaT (ExceptT Error IO) Program forall (m :: * -> *). MonadError Error m => FilePath -> Text -> m Program ParsePython.run FilePath path Text prog Program prog <- Program -> AlphaT (ExceptT Error IO) Program forall (m :: * -> *). (MonadAlpha m, MonadError Error m) => Program -> m Program ToRestrictedPython.run Program prog (Program prog, IOFormat format) <- Program -> AlphaT (ExceptT Error IO) (Program, IOFormat) forall (m :: * -> *). (MonadAlpha m, MonadError Error m) => Program -> m (Program, IOFormat) ToCore.run Program prog Text prog <- Program -> AlphaT (ExceptT Error IO) Text forall (m :: * -> *). Applicative m => Program -> m Text FormatCore.run Program prog IO () -> AlphaT (ExceptT Error IO) () forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO () -> AlphaT (ExceptT Error IO) ()) -> IO () -> AlphaT (ExceptT Error IO) () forall a b. (a -> b) -> a -> b $ Text -> IO () T.putStrLn Text prog IO () -> AlphaT (ExceptT Error IO) () forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO () -> AlphaT (ExceptT Error IO) ()) -> IO () -> AlphaT (ExceptT Error IO) () forall a b. (a -> b) -> a -> b $ FilePath -> IO () putStr (IOFormat -> FilePath IOFormat.formatIOFormat IOFormat format)