[GHC] #14796: Pretty Printing: GHC doesn't parenthesise (() :: Constraint) (was: Pretty-printer bug)

GHC ghc-devs at haskell.org
Mon Feb 12 16:47:43 UTC 2018


#14796: Pretty Printing: GHC doesn't parenthesise (() :: Constraint)
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.5
      Resolution:                    |             Keywords:
                                     |  TypeApplications
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by Iceland_jack):

 * cc: TypeApplications (removed)
 * cc: Calanz (added)
 * keywords:   => TypeApplications


Old description:

> From Ryan's [https://ryanglscott.github.io/2018/02/11/how-to-derive-
> generic-for-some-gadts/ How to derive Generic for (some) GADTs using
> QuantifiedConstraints]:
>
> {{{#!hs
> data ECC ctx f a where
>   ECC :: ctx => f a -> ECC ctx f a
> }}}
>
> When instantiating the `Constraint` using `-XTypeApplications` something
> weird happens
>
> {{{
> $ ~/code/qc-ghc/inplace/bin/ghc-stage2 --interactive -ignore-dot-ghci
> GHCi, version 8.5.20180128: http://www.haskell.org/ghc/  :? for help
> Prelude> :set -XGADTs -XConstraintKinds -XTypeApplications
> Prelude> data ECC ctx f a where ECC :: ctx => f a -> ECC ctx f a
> Prelude> :t ECC @[] @() @()
> ECC @[] @() @() :: [()] -> ECC () :: Constraint [] ()
> }}}
>
> Doesn't seem to happen in other cases:
>
> {{{
> Prelude> :t ECC @[] @() @((), ())
> ECC @[] @() @((), ())
>   :: [()] -> ECC (() :: Constraint, () :: Constraint) [] ()
>
> Prelude> :t ECC @[] @() @(Eq Int)
> ECC @[] @() @(Eq Int) :: [()] -> ECC (Eq Int) [] ()
> }}}

New description:

 From Ryan's [https://ryanglscott.github.io/2018/02/11/how-to-derive-
 generic-for-some-gadts/ How to derive Generic for (some) GADTs using
 QuantifiedConstraints]:

 {{{#!hs
 data ECC ctx f a where
   ECC :: ctx => f a -> ECC ctx f a
 }}}

 When instantiating the `Constraint` using `-XTypeApplications` with the
 empty constraint, GHC doesn't add parenthesis (it should look like `... ->
 ECC (() :: Constraint) [] ()`)

 {{{
 $ ~/code/qc-ghc/inplace/bin/ghc-stage2 --interactive -ignore-dot-ghci
 GHCi, version 8.5.20180128: http://www.haskell.org/ghc/  :? for help
 Prelude> :set -XGADTs -XConstraintKinds -XTypeApplications
 Prelude> data ECC ctx f a where ECC :: ctx => f a -> ECC ctx f a
 Prelude> :t ECC @[] @() @()
 ECC @[] @() @() :: [()] -> ECC () :: Constraint [] ()
 }}}

 Doesn't seem to happen in other cases:

 {{{
 Prelude> :t ECC @[] @() @((), ())
 ECC @[] @() @((), ())
   :: [()] -> ECC (() :: Constraint, () :: Constraint) [] ()

 Prelude> :t ECC @[] @() @(Eq Int)
 ECC @[] @() @(Eq Int) :: [()] -> ECC (Eq Int) [] ()
 }}}

--

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


More information about the ghc-tickets mailing list