mirror of
https://github.com/github/semantic.git
synced 2024-12-23 06:41:45 +03:00
Implement unzip over Both.
This commit is contained in:
parent
b6ffeeba2a
commit
ecdb3c3e9b
@ -7,6 +7,10 @@ newtype Both a = Both { runBoth :: (a, a) }
|
||||
both :: a -> a -> Both a
|
||||
both = curry Both
|
||||
|
||||
unzip :: [Both a] -> Both [a]
|
||||
unzip = foldr pair (pure [])
|
||||
where pair (Both (a, b)) (Both (as, bs)) = Both (a : as, b : bs)
|
||||
|
||||
instance Applicative Both where
|
||||
pure a = Both (a, a)
|
||||
Both (f, g) <*> Both (a, b) = Both (f a, g b)
|
||||
|
Loading…
Reference in New Issue
Block a user