Created
February 5, 2013 05:03
-
-
Save cutsea110/4712287 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, ImplicitParams #-} | |
import Control.Monad | |
import Control.Applicative | |
instance (Monad m, Num b) => Num (a -> m b) where | |
a + b = liftM2 (+) <$> a <*> b | |
a * b = liftM2 (*) <$> a <*> b | |
negate a = liftM negate <$> a | |
abs a = liftM abs <$> a | |
signum a = liftM signum <$> a | |
fromInteger = const . return . fromInteger | |
main = print $ (m >>= 1) () | |
where m = const 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment