Created
December 2, 2014 14:51
-
-
Save tel/e1f040a4e42887e6ab7a to your computer and use it in GitHub Desktop.
Num-in-Reader
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
-- We'll use the instance of Applicative for ((->) a) below | |
instance Num b => Num (a -> b) where | |
(+) = liftA2 (+) | |
(*) = liftA2 (*) | |
(-) = liftA2 (-) | |
negate = fmap negate | |
signum = fmap signum | |
abs = fmap abs | |
fromInteger = pure . fromInteger |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment