
#9918: GHC chooses an instance between two overlapping, but cannot resolve a clause within the similar closed type family -------------------------------------+------------------------------------- Reporter: qnikst | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by qnikst): I read the article and see a reasoning behind this solution, also I don't have an ideas or wishes about what solution will be right one.
Your program depends in a very delicate way on the treatment of infinite types. I wonder if it needs to?
I was a region code by Kiselev et al. And me and Oleg decided to give closed type families try to remove overloaded instances in the code. There are few other approaches that I have found like expressing type of the monadic stack as a typelevel list of monadic stacks then then check only relevant parts of that list, or calculate list length. {{{ type family Listify (a :: * -> *) :: [* -> *] where Listify (IORT s m) = IORT s m ': Listify m Listify m = '[m] }}} Either of this approaches partially fix the issue, i.e. the code will work for statically known stack, for example: {{{ test_copy = runSIO $ do hout <- newSHandle newRgn $ shPutStrLn hout runSIO :: (forall s. IORT s IO v) -> IO v runSIO = newRgn }}} But this approach do not allow to write region polymorphic code, as in all the cases I'm facing a case there type family can no longer be reduced as in all cases I'm finishing with something like: `MyTypeFamily (Listify m) (IORT s m, Listify m)` and at this point it's not possible to make a right choice. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9918#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler