From 45d119ed791a4e0bafd0ec8cf4e299748096874f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20G=C3=A9lineau?= Date: Sun, 2 Feb 2025 23:39:55 -0500 Subject: [PATCH] make the output deterministic --- .../non-examples/type-errors/not-a-function.golden | 2 +- src/Pretty.hs | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/non-examples/type-errors/not-a-function.golden b/examples/non-examples/type-errors/not-a-function.golden index 3417140..8df9f32 100644 --- a/examples/non-examples/type-errors/not-a-function.golden +++ b/examples/non-examples/type-errors/not-a-function.golden @@ -1,2 +1,2 @@ Type mismatch at not-a-function.kl:3.11-3.13. -Expected (Integer → META(MetaPtr 53790)) but got Integer +Expected (Integer → ?1) but got Integer diff --git a/src/Pretty.hs b/src/Pretty.hs index 73d2447..bfa6062 100644 --- a/src/Pretty.hs +++ b/src/Pretty.hs @@ -404,7 +404,15 @@ instance Pretty VarInfo TypeConstructor where pp _ TType = pure $ text "Type" pp env (TDatatype t) = pp env t pp _ (TSchemaVar n) = pure $ text $ typeVarNames !! fromIntegral n - pp _ (TMetaVar v) = pure $ text "META" <> viaShow v -- TODO + pp _ (TMetaVar v) = do + renumbering <- get + case St.lookup v renumbering of + Just n -> do + pure $ text "?" <> viaShow n + Nothing -> do + let n = St.size renumbering + 1 + put (St.insert v n renumbering) + pure $ text "?" <> viaShow n instance Pretty VarInfo a => Pretty VarInfo (TyF a) where pp _ (TyF TFun []) = pure $ parens (text "→")