Skip to content

Commit 588e6cc

Browse files
pretty-print select functions (#25)
1 parent 00ce4ef commit 588e6cc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Constrained/TheKnot.hs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,16 @@ deriving instance Eq (ProdW as b)
198198

199199
deriving instance Show (ProdW as b)
200200

201-
instance Syntax ProdW
201+
instance Syntax ProdW where
202+
prettySymbol ProdW _ _ = Nothing
203+
prettySymbol ProdFstW (t :> Nil) p = parensIf (p > 10) <$> prettySelect 0 t
204+
prettySymbol ProdSndW (t :> Nil) p = parensIf (p > 10) <$> prettySelect 1 t
205+
206+
prettySelect :: Int -> TermD deps t -> Maybe (Doc ann)
207+
prettySelect i (App f (t :> Nil))
208+
| Just ProdSndW <- getWitness f = prettySelect (i + 1) t
209+
| Just ToGenericW <- getWitness f = Just $ "sel @" <> pretty i <+> pretty t
210+
prettySelect _ _ = Nothing
202211

203212
instance Semantics ProdW where
204213
semantics ProdW = Prod

0 commit comments

Comments
 (0)