Skip to content

Type operator is parenthesized incorrectly in standalone kind signature with -ddump-splices

If you compile the following code on GHC HEAD:

{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -ddump-splices #-}
module Bug where

import Data.Kind

$([d| type (:+:) :: Type -> Type -> Type
      type (:+:) = Either
    |])

You'll get some curious output:

$ ~/Software/ghc5/inplace/bin/ghc-stage2 --interactive Bug.hs -dsuppress-uniques
GHCi, version 8.9.0.20191110: https://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug              ( Bug.hs, interpreted )
Bug.hs:(9,3)-(11,6): Splicing declarations
    [d| type :+: :: Type -> Type -> Type
        
        type (:+:) = Either |]
  ======>
    type :+: :: Type -> Type -> Type
    type (:+:) = Either

Note the incorrectly parenthesized standalone kind signature type :+: :: Type -> Type -> Type. Curiously, this doesn't happen in the body of the type synonym type (:+:) = Either.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information