
#14824: automatically select instance -------------------------------------+------------------------------------- Reporter: zaoqi | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.2 Resolution: | Keywords: 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 AntC): Thank you zaoqi. The ticket is now very different to your first post. GHC is behaving as I would expect. It doesn't know which instance of `C` to select for the invocation of `m`. That's because it doesn't know the type of the result for `m [X1]`. You could go: {{{ *Main> m [X1] :: X2 }}} And get result `X2`, because GHC can select `instance C X1 X2`. That's similar to `read "5" :: Int` vs `read "5" :: Float` to disambiguate number formats. GHC does not automatically select an instance just because it seems to be the only one that fits: maybe there is another instance declared in another module that fits just as well. I could tell you about `FunctionalDependencies` combined with `OverlappingInstances` and `UndecidableInstances`. But first consider whether Closed `TypeFamilies` will provide a better approach. I can't see any fault. I can't see any "new feature" needed. Please do not use Trac tickets for help requests. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14824#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler