Haskell Language Infix operators Custom operators


Example

In Haskell, you can define any infix operator you like. For example, I could define the list-enveloping operator as

(>+<) :: [a] -> [a] -> [a]
env >+< l = env ++ l ++ env

GHCi> "**">+<"emphasis"
"**emphasis**"

You should always give such operators a fixity declaration, like

infixr 5 >+<

(which would mean >+< binds as tightly as ++ and : do).