Skip to content

Commit

Permalink
Include location of ambiguous meta var
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdone committed Dec 4, 2024
1 parent 21207b5 commit adde248
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Hell.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,7 @@ data IRep v

data ZonkError
= ZonkKindError
| AmbiguousMetavar
| AmbiguousMetavar IMetaVar
deriving (Show)

-- | A complete implementation of conversion from the inferer's type
Expand Down Expand Up @@ -1709,7 +1709,7 @@ occurs ivar = any (==ivar)
-- <https://stackoverflow.com/questions/31889048/what-does-the-ghc-source-mean-by-zonk>
zonk :: IRep IMetaVar -> Either ZonkError (IRep Void)
zonk = \case
IVar {} -> Left AmbiguousMetavar
IVar var -> Left $ AmbiguousMetavar var
ICon c -> pure $ ICon c
IFun a b -> IFun <$> zonk a <*> zonk b
IApp a b -> IApp <$> zonk a <*> zonk b
Expand Down Expand Up @@ -1868,7 +1868,10 @@ instance Pretty a => Pretty (IRep a) where
instance Pretty ZonkError where
pretty = \case
ZonkKindError -> "Kind error."
AmbiguousMetavar -> "Ambiguous meta variable."
AmbiguousMetavar imetavar ->
"Ambiguous meta variable: " <> pretty imetavar <> "\n" <>
"arising from " <>
pretty imetavar.srcSpanInfo

instance Pretty ElaborateError where
pretty = \case
Expand Down

0 comments on commit adde248

Please sign in to comment.