[GHC] #14995: QuantifiedConstraints: Incorrect pretty printing

GHC ghc-devs at haskell.org
Mon Apr 2 17:35:26 UTC 2018


#14995: QuantifiedConstraints: Incorrect pretty printing
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  GHCi              |              Version:  8.2.2
      Resolution:                    |             Keywords:
                                     |  QuantifiedConstraints, wipT2893
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Poor/confusing    |  Unknown/Multiple
  error message                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Description changed by Iceland_jack:

Old description:

> This code from [https://www.microsoft.com/en-us/research/wp-
> content/uploads/2016/02/jfp-outsidein.pdf OutsideIn(X)] compiles
>
> {{{#!hs
> {-# Language FlexibleInstances, MultiParamTypeClasses, GADTs,
> QuantifiedConstraints #-}
>
> class C a
> class           B a b   where op :: a -> b
> instance C a => B a [a] where op = undefined
>
> data R a where
>   MkR :: C a => a -> R a
>
> k :: (C a => B a b) => R a -> b
> k (MkR x) = op x
> }}}
>
> but pretty-printing `k` prints `B a b => ..` instead of `(C a => B a b)
> => ..`
>
> {{{
> $ ghci -ignore-dot-ghci Test.hs
> GHCi, version 8.5.20180128: http://www.haskell.org/ghc/  :? for help
> [1 of 1] Compiling Main             ( hs/228-bug.hs, interpreted )
> Ok, one module loaded.
> *Main> :t k
> k :: B a b => R a -> b
> *Main>
> }}}

New description:

 This code from [https://www.microsoft.com/en-us/research/wp-
 content/uploads/2016/02/jfp-outsidein.pdf OutsideIn(X)] compiles

 {{{#!hs
 {-# Language FlexibleInstances, MultiParamTypeClasses, GADTs,
 QuantifiedConstraints #-}

 class C a
 class           B a b   where op :: a -> b
 instance C a => B a [a] where op = undefined

 data R a where
   MkR :: C a => a -> R a

 k :: (C a => B a b) => R a -> b
 k (MkR x) = op x
 }}}

 but pretty-printing `k` prints `B a b => ..` instead of `(C a => B a b) =>
 ..`

 {{{
 $ ghci -ignore-dot-ghci hs/228-bug.hs
 GHCi, version 8.5.20180128: http://www.haskell.org/ghc/  :? for help
 [1 of 1] Compiling Main             ( hs/228-bug.hs, interpreted )
 Ok, one module loaded.
 *Main> :t k
 k :: B a b => R a -> b
 *Main>
 }}}

--

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


More information about the ghc-tickets mailing list