haskell-suite / haskell-names

Haskell suite library for name resolution
52 stars 17 forks source link

Promoted names annotated in wrong context #117

Open nomeata opened 1 year ago

nomeata commented 1 year ago

It seems to properly annotate constructor names in promoted types (i.e. ticked constructors), we need something like this:

diff --git a/src/Language/Haskell/Names/Open/Instances.hs b/src/Language/Haskell/Names/Open/Instances.hs
index b9ec18b..f3e9b54 100644
--- a/src/Language/Haskell/Names/Open/Instances.hs
+++ b/src/Language/Haskell/Names/Open/Instances.hs
@@ -100,6 +100,15 @@ instanceHeadClass (IHApp _ instHead _) = instanceHeadClass instHead
 instance (Resolvable l, SrcInfo l, D.Data l) => Resolvable (Type l) where
   rtraverse e sc = defaultRtraverse e (exprT sc)

+instance (Resolvable l, SrcInfo l, D.Data l) => Resolvable (Promoted l) where
+  rtraverse e sc = case e of
+    PromotedCon l b n ->
+      c PromotedCon
+        <| sc -: l
+        <| sc -: b
+        <| exprV sc -: n
+    _ -> defaultRtraverse e sc
+
 instance (Resolvable l, SrcInfo l, D.Data l) => Resolvable (DeclHead l) where
   rtraverse e sc =
     case e of