-ddump-ast

This commit is contained in:
crumbtoo
2024-02-01 11:37:52 -07:00
parent 46f0393a03
commit dda0e17358
7 changed files with 75 additions and 60 deletions

View File

@@ -21,6 +21,7 @@ import Data.Functor.Identity
import Core.Syntax
import Core.Lex
import Compiler.RLPC
import Control.Monad
import Lens.Micro
import Data.Default.Class (def)
import Data.Hashable (Hashable)
@@ -225,12 +226,17 @@ insScDef sc = programScDefs %~ (sc:)
singletonScDef :: (Hashable b) => ScDef b -> Program b
singletonScDef sc = insScDef sc mempty
parseCoreProgR :: forall m. (Applicative m) => [Located CoreToken] -> RLPCT m Program'
parseCoreProgR = hoistRlpcT generalise . parseCoreProg
parseCoreProgR :: forall m. (Monad m) => [Located CoreToken] -> RLPCT m Program'
parseCoreProgR = ddumpast <=< (hoistRlpcT generalise . parseCoreProg)
where
generalise :: forall a. Identity a -> m a
generalise (Identity a) = pure a
ddumpast :: Program' -> RLPCT m Program'
ddumpast p = do
whenDFlag "dump-ast" $ (addDebugMsg . show $ p)
pure p
happyBind :: RLPC a -> (a -> RLPC b) -> RLPC b
happyBind m k = m >>= k