[[project @ 2005-03-09 17:47:09 by simonpj] simonpj**20050309174709 Document infix type operators ] { hunk ./ghc/docs/users_guide/glasgow_exts.xml 928 -Infix type constructors and classes +Infix type constructors, classes, and type variables hunk ./ghc/docs/users_guide/glasgow_exts.xml 931 -GHC allows type constructors and classes to be operators, and to be written infix, very much -like expressions. More specifically: +GHC allows type constructors, classes, and type variables to be operators, and +to be written infix, very much like expressions. More specifically: hunk ./ghc/docs/users_guide/glasgow_exts.xml 958 + A type variable can be an (unqualified) operator e.g. +. + The lexical syntax is the same as that for variable operators, excluding "(.)", + "(!)", and "(*)". In a binding position, the operator must be + parenthesised. For example: + + type T (+) = Int + Int + f :: T Either + f = Left 3 + + liftA2 :: Arrow (~>) + => (a -> b -> c) -> (e ~> a) -> (e ~> b) -> (e ~> c) + liftA2 = ... + + + hunk ./ghc/docs/users_guide/glasgow_exts.xml 991 - - The only thing that differs between operators in types and operators in expressions is that - ordinary non-constructor operators, such as + and * - are not allowed in types. Reason: the uniform thing to do would be to make them type - variables, but that's not very useful. A less uniform but more useful thing would be to - allow them to be type constructors. But that gives trouble in export - lists. So for now we just exclude them. - }