Skip to content

Can't define constructors to be infix (as far as Show is concerned) with GADT syntax

Okay so, if you define a data type like this:

data Two a = a :. a deriving Show

then show (1 :. 2) == "1 :. 2". On the other hand, if you define the data type like so:

data Two a = (:.) a a deriving Show

then `show (1 :. 2) == "(:.) 1 2".

This kind of makes sense since how the constructor is defined by the user gives some hint as to how it should be used. The only problem is you can't give that hint if you're using GADT syntax, since then constructors are given without explicit arguments.

I don't see an easy way to let you give that hint, but I think it would be reasonable to just guess that any constructor with a symbol name (i.e. one starting with :\) should be considered infix.

Trac metadata
Trac field Value
Version 7.3
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information