
18 Mar
2013
18 Mar
'13
10:17 a.m.
On Mon, Mar 18, 2013 at 10:15:53AM -0400, Brandon Allbery wrote:
On Mon, Mar 18, 2013 at 9:59 AM, Adrian May
wrote: infixl 6 ~+, ~- f ~+ g = \p -> f p + g p f ~- g = \p -> f p - g p
but I feel that the prelude must have already taken care of such things. What's the proper way to do it?
Not in the Prelude (which is specified by the Haskell Language Report and difficult to change), but I think you want to look at Control.Applicative.
In particular, (~+) = liftA2 (+), and similarly for (~-). This uses the ((->) e) instance of Applicative. -Brent