On Mon, 18 Oct 2004 09:51:52 +0200 "Georg Martius" <[EMAIL PROTECTED]> wrote:On Mon, 18 Oct 2004 09:43:26 +0200, Peter Theissen <[EMAIL PROTECTED]> wrote:Hi, is there any possibility of defining Infix-/Postfixoperators in Haskell? Example: Plus :: Int, Int -> Int
>>>Plus x y = x + y >>>an now I´m want to use Plus in another function as an infix: >>>Times2:: x = x Plus x
Another possiblity: define a new operator (let's call it $+) and you do without the backquotes:
infixl 5 $+ ($+) :: Int->Int->Int x $+ y = x+y times2 x = x $+ x
This way you can specify the associativy and binding precedence and reduce the need for parenthesis.
Note that you can define associativity and precedence of ANY function used as an infix operator, and you can also use it in an infix manner when it is defined. For example:
> infixl 5 `plus` > plus :: Int->Int->Int > x `plus` y = x+y > times2 x = x `plus` x
-Paul
_______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell