Skip to content

Out of scope errors with type families do not mention scope

{-# LANGUAGE TypeFamilies #-}
class C a where
    type T a
    c :: a -> T a
main = c noSuchThing

yields:

test_bad_error.hs:6:1: error:
    • Couldn't match expected type ‘T a’ with actual type ‘T a0’
      NB: ‘T’ is a type function, and may not be injective
      The type variable ‘a0’ is ambiguous
    • In the ambiguity check for the inferred type for ‘main’
      To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
      When checking the inferred type
        main :: forall a. T a

This makes simple out-of-scope error seem very perplexing and is a huge regression in error quality.

Edited by Ben Gamari
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information