[GHC] #13249: Default signature check can be quite onerous
GHC
ghc-devs at haskell.org
Mon Feb 27 19:14:08 UTC 2017
#13249: Default signature check can be quite onerous
-------------------------------------+-------------------------------------
Reporter: bgamari | Owner: (none)
Type: feature request | Status: closed
Priority: normal | Milestone: 8.2.1
Component: Compiler (Type | Version: 8.1
checker) |
Resolution: invalid | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: GHC rejects | Unknown/Multiple
valid program | Test Case:
Blocked By: | Blocking:
Related Tickets: #12918 | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by RyanGlScott):
Sorry for not noticing this sooner, but I agree with Simon that the
situation is not as dire as it seems.
It should be noted that the correct default type signature could actually
be made a little shorter:
{{{#!hs
default remaining :: (MonadTrans t, MonadGet n, m ~ t n, Remaining m ~
Remaining n) => m (Remaining m)
}}}
That is, the `MonadGet n` constraint implies the `Monad n` constraint. I
don't think four constraints is a unreasonable amount to ask for, given
that we're using the "lift something into a `MonadTrans`" design pattern,
which requires repeating the constraints (and associated type families)
for the type that is lifted anyway.
Also, to answer Iceland_jack's question: no, `t m (Remaining m)` would not
be valid, both in the sense that GHC will reject it and in a semantic
sense, as you're conflating two different `Monad`s. The first `m` in `t m
(Remaining m)` represents the `Monad` you're lifted, while the second `m`
is for the type which is a `MonadTrans` (i.e, the thing you're lifting
into). Failing to distinguish between these two things has led to all
sorts of problems in the past (see #12784), which is one the reasons we
introduced this check in the first place.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13249#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list