Created
December 7, 2011 07:04
-
-
Save onlyshk/1441804 to your computer and use it in GitHub Desktop.
Lifting functions more than 1 parameter
This file contains hidden or 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
lift0 :: a -> Pair a | |
lift0 x = Pair x x | |
lift2 :: (a -> b -> r) -> (Pair a -> Pair b -> Pair r) | |
lift2 f (Pair x1 x2) (Pair y1 y2) = Pair (f x1 y1) (f x2 y2) | |
plus :: Pair Int -> Pair Int -> Pair Int | |
plus = lift2 (+) | |
-- plus (Pair 1 2) (Pair 3 4) ---> Pair 4 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment