Consider two data
declarations:
{-# LANGUAGE GADTs #-}
data X = Int `Y` Int deriving Show
data Z where
W :: Int -> Int -> Z deriving Show
main = do
print (1 `Y` 2)
print (3 `W` 4)
Running the above program produces:
1 `Y` 2
W 3 4
so the derived show
knows that Y
is infix and prints it accordingly. The ::
syntax doesn't seem to allow infixness.
Is there any way to make the compiler derive show for W
as infix, (other than explicitly providing a show
instance for Z
)?
The desired output is
1 `Y` 2
3 `W` 4
Show
deriver to print a non-symbolic constructor infix. – Lifework