@@ -6,15 +6,14 @@ module PrettyPrint where
66import Control.Monad.State (State )
77import Data.Map (Map )
88import Naturals (NExpr (.. ), NExprs (.. ), NResult )
9- import Telomare (FragExpr (.. ), FragExprF (.. ), FragExprUR (.. ),
9+ import Telomare (DataType ( .. ), FragExpr (.. ), FragExprF (.. ), FragExprUR (.. ),
1010 FragExprURSansAnnotation (FragExprURSA , unFragExprURSA ),
11- FragIndex (.. ), IExpr (.. ), LocTag , PartialType (.. ),
12- RecursionSimulationPieces (.. ), IExprF (.. ), DataType (.. ),
13- Term3 (.. ), Term4 (.. ), forget , forgetAnnotationFragExprUR ,
14- indentWithOneChild' , indentWithTwoChildren' , rootFrag ,
15- Pattern (.. ), UnprocessedParsedTerm (.. ),
16- UnprocessedParsedTermF (.. ), isNum , g2i
17- )
11+ FragIndex (.. ), IExpr (.. ), IExprF (.. ), LamType (.. ), LocTag ,
12+ ParserTermF (.. ), PartialType (.. ), Pattern (.. ),
13+ RecursionSimulationPieces (.. ), Term1 , Term3 (.. ), Term4 (.. ),
14+ UnprocessedParsedTerm (.. ), UnprocessedParsedTermF (.. ),
15+ forget , forgetAnnotationFragExprUR , g2i , indentWithChildren' ,
16+ indentWithOneChild' , indentWithTwoChildren' , isNum , rootFrag )
1817
1918import qualified Control.Comonad.Trans.Cofree as CofreeT (CofreeF (.. ))
2019import qualified Control.Monad.State as State
@@ -180,6 +179,24 @@ instance PrettyPrintable Term4 where
180179 TraceFragF -> pure " T"
181180 AuxFragF _ -> error " prettyPrint term4 - should be no auxfrag here"
182181
182+ instance {-# OVERLAPPING #-} PrettyPrintable Term1 where
183+ showP = cata fa where
184+ fa (_ CofreeT. :< x) = case x of
185+ TZeroF -> pure " 0"
186+ TPairF a b -> indentWithTwoChildren' " (" a b
187+ TVarF v -> pure v
188+ TAppF c i -> indentWithTwoChildren' " ($)" c i
189+ TCheckF cf i -> indentWithTwoChildren' " :" cf i
190+ TITEF i t e -> indentWithChildren' " ITE" [i,t,e]
191+ TLeftF x -> indentWithOneChild' " L" x
192+ TRightF x -> indentWithOneChild' " R" x
193+ TTraceF x -> indentWithOneChild' " T" x
194+ THashF x -> indentWithOneChild' " #" x
195+ TChurchF n -> pure $ " $" <> show n
196+ TLamF (Open v) x -> indentWithOneChild' (" \\ " <> v) x
197+ TLamF (Closed v) x -> indentWithOneChild' (" [\\ " <> v) x
198+ TLimitedRecursionF t r b -> indentWithChildren' " TRB" [t,r,b]
199+
183200showTypeDebugInfo :: TypeDebugInfo -> String
184201showTypeDebugInfo (TypeDebugInfo (Term3 m) lookup rootType) =
185202 let termMap = forgetAnnotationFragExprUR <$> m
0 commit comments