pattern synonym with required ctx having polykinded constraint fails

Sreenidhi Nair nair.sreenidhi at
Wed Oct 21 11:49:05 UTC 2015


We have a pattern synonym as follows

type family Showable (a :: k) :: Constraint where
  Showable (a :: *) = (Show a)
  Showable a       = ()

pattern Just' :: () => (Showable a) => a -> (Maybe a)
pattern Just' a <- (extractJust -> (True, a)) where
  Just' a = Just a

When we try to use the pattern in a different package, the error was

    [1 of 1] Compiling Bar              ( Bar.hs,
.stack-work/dist/x86_64-linux/Cabal- )

    Declaration for Just'
    Pattern synonym Just':
      Iface type variable out of scope:  k
    Cannot continue after interface file error

The error only occurred when Showable was polykinded and we used synonym in
a different package . Using the synonym in the same package works fine.

This problem did not happen with the following definition of (non
polykinded ) Showable

type family Showable a :: Constraint where
  Showable a = (Show a)

We have attached the sample packages which simulate the exact scenario
described above.

Yours truly,
Sreenidhi Nair
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug.tar.gz
Type: application/x-gzip
Size: 2154 bytes
Desc: not available
URL: <>

More information about the ghc-devs mailing list