[GHC] #7019: Wrong error message when using forall in constraints

GHC ghc-devs at haskell.org
Tue Sep 13 16:59:17 UTC 2016


#7019: Wrong error message when using forall in constraints
-------------------------------------+-------------------------------------
        Reporter:  sjoerd_visscher   |                Owner:  simonpj
            Type:  bug               |               Status:  closed
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.4.1
      Resolution:  fixed             |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
                                     |  typecheck/should_fail/T7019, T7019a
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Iceland_jack):

 This compiles using
 [https://hackage.haskell.org/package/constraints-0.8/docs/Data-Constraint-
 Forall.html Data.Constraint.Forall] for the record:

 {{{#!hs
 import Data.Constraint
 import Data.Constraint.Forall

 newtype Free c a = Free { runFree :: forall r. c r => (a -> r) -> r }
   deriving Functor

 class    c (Free c a) => C c a
 instance c (Free c a) => C c a

 instance Applicative (Free c) where
   pure :: a -> Free c a
   pure a = Free ($ a)

   (<*>) :: Free c (a -> b) -> (Free c a -> Free c b)
   Free f <*> Free g = Free (\bfr -> f (\ab -> g (bfr . ab)))

 instance Forall (C c) => Monad (Free c) where
   return :: a -> Free c a
   return a = Free ($ a)

   (>>=) :: forall a b. Free c a -> (a -> Free c b) -> Free c b
   Free f >>= g = f g \\
     inst @(C c) @b
 }}}

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


More information about the ghc-tickets mailing list