public
Created

"Class Aliases"

  • Download Gist
NumberStuff.hs
Haskell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
module NumberStuff where
 
import qualified Prelude
 
class CanAdd a where
(+) :: a -> a -> a
 
class CanNegate a where
negate :: a -> a
 
class FromInteger a where
fromInteger :: Prelude.Integer -> a
 
class (CanAdd a, CanNegate a, FromInteger a) => Num a
 
instance CanAdd Prelude.Integer where
(+) = (Prelude.+)
 
instance CanNegate Prelude.Integer where
negate = Prelude.negate
 
instance FromInteger Prelude.Integer where
fromInteger = Prelude.id
 
instance Num Prelude.Integer
 
someFunc :: (Num a) => a -> a
someFunc x = negate (x + x + fromInteger 12)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.