Skip to content

Instantly share code, notes, and snippets.

@tel
Created December 2, 2014 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tel/e1f040a4e42887e6ab7a to your computer and use it in GitHub Desktop.
Save tel/e1f040a4e42887e6ab7a to your computer and use it in GitHub Desktop.
Num-in-Reader
-- 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