
#12006: Can't infer constraint of pattern synonyms -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by mpickering): * keywords: TypeSynonyms => PatternSynonyms Comment: The problem here is that the type signature of the builder is fixed by the type of the matcher. By fixed, I mean literally fixed, we first typecheck the matcher with either the signature or infer the type and then we create an `Id` for the builder with precisely the same type. So the problem here is that the inferred type for the matcher doesn't require the `Num` constraint and so the builder type is `t -> Complex t` rather than `Num t => t -> Complex t` as you desire. From what I could work out from reading the source, the way it is like this is for mainly because of implementation problems. There is some more confused discussion on this ticket -https://ghc.haskell.org/trac/ghc/ticket/8581 - it is something I hope to look at again one day. Thank you for all these reports, they are very useful, I am interested in any pattern synonyms tickets so feel free to add me to cc to make sure that I see them. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12006#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler