In standard Haskell, operator symbols may only be used at the value level.The only exception to this is the function arrow,
(->), which is a built-in type operator. GHC expands the role of operators with the
TypeOperators extension, which makes it possible to use an operator as the name of a type.
TypeOperators extension has been available since GHC 6.8.1 and implies the
ExplicitNamespaces extension. GHC User Manual documentation for
Defining type operators
By default, if you try to define a type whose name isn’t composed of letters, compilation fails and GHC suggests that you enable the
TypeOperators extension. This happens regardless of whether you place the name in infix or prefix position.
An example of failing with infix notation:
An example of failing with prefix notation:
With the extension enabled, either of these declarations is permitted.
Using type operators
You can use a type operator, in prefix notation, without any extensions enabled.
However, you cannot use it in infix notation.
Using a type operator in infix notation requires enabling the
GHC.Generics defines types named