6.8.1 incorrectly infers contexts from pattern matches.
|Reported by:||guest||Owned by:||igloo|
|Type of failure:||Difficulty:||Unknown|
|Test Case:||Blocked By:|
The following code is rejected by GHC 6.6.1
data Foo a = (Num a) => MkFoo a data (Num a) => Foo' a = MkFoo' a data Foo'' a = (Num a) => X a | (Show a) => Y a fun :: Foo'' t -> String fun (Y a) = show a -- Prelude> :load "/Users/jules/personal/progs/test.hs" -- [1 of 1] Compiling Main ( /Users/jules/personal/progs/test.hs, interpreted ) -- /Users/jules/personal/progs/test.hs:10:12: -- No instance for (Show t) -- arising from use of `show' -- at /Users/jules/personal/progs/test.hs:10:12-17 -- Possible fix: add (Show t) to the type signature(s) for `fun' -- In the expression: show a -- In the definition of `fun': fun (Y a) = show a -- Failed, modules loaded: none.
According to the GHC manual (section 8.4.5) this rejection is correct. That is, haskell98 is not supposed to infer contexts from a pattern match. However strange that behaviour is, it is apparently the standard.
6.8.1 appears to do the more natural, but incorrect, thing, and accept this program.
Change History (7)
comment:1 Changed 6 years ago by simonpj
- Difficulty set to Unknown
- Resolution set to invalid
- Status changed from new to closed
comment:3 Changed 6 years ago by simonpj
- Resolution invalid deleted
- Status changed from closed to reopened
- Type changed from bug to merge