nebo :: (Bool, Bool) -> Bool nebo (x, y) = x || y -- curry nebo = (||) -- uncurry (||) = nebo -- curry f x y = f (x, y) -- uncurry f (x, y) = f x y curry3 :: ((a,b,c) -> d) -> a -> b -> c -> d uncurry3 :: (a -> b -> c -> d) -> (a,b,c) -> d (curry3 f) x y z = f (x, y, z) (uncurry3 f) (x, y, z) = f x y z -- \x -> x + sin x -- \x -> (+) x (sin x) -- \x -> distr (+) sin x {- SPOSOB 1 id :: a -> a curry :: ((a,b) -> d) -> a -> b -> d id x = x id :: (a,b) -> (a,b) (curry id) x y = (x, y) distr (curry id) id \x -> distr (curry id) id x \x -> (curry id) x (id x) \x -> (x, id x) \x -> (x, x) SPOSOB 2 curry :: ((a, b) -> c) -> a -> b -> c id :: d -> d distr (curry id) id \x -> distr (curry id) id x \x -> (curry id) x (id x) \x -> (curry id) x x \x -> curry id x x \x -> curry (\(a,b) -> (a,b)) x x \x -> (\a b -> (a,b)) x x \x -> (x,x) -} distr f g x = f x (g x) pair = uncurry (distr . ((.)(curry id))) negp :: (a -> Bool) -> a -> Bool negp f x = not (f x) negp1 f = not . f negp2 = (.) not negp2 = (not.) -- ekvivalentne: -- f x ... z = telo -- f = \x ... z -> telo {- toto nejde! \x y -> f (g x y) f . g -}