2

I have got an error: Not a data constructor: "%:":

data KV = forall a. Show a => (%:) Text a

Interestingly, but :% is fine as data constructor! %% is not fine again. But %% is fine to be infix function. Why is it treating as an error? What is the difference between these variants?

RandomB
  • 3,367
  • 19
  • 30

1 Answers1

4

It's not a valid name for a data constructor. All infix operator data constructors must start with :. So (:%) would be fine.

This is just the operator equivalent of "constructors must start with capital letters", as a syntactic means to distinguish constructors from other names when pattern matching.

Carl
  • 26,500
  • 4
  • 65
  • 86
  • 3
    I memorize this as "`:` counts as an uppercase character". – chi Jul 02 '19 at 15:23
  • I just remember that the non-empty list constructor `:` is the simplest/shortest constructor name starting with `:`. – chepner Jul 02 '19 at 18:42