
#14059: COMPLETE sets don't work at all with data family instances -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: | PatternSynonyms, | PatternMatchWarnings Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): I looked into this some more tonight. While I wasn't able to find the underlying cause of why `COMPLETE` sets don't seem to quite work for data family instances, I did notice a discrepancy between pattern synonyms for datatype contructors and those for data family instance constructors. In several places throughout GHC, the `conLikeResTy` function is used to determine the return type of a conlike (be it a proper data constructor or a pattern synonym). For datatype constructors, `conLikeResTy` returns something of the form `T a1 ... an`, where `T` is a datatype tycon. This holds true regardless of whether `conLikeResTy` is called on a proper data constructor (e.g., the `MkT` in `data T a = MkT a`) or a pattern synonym for a data constructor (e.g., `pattern FakeT a = MkT a`). With data family instances, however, the story is a little different. Let's suppose we have: {{{#!hs data family F a b data instance F Int b = MkF Int pattern FakeF a = MkF a }}} If you call `conLikeResTy` on `MkF`, you won't get `F Int b`, but instead something like `R:FInt b`, where `R:FInt` is the //representation// tycon for the data family instance `F Int b` (as opposed to `F`, which is the //parent// data family tycon). However, calling `conLikeResTy` on `FakeF` gives you `F Int b` instead! That's a difference that smells quite funny to me, but I haven't tracked down the scent's origin yet. For what it's worth, `COMPLETE` sets group conlikes by parent tycon name, not by representation tycon name, so for instance: {{{#!hs {-# COMPLETE SFalse, STooGoodToBeTrue :: Sing #-} }}} In order to look up these conlikes, you'd need to use `Sing (z :: Bool)`, not `R:SingzBool` (type weirdness in comment:1 aside). What does it all mean? I can't be sure at the moment. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14059#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler