Created
February 22, 2017 01:55
-
-
Save league/07ea9764b8bc6c25d276b09934b69330 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE FlexibleInstances #-} | |
lift2 op f g x = op (f x) (g x) | |
instance Num a => Num (a -> a) where | |
(+) = lift2 (+) | |
(*) = lift2 (*) | |
abs = (.) abs | |
signum = (.) signum | |
negate = (.) negate | |
fromInteger i _ = fromInteger i | |
instance Fractional a => Fractional (a -> a) where | |
(/) = lift2 (/) | |
fromRational r _ = fromRational r | |
{- | |
let t = sin / cos in map t [1,2,pi,4] | |
[1.557407724654902,-2.185039863261519,-1.2246467991473532e-16,1.1578212823495775] | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment