Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {-# LANGUAGE FlexibleInstances #-}
  2. {-# LANGUAGE FlexibleContexts #-}
  3. {-# LANGUAGE UndecidableInstances #-}
  4.  
  5. instance (Num a, Applicative f, Show (f a), Eq (f a)) => Num (f a) where
  6.         (+) = liftA2 (+)
  7.         (-) = liftA2 (-)
  8.         (*) = liftA2 (*)
  9.         negate = fmap negate
  10.         signum = fmap signum
  11.         abs = fmap abs
  12.         fromInteger = pure . fromInteger
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement