Last active
August 29, 2015 14:06
-
-
Save fronx/a83cf1136d5bb5fc2d90 to your computer and use it in GitHub Desktop.
Revisions
-
fronx revised this gist
Sep 14, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -12,6 +12,6 @@ instance Functor (Snd a) where fmap f (Snd (x, y)) = Snd (x, f y) main = do let pair = (3, 4) print $ fmap (*2) $ Fst pair -- Fst (6, 4) print $ fmap (*2) $ Snd pair -- Fst (3, 8) -
fronx created this gist
Sep 14, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ module PairFunctors where data Fst b a = Fst (a, b) deriving Show data Snd a b = Snd (a, b) deriving Show instance Functor (Fst b) where fmap f (Fst (x, y)) = Fst (f x, y) instance Functor (Snd a) where fmap f (Snd (x, y)) = Snd (x, f y) main = do let pair = (3, 4) :: (Int, Int) print $ fmap (*2) $ Fst pair -- Fst (6, 4) print $ fmap (*2) $ Snd pair -- Snd (3, 8)