[Haskell-cafe] Defining operators via sections
Tom Ellis
tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk
Thu Jul 19 14:14:03 UTC 2018
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
More information about the Haskell-Cafe
mailing list