module Aula9 where f x y = x ^ y -- quadrados = fmap (\x -> x^2) [1, 2..10 ] -- quadrados = (\x -> x^2) `fmap` [1, 2..10 ] quadrados = (\x -> x^2) <$> [1, 2..10 ] (#) :: Integral b => b -> b -> b x # y = (x*y)^(y+x) infixr 0 # g x y z w = 0 h :: Integer -> Integer h x = 2 i :: Integer -> Integer i y = y+1 j :: Integer -> Integer j z = z^z (?) :: (a -> b) -> (b -> c) -> (a -> c) -- f ? g = g . f (f ? g) x = g (f x) infixr 9 ? instance Semigroup Integer where x <> y = x - y class Grupo a where op :: a -> a -> a inv :: a -> a neutro :: a pot :: Integral b => a -> b -> a pot x 0 = neutro pot x n = (pot x (n-1)) `op` x instance Grupo Integer where op x y = x + y inv x = -x neutro = 0 instance Grupo Float where op x y = x*y inv x = 1.0/x neutro = 1.0 instance Monoid Integer where mempty = 0