Created
April 13, 2012 05:16
-
-
Save tonymorris/2373889 to your computer and use it in GitHub Desktop.
Ugly -> nicer?
This file contains 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
class Functor f => Unzip f where | |
unfzip :: | |
f (a, b) | |
-> (f a, f b) | |
unfzip3 :: | |
f (a, b, c) | |
-> (f a, f b, f c) | |
unfzip3 x = | |
let (a, bc) = unfzip (fmap (\(a', b', c') -> (a', (b', c'))) x) | |
(b, c) = unfzip bc | |
in (a, b, c) | |
unfzip4 :: | |
f (a, b, c, d) | |
-> (f a, f b, f c, f d) | |
unfzip4 x = | |
let (a, b, cd) = unfzip3 (fmap (\(a', b', c', d') -> (a', b', (c', d'))) x) | |
(c, d) = unfzip cd | |
in (a, b, c, d) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment