@@ -9,6 +9,15 @@ module Main (
99 main ,
1010) where
1111
12+ import Control.Monad.Trans.Except
13+ import Data.Aeson (eitherDecode )
14+ import Data.ByteString.Lazy qualified as BS
15+ import Data.Map qualified as Map
16+ import Data.Text.IO qualified as Text
17+ import Prettyprinter
18+ import System.Environment (getArgs )
19+
20+ import Booster.Pattern.Base (Term , Variable (.. ))
1221import Booster.Pattern.Pretty
1322import Booster.Prettyprinter (renderDefault )
1423import Booster.Syntax.Json (KoreJson (.. ))
@@ -21,12 +30,6 @@ import Booster.Syntax.Json.Internalise (
2130 pattern DisallowAlias ,
2231 )
2332import Booster.Syntax.ParsedKore (internalise , parseKoreDefinition )
24- import Control.Monad.Trans.Except
25- import Data.Aeson (eitherDecode )
26- import Data.ByteString.Lazy qualified as BS
27- import Data.Text.IO qualified as Text
28- import Prettyprinter
29- import System.Environment (getArgs )
3033
3134main :: IO ()
3235main = do
@@ -40,9 +43,11 @@ main = do
4043 Left err -> putStrLn $ " Error: " ++ err
4144 Right KoreJson {term} -> do
4245 case runExcept $ internalisePattern DisallowAlias CheckSubsorts Nothing internalDef term of
43- Right (trm, _subst , _unsupported) -> do
46+ Right (trm, subst , _unsupported) -> do
4447 putStrLn " Pretty-printing pattern: "
4548 putStrLn $ renderDefault $ pretty' @ '[Decoded ] trm
49+ putStrLn " Substitution: "
50+ mapM_ (putStrLn . prettyPrintSubstItem) (Map. toList subst)
4651 Left (NoTermFound _) ->
4752 case runExcept $ internalisePredicates DisallowAlias CheckSubsorts Nothing internalDef [term] of
4853 Left es -> error (show es)
@@ -53,7 +58,10 @@ main = do
5358 putStrLn " Ceil predicates: "
5459 mapM_ (putStrLn . renderDefault . pretty' @ '[Decoded ]) ts. ceilPredicates
5560 putStrLn " Substitution: "
56- mapM_ (putStrLn . renderDefault . pretty' @ '[ Decoded ]) ts. substitution
61+ mapM_ (putStrLn . prettyPrintSubstItem) ( Map. toList ts. substitution)
5762 putStrLn " Unsupported predicates: "
5863 mapM_ print ts. unsupported
5964 Left err -> error (show err)
65+
66+ prettyPrintSubstItem :: (Variable , Term ) -> String
67+ prettyPrintSubstItem (v, t) = show v. variableName <> " |-> " <> (renderDefault . pretty' @ '[Decoded ] $ t)
0 commit comments