Defining operators via sections

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Defining operators via sections

Tom Ellis-5
I can define operators directly or through their parenthesised name:

> let x .+ y = x + y
> let (.+) x y = (+) x y
> let (.+) x = (+) x
> let (.+) = (.+)

but I can't define them via sections:

> let (x .+) = (x +)
<interactive>:11:6: Parse error in pattern: x .+
> let (.+ y) = (+ y)
<interactive>:12:6: Parse error in pattern: .+ y

It seems natural to write, for example

    instance Monad Maybe where
      ...
      (>>= f) = \case
        Nothing -> Nothing
        Just a  -> f a

Is there any particular reason this is not possible?  Thanks,

Tom
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.