[GHC] #14879: QuantifiedConstraints: Big error message + can't substitute (=>) with a class alias

GHC ghc-devs at haskell.org
Thu Apr 5 23:40:27 UTC 2018


#14879: QuantifiedConstraints: Big error message + can't substitute (=>) with a
class alias
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.5
      Resolution:                    |             Keywords:
                                     |  QuantifiedConstraints, wipT2893
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 Iceland_jack):

 For context this was to encode [https://hackage.haskell.org/package/kan-
 extensions-5.1/docs/Data-Functor-Yoneda.html Yoneda ((->) a) b] with
 constraints

 {{{#!hs
 newtype Yoneda f b = Yoneda (forall xx. (b -> xx) -> f xx)

 type Yo a b = Yoneda ((->) a) b

 lower :: forall a b. (Yo a b) -> (a -> b)
 lower (Yoneda yoneda) = yoneda (id @b)

 lift :: (a -> b) -> (Yo a b)
 lift f = Yoneda (. f)
 }}}

 ----

 Replying to [comment:1 simonpj]:
 > Iceland Jack!  You are torturing me.

 Think of it as enhanced bug reporting

 In this particular case the fluke does a good thing, it behaves like the
 `lower` function where instead of applying to the identity function `(id
 @b)` the constraint solver conjures up the identity constraint `(Implies b
 b)`.

 > If we expanded more vigorously, the fluke would happen both times. I'm
 not sure how hard to work on this.

 I'm ok with the looping situation. Would the hypothetical change make
 `Implies` behave more like `=>`? Making them substitutable ''may'' be a
 desirable property

 That being said! The current implementation is very impressive. If
 something seem unworkable there is surprisingly often some way to guide
 (trick) GHC into accepting it
 ([https://gist.github.com/Icelandjack/aeda8e98214cc52c96230af7b8724d25
 quantifying over TFs],
 [https://ghc.haskell.org/trac/ghc/ticket/14878#comment:2 overlap],
 [https://gist.github.com/Icelandjack/93cf64878e286ed6378adf8fc0e7c200
 overlap]). I hope that doesn't change :)

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14879#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list