Skip to content

Pattern synonym fields should not allow type synonyms

Currently, a type synonym can be used to define fields of a pattern synonym:

{-# LANGUAGE PatternSynonyms #-}
type T = Int -> Int
pattern P :: T
pattern P x = x

I think this should be disallowed, just like we disallow

{-# LANGUAGE GADTs #-}
type T = Int -> X
data X where
  MkX :: T

The arrows -> in a pattern synonym type and in a GADT constructor are not functions; they are a syntactic form used to delimit fields. The same holds for the two => arrows that can appear in a pattern synonym type.

Another possible testcase is pattern P :: (->) Int Int (compare #17211 (closed))

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