@@ -24,7 +24,7 @@ import Data.IntMap (IntMap)
2424import Data.IntMap qualified as IntMap (assocs )
2525import Data.Text (Text )
2626import GHC.TypeLits (ErrorMessage (.. ), TypeError )
27- import Prettyprinter (list )
27+ import Prettyprinter (fill , list )
2828import Vehicle.Compile.Descope
2929import Vehicle.Compile.Normalise.Quote (unnormalise )
3030import Vehicle.Compile.Prelude
@@ -160,8 +160,10 @@ type family StrategyFor (tags :: Tags) a :: Strategy where
160160 -----------------
161161 -- Constraints --
162162 -----------------
163+ StrategyFor tags (ArgInsertionProblem builtin `In ` NamedBoundCtx ) = StrategyFor tags (Expr builtin `In ` NamedBoundCtx )
163164 StrategyFor tags (InstanceConstraint builtin `In ` ConstraintContext builtin ) = StrategyFor tags (Value builtin `In ` NamedBoundCtx )
164165 StrategyFor tags (UnificationConstraint builtin `In ` ConstraintContext builtin ) = StrategyFor tags (Value builtin `In ` NamedBoundCtx )
166+ StrategyFor tags (ApplicationConstraint builtin `In ` ConstraintContext builtin ) = StrategyFor tags (Value builtin `In ` NamedBoundCtx )
165167 StrategyFor tags (Constraint builtin `In ` ConstraintContext builtin ) = StrategyFor tags (Value builtin `In ` NamedBoundCtx )
166168 ------------
167169 -- Pretty --
@@ -448,12 +450,37 @@ instance
448450 let e' = unnormalise @ (Value builtin ) @ (Expr Builtin ) (Lv $ length ctx) e
449451 prettyUsing @ rest (e', ctx)
450452
453+ instance
454+ (PrettyUsing rest (Arg builtin `In ` NamedBoundCtx ), ConvertableBuiltin builtin Builtin ) =>
455+ PrettyUsing ('QuoteValue rest ) (Arg builtin `In ` NamedBoundCtx )
456+ where
457+ prettyUsing (e, ctx) = prettyUsing @ rest (e, ctx)
458+
459+ instance
460+ (PrettyUsing rest (Expr builtin `In ` NamedBoundCtx ), ConvertableBuiltin builtin Builtin ) =>
461+ PrettyUsing ('QuoteValue rest ) (Expr builtin `In ` NamedBoundCtx )
462+ where
463+ prettyUsing (e, ctx) = prettyUsing @ rest (e, ctx)
464+
451465instance PrettyUsing rest (GenericBinder () ) where
452466 prettyUsing b = maybe " _" pretty (nameOf b)
453467
454468--------------------------------------------------------------------------------
455469-- Instances for constraints
456470
471+ instance
472+ ( PrettyUsing rest (Expr builtin `In ` NamedBoundCtx ),
473+ PrettyUsing rest (Arg builtin `In ` NamedBoundCtx )
474+ ) =>
475+ PrettyUsing rest (ArgInsertionProblem builtin `In ` NamedBoundCtx )
476+ where
477+ prettyUsing (problem, ctx) = do
478+ let checkedExpr = solutionSoFar problem
479+ let checkedExprDoc = prettyUsing @ rest (checkedExpr, ctx)
480+ let expectedTypeDoc = prettyUsing @ rest (currentExpectedType problem, ctx)
481+ let uncheckedArgsDoc = prettyUsing @ rest (uncheckedArgs problem, ctx)
482+ parens (checkedExprDoc <+> " :" <+> expectedTypeDoc) <+> " @" <+> uncheckedArgsDoc
483+
457484prettyConstraintContext :: ConstraintContext builtin -> Doc a
458485prettyConstraintContext ctx =
459486 " #" <> pretty (constraintID ctx) <> " . " -- <+> pretty ctx
@@ -475,15 +502,25 @@ instance
475502 let expr' = prettyUsing @ rest (expr, namedBoundCtxOf ctx)
476503 prettyConstraintContext ctx <+> pretty m <+> " <=" <+> expr'
477504
505+ instance
506+ (PrettyUsing rest (ArgInsertionProblem builtin `In ` NamedBoundCtx )) =>
507+ PrettyUsing rest (ApplicationConstraint builtin `In ` ConstraintContext builtin )
508+ where
509+ prettyUsing (InferArgs {.. }, ctx) = do
510+ let problemDoc = prettyUsing @ rest (argInsertionProblem, namedBoundCtxOf ctx)
511+ prettyConstraintContext ctx <+> parens (pretty exprSolutionMeta <+> " =" <+> problemDoc) <+> " :" <+> pretty typeSolutionMeta
512+
478513instance
479514 ( PrettyUsing rest (UnificationConstraint builtin `In ` ctx ),
480- PrettyUsing rest (InstanceConstraint builtin `In ` ctx )
515+ PrettyUsing rest (InstanceConstraint builtin `In ` ctx ),
516+ PrettyUsing rest (ApplicationConstraint builtin `In ` ctx )
481517 ) =>
482518 PrettyUsing rest (Constraint builtin `In ` ctx )
483519 where
484520 prettyUsing (c, ctx) = case c of
485521 UnificationConstraint uc -> prettyUsing @ rest (uc, ctx)
486522 InstanceConstraint tc -> prettyUsing @ rest (tc, ctx)
523+ ApplicationConstraint tc -> prettyUsing @ rest (tc, ctx)
487524
488525--------------------------------------------------------------------------------
489526-- Assertions
@@ -545,7 +582,7 @@ instance
545582instance (PrettyUsing rest (a `In ` ctx )) => PrettyUsing rest (MetaMap a `In ` ctx ) where
546583 prettyUsing (MetaMap m, ctx) = prettyMapEntries entries
547584 where
548- entries = fmap (bimap MetaID (prettyUsing @ rest . (,ctx))) (IntMap. assocs m)
585+ entries = fmap (bimap (fill 3 . pretty . MetaID ) (prettyUsing @ rest . (,ctx))) (IntMap. assocs m)
549586
550587instance (PrettyUsing rest (a `In ` ctx )) => PrettyUsing rest (MaybeTrivial a `In ` ctx ) where
551588 prettyUsing (e, ctx) = case e of
0 commit comments