[GHC] #9607: Programs that require AllowAmbiguousTypes in 7.8
GHC
ghc-devs at haskell.org
Wed Mar 11 16:46:21 UTC 2015
#9607: Programs that require AllowAmbiguousTypes in 7.8
-------------------------------------+-------------------------------------
Reporter: jstolarek | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler (Type | Version: 7.8.3
checker) | Keywords:
Resolution: | Architecture:
Operating System: Unknown/Multiple | Unknown/Multiple
Type of failure: GHC rejects | Test Case:
valid program | Blocking:
Blocked By: | Differential Revisions:
Related Tickets: |
-------------------------------------+-------------------------------------
Comment (by trevorcook):
Thanks for the insight. So, this is bad design, and an instance where
ambiguity was mistakenly sought in the wild. I was vaguely aware of the
mistake, but thought using the ambiguity flag made it all fine.
In summary, I was attempting to make a configurable, general purpose
function, but giving no way for the user to control the configuration,
i.e. which instances of the class constraints containing 'c' to use. Hence
the ambiguity.
A solution which doesn't require AllowAmbiguousTypes is to let the user
specify the configuration by handing forwardingAction some data. Below, I
have a similar function which effectively passes the 'ServerAction' method
call wrapped in a data ServCfg.
{{{#!hs
newtype ServCfg st cmd resp c =
ServCfg { runService :: st -> cmd ->(resp,c->ComResp cmd)}
maybeFwdAction :: forall st cmd trig b c . (ClientAction trig VisCom b)
=> ServCfg st cmd (Maybe (trig, b->c)) c
-> st -> cmd
-> (Maybe ([VisCom],[VisResp] -> c), c -> ComResp cmd)
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9607#comment:9>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list