Skip to content

Operator (!) causes weird pretty printing and parsing

class Key key where
  data TotalMap key :: Type -> Type
  (!) :: TotalMap key val -> (key -> val)

instance Key Bool where
  data TotalMap Bool val = BoolMap val val
  (!) :: TotalMap Bool val -> (Bool -> val)
  (BoolMap f _) ! False = f

puts unnecessary parentheses around the wildcard pattern:

tf6t.hs:14:3-23: error: …
    Parse error in pattern: (BoolMap f (_))
Compilation failed.

and with no parentheses

  BoolMap f _ ! False = f

it talks about missing method, pattern bindings and doesn't list a space between ! and False:

tf6t.hs:13:3-5: error: …
    The class method signature for ‘!’ lacks an accompanying binding
      (The class method signature must be given where ‘!’ is declared)
tf6t.hs:14:3-25: error: …
    Pattern bindings (except simple variables) not allowed in instance declaration:
      BoolMap f _ !False = f
Compilation failed.

All of these issues go away if the operator is called something other than !, it works if written prefix

  (!) (BoolMap f _) False = f
Trac metadata
Trac field Value
Version 8.0.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Parser)
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