
#15927: Weird interaction between fundeps and overlappable instances -------------------------------------+------------------------------------- Reporter: Darwin226 | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.3 Component: Compiler | Version: 8.6.2 Resolution: | Keywords: | FunctionalDependencies Operating System: Unknown/Multiple | Architecture: Type of failure: GHC accepts | Unknown/Multiple invalid program | Test Case: Blocked By: | Blocking: Related Tickets: 10675, 15632 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by AntC): You've clearly unearthed an(other) example of GHC's bogusness with FunDeps+Overlaps. Without wanting to take anything away from that ... Replying to [comment:4 AntC]:
behavior ... seems pretty useful in some situations
... can you refactor your code?
The code as currently is fragile and non-scalable. It relies on the payload content of the `StateT`s having distinct types. You can do this {{{#!hs f :: (MyState Int m, MyState Char m, MyState String m, MonadIO m) => m () -- believe 3 impossible things before breakfast f = do int <- getMyState char <- getMyState str <- getMyState liftIO $ putStrLn ((replicate int char) ++ str) }}} * But it doesn't work if `f` wants two values of the same type. (`getMyState` will always get the first-bound.) `... liftIO $ putStrLn (str1 ++ str2)` I suggest you want either * depth-based access: `getMyState` has an extra parameter for the depth. Or it very cleverly takes the content from this layer and unwraps one layer of State for the next call. Now you need a PolyMonad; or * type-indexed access: wrap each layer's content in a newtype. Make sure they're distinct types. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15927#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler