{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TypeOperators #-}
module Foundation.Collection.Zippable
( BoxedZippable(..)
, Zippable(..)
) where
import qualified Basement.UArray as UV
import qualified Basement.BoxedArray as BA
import qualified Basement.String as S
import Foundation.Collection.Element
import Foundation.Collection.Sequential
import Basement.Compat.Base
import Basement.Types.AsciiString(AsciiString(..))
import qualified Prelude
import GHC.ST
class Sequential col => Zippable col where
zipWith :: (Sequential a, Sequential b)
=> (Element a -> Element b -> Element col)
-> a -> b -> col
zipWith Element a -> Element b -> Element col
f a
a b
b = forall {c} {a} {b}.
(Sequential c, Sequential a, Sequential b) =>
(Element a -> Element b -> Element c) -> (a, b) -> c
go Element a -> Element b -> Element col
f (forall l. IsList l => l -> [Item l]
toList a
a, forall l. IsList l => l -> [Item l]
toList b
b)
where go :: (Element a -> Element b -> Element c) -> (a, b) -> c
go Element a -> Element b -> Element c
f' = forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. Monoid a => a
mempty (\((Element a, Element b)
x, (a, b)
xs) -> forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry2 Element a -> Element b -> Element c
f' (Element a, Element b)
x forall c. Sequential c => Element c -> c -> c
`cons` (Element a -> Element b -> Element c) -> (a, b) -> c
go Element a -> Element b -> Element c
f' (a, b)
xs) forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall a b.
(Sequential a, Sequential b) =>
(a, b) -> Maybe ((Element a, Element b), (a, b))
uncons2
zipWith3 :: (Sequential a, Sequential b, Sequential c)
=> (Element a -> Element b -> Element c -> Element col)
-> a -> b -> c -> col
zipWith3 Element a -> Element b -> Element c -> Element col
f a
a b
b c
c = forall {c} {a} {b} {c}.
(Sequential c, Sequential a, Sequential b, Sequential c) =>
(Element a -> Element b -> Element c -> Element c)
-> (a, b, c) -> c
go Element a -> Element b -> Element c -> Element col
f (forall l. IsList l => l -> [Item l]
toList a
a, forall l. IsList l => l -> [Item l]
toList b
b, forall l. IsList l => l -> [Item l]
toList c
c)
where go :: (Element a -> Element b -> Element c -> Element c)
-> (a, b, c) -> c
go Element a -> Element b -> Element c -> Element c
f' = forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. Monoid a => a
mempty (\((Element a, Element b, Element c)
x, (a, b, c)
xs) -> forall a b c d. (a -> b -> c -> d) -> (a, b, c) -> d
uncurry3 Element a -> Element b -> Element c -> Element c
f' (Element a, Element b, Element c)
x forall c. Sequential c => Element c -> c -> c
`cons` (Element a -> Element b -> Element c -> Element c)
-> (a, b, c) -> c
go Element a -> Element b -> Element c -> Element c
f' (a, b, c)
xs) forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall a b c.
(Sequential a, Sequential b, Sequential c) =>
(a, b, c) -> Maybe ((Element a, Element b, Element c), (a, b, c))
uncons3
zipWith4 :: (Sequential a, Sequential b, Sequential c, Sequential d)
=> (Element a -> Element b -> Element c -> Element d -> Element col)
-> a -> b -> c -> d -> col
zipWith4 Element a -> Element b -> Element c -> Element d -> Element col
fn a
a b
b c
c d
d = forall {c} {a} {b} {c} {d}.
(Sequential c, Sequential a, Sequential b, Sequential c,
Sequential d) =>
(Element a -> Element b -> Element c -> Element d -> Element c)
-> (a, b, c, d) -> c
go Element a -> Element b -> Element c -> Element d -> Element col
fn (forall l. IsList l => l -> [Item l]
toList a
a, forall l. IsList l => l -> [Item l]
toList b
b, forall l. IsList l => l -> [Item l]
toList c
c, forall l. IsList l => l -> [Item l]
toList d
d)
where go :: (Element a -> Element b -> Element c -> Element d -> Element c)
-> (a, b, c, d) -> c
go Element a -> Element b -> Element c -> Element d -> Element c
f' = forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. Monoid a => a
mempty (\((Element a, Element b, Element c, Element d)
x, (a, b, c, d)
xs) -> forall a b c d g. (a -> b -> c -> d -> g) -> (a, b, c, d) -> g
uncurry4 Element a -> Element b -> Element c -> Element d -> Element c
f' (Element a, Element b, Element c, Element d)
x forall c. Sequential c => Element c -> c -> c
`cons` (Element a -> Element b -> Element c -> Element d -> Element c)
-> (a, b, c, d) -> c
go Element a -> Element b -> Element c -> Element d -> Element c
f' (a, b, c, d)
xs) forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall a b c d.
(Sequential a, Sequential b, Sequential c, Sequential d) =>
(a, b, c, d)
-> Maybe
((Element a, Element b, Element c, Element d), (a, b, c, d))
uncons4
zipWith5 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e)
=> (Element a -> Element b -> Element c -> Element d -> Element e -> Element col)
-> a -> b -> c -> d -> e -> col
zipWith5 Element a
-> Element b -> Element c -> Element d -> Element e -> Element col
fn a
a b
b c
c d
d e
e = forall {c} {a} {b} {c} {d} {e}.
(Sequential c, Sequential a, Sequential b, Sequential c,
Sequential d, Sequential e) =>
(Element a
-> Element b -> Element c -> Element d -> Element e -> Element c)
-> (a, b, c, d, e) -> c
go Element a
-> Element b -> Element c -> Element d -> Element e -> Element col
fn (forall l. IsList l => l -> [Item l]
toList a
a, forall l. IsList l => l -> [Item l]
toList b
b, forall l. IsList l => l -> [Item l]
toList c
c, forall l. IsList l => l -> [Item l]
toList d
d, forall l. IsList l => l -> [Item l]
toList e
e)
where go :: (Element a
-> Element b -> Element c -> Element d -> Element e -> Element c)
-> (a, b, c, d, e) -> c
go Element a
-> Element b -> Element c -> Element d -> Element e -> Element c
f' = forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. Monoid a => a
mempty (\((Element a, Element b, Element c, Element d, Element e)
x, (a, b, c, d, e)
xs) -> forall a b c d e f.
(a -> b -> c -> d -> e -> f) -> (a, b, c, d, e) -> f
uncurry5 Element a
-> Element b -> Element c -> Element d -> Element e -> Element c
f' (Element a, Element b, Element c, Element d, Element e)
x forall c. Sequential c => Element c -> c -> c
`cons` (Element a
-> Element b -> Element c -> Element d -> Element e -> Element c)
-> (a, b, c, d, e) -> c
go Element a
-> Element b -> Element c -> Element d -> Element e -> Element c
f' (a, b, c, d, e)
xs) forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall a b c d e.
(Sequential a, Sequential b, Sequential c, Sequential d,
Sequential e) =>
(a, b, c, d, e)
-> Maybe
((Element a, Element b, Element c, Element d, Element e),
(a, b, c, d, e))
uncons5
zipWith6 :: ( Sequential a, Sequential b, Sequential c, Sequential d, Sequential e
, Sequential f)
=> (Element a -> Element b -> Element c -> Element d -> Element e -> Element f -> Element col)
-> a -> b -> c -> d -> e -> f -> col
zipWith6 Element a
-> Element b
-> Element c
-> Element d
-> Element e
-> Element f
-> Element col
fn a
a b
b c
c d
d e
e f
f = forall {c} {a} {b} {c} {d} {e} {f}.
(Sequential c, Sequential a, Sequential b, Sequential c,
Sequential d, Sequential e, Sequential f) =>
(Element a
-> Element b
-> Element c
-> Element d
-> Element e
-> Element f
-> Element c)
-> (a, b, c, d, e, f) -> c
go Element a
-> Element b
-> Element c
-> Element d
-> Element e
-> Element f
-> Element col
fn (forall l. IsList l => l -> [Item l]
toList a
a, forall l. IsList l => l -> [Item l]
toList b
b, forall l. IsList l => l -> [Item l]
toList c
c, forall l. IsList l => l -> [Item l]
toList d
d, forall l. IsList l => l -> [Item l]
toList e
e, forall l. IsList l => l -> [Item l]
toList f
f)
where go :: (Element a
-> Element b
-> Element c
-> Element d
-> Element e
-> Element f
-> Element c)
-> (a, b, c, d, e, f) -> c
go Element a
-> Element b
-> Element c
-> Element d
-> Element e
-> Element f
-> Element c
f' = forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. Monoid a => a
mempty (\((Element a, Element b, Element c, Element d, Element e, Element f)
x, (a, b, c, d, e, f)
xs) -> forall a b c d e f g.
(a -> b -> c -> d -> e -> f -> g) -> (a, b, c, d, e, f) -> g
uncurry6 Element a
-> Element b
-> Element c
-> Element d
-> Element e
-> Element f
-> Element c
f' (Element a, Element b, Element c, Element d, Element e, Element f)
x forall c. Sequential c => Element c -> c -> c
`cons` (Element a
-> Element b
-> Element c
-> Element d
-> Element e
-> Element f
-> Element c)
-> (a, b, c, d, e, f) -> c
go Element a
-> Element b
-> Element c
-> Element d
-> Element e
-> Element f
-> Element c
f' (a, b, c, d, e, f)
xs) forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall a b c d e f.
(Sequential a, Sequential b, Sequential c, Sequential d,
Sequential e, Sequential f) =>
(a, b, c, d, e, f)
-> Maybe
((Element a, Element b, Element c, Element d, Element e,
Element f),
(a, b, c, d, e, f))
uncons6
zipWith7 :: ( Sequential a, Sequential b, Sequential c, Sequential d, Sequential e
, Sequential f, Sequential g )
=> (Element a -> Element b -> Element c -> Element d -> Element e -> Element f -> Element g -> Element col)
-> a -> b -> c -> d -> e -> f -> g -> col
zipWith7 Element a
-> Element b
-> Element c
-> Element d
-> Element e
-> Element f
-> Element g
-> Element col
fn a
a b
b c
c d
d e
e f
f g
g = forall {c} {a} {b} {c} {d} {e} {f} {g}.
(Sequential c, Sequential a, Sequential b, Sequential c,
Sequential d, Sequential e, Sequential f, Sequential g) =>
(Element a
-> Element b
-> Element c
-> Element d
-> Element e
-> Element f
-> Element g
-> Element c)
-> (a, b, c, d, e, f, g) -> c
go Element a
-> Element b
-> Element c
-> Element d
-> Element e
-> Element f
-> Element g
-> Element col
fn (forall l. IsList l => l -> [Item l]
toList a
a, forall l. IsList l => l -> [Item l]
toList b
b, forall l. IsList l => l -> [Item l]
toList c
c, forall l. IsList l => l -> [Item l]
toList d
d, forall l. IsList l => l -> [Item l]
toList e
e, forall l. IsList l => l -> [Item l]
toList f
f, forall l. IsList l => l -> [Item l]
toList g
g)
where go :: (Element a
-> Element b
-> Element c
-> Element d
-> Element e
-> Element f
-> Element g
-> Element c)
-> (a, b, c, d, e, f, g) -> c
go Element a
-> Element b
-> Element c
-> Element d
-> Element e
-> Element f
-> Element g
-> Element c
f' = forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. Monoid a => a
mempty (\((Element a, Element b, Element c, Element d, Element e, Element f,
Element g)
x, (a, b, c, d, e, f, g)
xs) -> forall a b c d e f g h.
(a -> b -> c -> d -> e -> f -> g -> h)
-> (a, b, c, d, e, f, g) -> h
uncurry7 Element a
-> Element b
-> Element c
-> Element d
-> Element e
-> Element f
-> Element g
-> Element c
f' (Element a, Element b, Element c, Element d, Element e, Element f,
Element g)
x forall c. Sequential c => Element c -> c -> c
`cons` (Element a
-> Element b
-> Element c
-> Element d
-> Element e
-> Element f
-> Element g
-> Element c)
-> (a, b, c, d, e, f, g) -> c
go Element a
-> Element b
-> Element c
-> Element d
-> Element e
-> Element f
-> Element g
-> Element c
f' (a, b, c, d, e, f, g)
xs) forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall a b c d e f g.
(Sequential a, Sequential b, Sequential c, Sequential d,
Sequential e, Sequential f, Sequential g) =>
(a, b, c, d, e, f, g)
-> Maybe
((Element a, Element b, Element c, Element d, Element e, Element f,
Element g),
(a, b, c, d, e, f, g))
uncons7
instance Zippable [c]
instance UV.PrimType ty => Zippable (UV.UArray ty) where
zipWith :: forall a b.
(Sequential a, Sequential b) =>
(Element a -> Element b -> Element (UArray ty))
-> a -> b -> UArray ty
zipWith Element a -> Element b -> Element (UArray ty)
f a
as b
bs = forall a. (forall s. ST s a) -> a
runST forall a b. (a -> b) -> a -> b
$ forall ty (m :: * -> *).
(PrimType ty, PrimMonad m) =>
Int -> Builder (UArray ty) (MUArray ty) ty m () () -> m (UArray ty)
UV.builderBuild_ Int
64 forall a b. (a -> b) -> a -> b
$ forall {state :: * -> *} {ty} {t} {t} {err}.
(PrimType ty, PrimMonad state) =>
(t -> t -> ty)
-> [t] -> [t] -> Builder (UArray ty) (MUArray ty) ty state err ()
go Element a -> Element b -> Element (UArray ty)
f (forall l. IsList l => l -> [Item l]
toList a
as) (forall l. IsList l => l -> [Item l]
toList b
bs)
where
go :: (t -> t -> ty)
-> [t] -> [t] -> Builder (UArray ty) (MUArray ty) ty state err ()
go t -> t -> ty
_ [] [t]
_ = forall (m :: * -> *) a. Monad m => a -> m a
return ()
go t -> t -> ty
_ [t]
_ [] = forall (m :: * -> *) a. Monad m => a -> m a
return ()
go t -> t -> ty
f' (t
a':[t]
as') (t
b':[t]
bs') = forall ty (state :: * -> *) err.
(PrimType ty, PrimMonad state) =>
ty -> Builder (UArray ty) (MUArray ty) ty state err ()
UV.builderAppend (t -> t -> ty
f' t
a' t
b') forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (t -> t -> ty)
-> [t] -> [t] -> Builder (UArray ty) (MUArray ty) ty state err ()
go t -> t -> ty
f' [t]
as' [t]
bs'
instance Zippable (BA.Array ty) where
zipWith :: forall a b.
(Sequential a, Sequential b) =>
(Element a -> Element b -> Element (Array ty))
-> a -> b -> Array ty
zipWith Element a -> Element b -> Element (Array ty)
f a
as b
bs = forall a. (forall s. ST s a) -> a
runST forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) ty.
PrimMonad m =>
Int -> Builder (Array ty) (MArray ty) ty m () () -> m (Array ty)
BA.builderBuild_ Int
64 forall a b. (a -> b) -> a -> b
$ forall {state :: * -> *} {t} {t} {ty} {err}.
PrimMonad state =>
(t -> t -> ty)
-> [t] -> [t] -> Builder (Array ty) (MArray ty) ty state err ()
go Element a -> Element b -> Element (Array ty)
f (forall l. IsList l => l -> [Item l]
toList a
as) (forall l. IsList l => l -> [Item l]
toList b
bs)
where
go :: (t -> t -> ty)
-> [t] -> [t] -> Builder (Array ty) (MArray ty) ty state err ()
go t -> t -> ty
_ [] [t]
_ = forall (m :: * -> *) a. Monad m => a -> m a
return ()
go t -> t -> ty
_ [t]
_ [] = forall (m :: * -> *) a. Monad m => a -> m a
return ()
go t -> t -> ty
f' (t
a':[t]
as') (t
b':[t]
bs') = forall (state :: * -> *) ty err.
PrimMonad state =>
ty -> Builder (Array ty) (MArray ty) ty state err ()
BA.builderAppend (t -> t -> ty
f' t
a' t
b') forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (t -> t -> ty)
-> [t] -> [t] -> Builder (Array ty) (MArray ty) ty state err ()
go t -> t -> ty
f' [t]
as' [t]
bs'
instance Zippable S.String where
zipWith :: forall a b.
(Sequential a, Sequential b) =>
(Element a -> Element b -> Element String) -> a -> b -> String
zipWith Element a -> Element b -> Element String
f a
as b
bs = forall a. (forall s. ST s a) -> a
runST forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *).
PrimMonad m =>
Int -> Builder String MutableString Word8 m () () -> m String
S.builderBuild_ Int
64 forall a b. (a -> b) -> a -> b
$ forall {state :: * -> *} {t} {t} {err}.
PrimMonad state =>
(t -> t -> Char)
-> [t] -> [t] -> Builder String MutableString Word8 state err ()
go Element a -> Element b -> Element String
f (forall l. IsList l => l -> [Item l]
toList a
as) (forall l. IsList l => l -> [Item l]
toList b
bs)
where
go :: (t -> t -> Char)
-> [t] -> [t] -> Builder String MutableString Word8 state err ()
go t -> t -> Char
_ [] [t]
_ = forall (m :: * -> *) a. Monad m => a -> m a
return ()
go t -> t -> Char
_ [t]
_ [] = forall (m :: * -> *) a. Monad m => a -> m a
return ()
go t -> t -> Char
f' (t
a':[t]
as') (t
b':[t]
bs') = forall (state :: * -> *) err.
PrimMonad state =>
Char -> Builder String MutableString Word8 state err ()
S.builderAppend (t -> t -> Char
f' t
a' t
b') forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (t -> t -> Char)
-> [t] -> [t] -> Builder String MutableString Word8 state err ()
go t -> t -> Char
f' [t]
as' [t]
bs'
deriving instance Zippable AsciiString
class Zippable col => BoxedZippable col where
zip :: ( Sequential a, Sequential b
, Element col ~ (Element a, Element b) )
=> a -> b -> col
zip = forall col a b.
(Zippable col, Sequential a, Sequential b) =>
(Element a -> Element b -> Element col) -> a -> b -> col
zipWith (,)
zip3 :: ( Sequential a, Sequential b, Sequential c
, Element col ~ (Element a, Element b, Element c) )
=> a -> b -> c -> col
zip3 = forall col a b c.
(Zippable col, Sequential a, Sequential b, Sequential c) =>
(Element a -> Element b -> Element c -> Element col)
-> a -> b -> c -> col
zipWith3 (,,)
zip4 :: ( Sequential a, Sequential b, Sequential c, Sequential d
, Element col ~ (Element a, Element b, Element c, Element d) )
=> a -> b -> c -> d -> col
zip4 = forall col a b c d.
(Zippable col, Sequential a, Sequential b, Sequential c,
Sequential d) =>
(Element a -> Element b -> Element c -> Element d -> Element col)
-> a -> b -> c -> d -> col
zipWith4 (,,,)
zip5 :: ( Sequential a, Sequential b, Sequential c, Sequential d, Sequential e
, Element col ~ (Element a, Element b, Element c, Element d, Element e) )
=> a -> b -> c -> d -> e -> col
zip5 = forall col a b c d e.
(Zippable col, Sequential a, Sequential b, Sequential c,
Sequential d, Sequential e) =>
(Element a
-> Element b -> Element c -> Element d -> Element e -> Element col)
-> a -> b -> c -> d -> e -> col
zipWith5 (,,,,)
zip6 :: ( Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f
, Element col ~ (Element a, Element b, Element c, Element d, Element e, Element f) )
=> a -> b -> c -> d -> e -> f -> col
zip6 = forall col a b c d e f.
(Zippable col, Sequential a, Sequential b, Sequential c,
Sequential d, Sequential e, Sequential f) =>
(Element a
-> Element b
-> Element c
-> Element d
-> Element e
-> Element f
-> Element col)
-> a -> b -> c -> d -> e -> f -> col
zipWith6 (,,,,,)
zip7 :: ( Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f, Sequential g
, Element col ~ (Element a, Element b, Element c, Element d, Element e, Element f, Element g) )
=> a -> b -> c -> d -> e -> f -> g -> col
zip7 = forall col a b c d e f g.
(Zippable col, Sequential a, Sequential b, Sequential c,
Sequential d, Sequential e, Sequential f, Sequential g) =>
(Element a
-> Element b
-> Element c
-> Element d
-> Element e
-> Element f
-> Element g
-> Element col)
-> a -> b -> c -> d -> e -> f -> g -> col
zipWith7 (,,,,,,)
unzip :: (Sequential a, Sequential b, Element col ~ (Element a, Element b))
=> col -> (a, b)
unzip = forall {a} {b}.
(Sequential a, Sequential b) =>
[(Element a, Element b)] -> (a, b)
go forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall l. IsList l => l -> [Item l]
toList
where go :: [(Element a, Element b)] -> (a, b)
go [] = (forall a. Monoid a => a
mempty, forall a. Monoid a => a
mempty)
go ((Element a
a, Element b
b):[(Element a, Element b)]
xs) =
let (a
as, b
bs) = [(Element a, Element b)] -> (a, b)
go [(Element a, Element b)]
xs
in (Element a
a forall c. Sequential c => Element c -> c -> c
`cons` a
as, Element b
b forall c. Sequential c => Element c -> c -> c
`cons` b
bs)
unzip3 :: ( Sequential a, Sequential b, Sequential c
, Element col ~ (Element a, Element b, Element c) )
=> col -> (a, b, c)
unzip3 = forall {a} {b} {c}.
(Sequential a, Sequential b, Sequential c) =>
[(Element a, Element b, Element c)] -> (a, b, c)
go forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall l. IsList l => l -> [Item l]
toList
where go :: [(Element a, Element b, Element c)] -> (a, b, c)
go [] = (forall a. Monoid a => a
mempty, forall a. Monoid a => a
mempty, forall a. Monoid a => a
mempty)
go ((Element a
a, Element b
b, Element c
c):[(Element a, Element b, Element c)]
xs) =
let (a
as, b
bs, c
cs) = [(Element a, Element b, Element c)] -> (a, b, c)
go [(Element a, Element b, Element c)]
xs
in (Element a
a forall c. Sequential c => Element c -> c -> c
`cons` a
as, Element b
b forall c. Sequential c => Element c -> c -> c
`cons` b
bs, Element c
c forall c. Sequential c => Element c -> c -> c
`cons` c
cs)
unzip4 :: ( Sequential a, Sequential b, Sequential c, Sequential d
, Element col ~ (Element a, Element b, Element c, Element d) )
=> col -> (a, b, c, d)
unzip4 = forall {a} {b} {c} {d}.
(Sequential a, Sequential b, Sequential c, Sequential d) =>
[(Element a, Element b, Element c, Element d)] -> (a, b, c, d)
go forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall l. IsList l => l -> [Item l]
toList
where go :: [(Element a, Element b, Element c, Element d)] -> (a, b, c, d)
go [] = (forall a. Monoid a => a
mempty, forall a. Monoid a => a
mempty, forall a. Monoid a => a
mempty, forall a. Monoid a => a
mempty)
go ((Element a
a, Element b
b, Element c
c, Element d
d):[(Element a, Element b, Element c, Element d)]
xs) =
let (a
as, b
bs, c
cs, d
ds) = [(Element a, Element b, Element c, Element d)] -> (a, b, c, d)
go [(Element a, Element b, Element c, Element d)]
xs
in (Element a
a forall c. Sequential c => Element c -> c -> c
`cons` a
as, Element b
b forall c. Sequential c => Element c -> c -> c
`cons` b
bs, Element c
c forall c. Sequential c => Element c -> c -> c
`cons` c
cs, Element d
d forall c. Sequential c => Element c -> c -> c
`cons` d
ds)
unzip5 :: ( Sequential a, Sequential b, Sequential c, Sequential d, Sequential e
, Element col ~ (Element a, Element b, Element c, Element d, Element e) )
=> col -> (a, b, c, d, e)
unzip5 = forall {a} {b} {c} {d} {e}.
(Sequential a, Sequential b, Sequential c, Sequential d,
Sequential e) =>
[(Element a, Element b, Element c, Element d, Element e)]
-> (a, b, c, d, e)
go forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall l. IsList l => l -> [Item l]
toList
where go :: [(Element a, Element b, Element c, Element d, Element e)]
-> (a, b, c, d, e)
go [] = (forall a. Monoid a => a
mempty, forall a. Monoid a => a
mempty, forall a. Monoid a => a
mempty, forall a. Monoid a => a
mempty, forall a. Monoid a => a
mempty)
go ((Element a
a, Element b
b, Element c
c, Element d
d, Element e
e):[(Element a, Element b, Element c, Element d, Element e)]
xs) =
let (a
as, b
bs, c
cs, d
ds, e
es) = [(Element a, Element b, Element c, Element d, Element e)]
-> (a, b, c, d, e)
go [(Element a, Element b, Element c, Element d, Element e)]
xs
in (Element a
a forall c. Sequential c => Element c -> c -> c
`cons` a
as, Element b
b forall c. Sequential c => Element c -> c -> c
`cons` b
bs, Element c
c forall c. Sequential c => Element c -> c -> c
`cons` c
cs, Element d
d forall c. Sequential c => Element c -> c -> c
`cons` d
ds, Element e
e forall c. Sequential c => Element c -> c -> c
`cons` e
es)
unzip6 :: ( Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f
, Element col ~ (Element a, Element b, Element c, Element d, Element e, Element f) )
=> col -> (a, b, c, d, e, f)
unzip6 = forall {a} {b} {c} {d} {e} {f}.
(Sequential a, Sequential b, Sequential c, Sequential d,
Sequential e, Sequential f) =>
[(Element a, Element b, Element c, Element d, Element e,
Element f)]
-> (a, b, c, d, e, f)
go forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall l. IsList l => l -> [Item l]
toList
where go :: [(Element a, Element b, Element c, Element d, Element e,
Element f)]
-> (a, b, c, d, e, f)
go [] = (forall a. Monoid a => a
mempty, forall a. Monoid a => a
mempty, forall a. Monoid a => a
mempty, forall a. Monoid a => a
mempty, forall a. Monoid a => a
mempty, forall a. Monoid a => a
mempty)
go ((Element a
a, Element b
b, Element c
c, Element d
d, Element e
e, Element f
f):[(Element a, Element b, Element c, Element d, Element e,
Element f)]
xs) =
let (a
as, b
bs, c
cs, d
ds, e
es, f
fs) = [(Element a, Element b, Element c, Element d, Element e,
Element f)]
-> (a, b, c, d, e, f)
go [(Element a, Element b, Element c, Element d, Element e,
Element f)]
xs
in (Element a
a forall c. Sequential c => Element c -> c -> c
`cons` a
as, Element b
b forall c. Sequential c => Element c -> c -> c
`cons` b
bs, Element c
c forall c. Sequential c => Element c -> c -> c
`cons` c
cs, Element d
d forall c. Sequential c => Element c -> c -> c
`cons` d
ds, Element e
e forall c. Sequential c => Element c -> c -> c
`cons` e
es, Element f
f forall c. Sequential c => Element c -> c -> c
`cons` f
fs)
unzip7 :: ( Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f, Sequential g
, Element col ~ (Element a, Element b, Element c, Element d, Element e, Element f, Element g) )
=> col -> (a, b, c, d, e, f, g)
unzip7 = forall {a} {b} {c} {d} {e} {f} {g}.
(Sequential a, Sequential b, Sequential c, Sequential d,
Sequential e, Sequential f, Sequential g) =>
[(Element a, Element b, Element c, Element d, Element e, Element f,
Element g)]
-> (a, b, c, d, e, f, g)
go forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall l. IsList l => l -> [Item l]
toList
where go :: [(Element a, Element b, Element c, Element d, Element e, Element f,
Element g)]
-> (a, b, c, d, e, f, g)
go [] = (forall a. Monoid a => a
mempty, forall a. Monoid a => a
mempty, forall a. Monoid a => a
mempty, forall a. Monoid a => a
mempty, forall a. Monoid a => a
mempty, forall a. Monoid a => a
mempty, forall a. Monoid a => a
mempty)
go ((Element a
a, Element b
b, Element c
c, Element d
d, Element e
e, Element f
f, Element g
g):[(Element a, Element b, Element c, Element d, Element e, Element f,
Element g)]
xs) =
let (a
as, b
bs, c
cs, d
ds, e
es, f
fs, g
gs) = [(Element a, Element b, Element c, Element d, Element e, Element f,
Element g)]
-> (a, b, c, d, e, f, g)
go [(Element a, Element b, Element c, Element d, Element e, Element f,
Element g)]
xs
in (Element a
a forall c. Sequential c => Element c -> c -> c
`cons` a
as, Element b
b forall c. Sequential c => Element c -> c -> c
`cons` b
bs, Element c
c forall c. Sequential c => Element c -> c -> c
`cons` c
cs, Element d
d forall c. Sequential c => Element c -> c -> c
`cons` d
ds, Element e
e forall c. Sequential c => Element c -> c -> c
`cons` e
es, Element f
f forall c. Sequential c => Element c -> c -> c
`cons` f
fs, Element g
g forall c. Sequential c => Element c -> c -> c
`cons` g
gs)
instance BoxedZippable [a]
instance BoxedZippable (BA.Array ty)
uncons2 :: (Sequential a, Sequential b) => (a, b) -> Maybe ((Element a, Element b), (a, b))
uncons2 :: forall a b.
(Sequential a, Sequential b) =>
(a, b) -> Maybe ((Element a, Element b), (a, b))
uncons2 (a, b)
xs = let (a
as, b
bs) = (a, b)
xs
in do (Element a
a', a
as') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons a
as
(Element b
b', b
bs') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons b
bs
forall (m :: * -> *) a. Monad m => a -> m a
return ((Element a
a', Element b
b'), (a
as', b
bs'))
uncons3 :: (Sequential a, Sequential b, Sequential c)
=> (a, b, c)
-> Maybe ((Element a, Element b, Element c), (a, b, c))
uncons3 :: forall a b c.
(Sequential a, Sequential b, Sequential c) =>
(a, b, c) -> Maybe ((Element a, Element b, Element c), (a, b, c))
uncons3 (a, b, c)
xs = let (a
as, b
bs, c
cs) = (a, b, c)
xs
in do (Element a
a', a
as') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons a
as
(Element b
b', b
bs') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons b
bs
(Element c
c', c
cs') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons c
cs
forall (m :: * -> *) a. Monad m => a -> m a
return ((Element a
a', Element b
b', Element c
c'), (a
as', b
bs', c
cs'))
uncons4 :: (Sequential a, Sequential b, Sequential c, Sequential d)
=> (a, b, c, d)
-> Maybe ( (Element a, Element b, Element c, Element d)
, (a, b, c, d) )
uncons4 :: forall a b c d.
(Sequential a, Sequential b, Sequential c, Sequential d) =>
(a, b, c, d)
-> Maybe
((Element a, Element b, Element c, Element d), (a, b, c, d))
uncons4 (a, b, c, d)
xs = let (a
as, b
bs, c
cs, d
ds) = (a, b, c, d)
xs
in do (Element a
a', a
as') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons a
as
(Element b
b', b
bs') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons b
bs
(Element c
c', c
cs') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons c
cs
(Element d
d', d
ds') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons d
ds
forall (m :: * -> *) a. Monad m => a -> m a
return ((Element a
a', Element b
b', Element c
c', Element d
d'), (a
as', b
bs', c
cs', d
ds'))
uncons5 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e)
=> (a, b, c, d, e)
-> Maybe ( (Element a, Element b, Element c, Element d, Element e)
, (a, b, c, d, e) )
uncons5 :: forall a b c d e.
(Sequential a, Sequential b, Sequential c, Sequential d,
Sequential e) =>
(a, b, c, d, e)
-> Maybe
((Element a, Element b, Element c, Element d, Element e),
(a, b, c, d, e))
uncons5 (a, b, c, d, e)
xs = let (a
as, b
bs, c
cs, d
ds, e
es) = (a, b, c, d, e)
xs
in do (Element a
a', a
as') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons a
as
(Element b
b', b
bs') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons b
bs
(Element c
c', c
cs') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons c
cs
(Element d
d', d
ds') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons d
ds
(Element e
e', e
es') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons e
es
forall (m :: * -> *) a. Monad m => a -> m a
return ((Element a
a', Element b
b', Element c
c', Element d
d', Element e
e'), (a
as', b
bs', c
cs', d
ds', e
es'))
uncons6 :: ( Sequential a, Sequential b, Sequential c, Sequential d, Sequential e
, Sequential f )
=> (a, b, c, d, e, f)
-> Maybe ( (Element a, Element b, Element c, Element d, Element e, Element f)
, (a, b, c, d, e, f) )
uncons6 :: forall a b c d e f.
(Sequential a, Sequential b, Sequential c, Sequential d,
Sequential e, Sequential f) =>
(a, b, c, d, e, f)
-> Maybe
((Element a, Element b, Element c, Element d, Element e,
Element f),
(a, b, c, d, e, f))
uncons6 (a, b, c, d, e, f)
xs = let (a
as, b
bs, c
cs, d
ds, e
es, f
fs) = (a, b, c, d, e, f)
xs
in do (Element a
a', a
as') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons a
as
(Element b
b', b
bs') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons b
bs
(Element c
c', c
cs') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons c
cs
(Element d
d', d
ds') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons d
ds
(Element e
e', e
es') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons e
es
(Element f
f', f
fs') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons f
fs
forall (m :: * -> *) a. Monad m => a -> m a
return ((Element a
a', Element b
b', Element c
c', Element d
d', Element e
e', Element f
f'), (a
as', b
bs', c
cs', d
ds', e
es', f
fs'))
uncons7 :: ( Sequential a, Sequential b, Sequential c, Sequential d, Sequential e
, Sequential f, Sequential g )
=> (a, b, c, d, e, f, g)
-> Maybe ( (Element a, Element b, Element c, Element d, Element e, Element f
, Element g)
, (a, b, c, d, e, f, g) )
uncons7 :: forall a b c d e f g.
(Sequential a, Sequential b, Sequential c, Sequential d,
Sequential e, Sequential f, Sequential g) =>
(a, b, c, d, e, f, g)
-> Maybe
((Element a, Element b, Element c, Element d, Element e, Element f,
Element g),
(a, b, c, d, e, f, g))
uncons7 (a, b, c, d, e, f, g)
xs = let (a
as, b
bs, c
cs, d
ds, e
es, f
fs, g
gs) = (a, b, c, d, e, f, g)
xs
in do (Element a
a', a
as') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons a
as
(Element b
b', b
bs') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons b
bs
(Element c
c', c
cs') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons c
cs
(Element d
d', d
ds') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons d
ds
(Element e
e', e
es') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons e
es
(Element f
f', f
fs') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons f
fs
(Element g
g', g
gs') <- forall c. Sequential c => c -> Maybe (Element c, c)
uncons g
gs
forall (m :: * -> *) a. Monad m => a -> m a
return ( (Element a
a', Element b
b', Element c
c', Element d
d', Element e
e', Element f
f', Element g
g')
, (a
as', b
bs', c
cs', d
ds', e
es', f
fs', g
gs') )
uncurry2 :: (a -> b -> c) -> (a, b) -> c
uncurry2 :: forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry2 = forall a b c. (a -> b -> c) -> (a, b) -> c
Prelude.uncurry
uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d
uncurry3 :: forall a b c d. (a -> b -> c -> d) -> (a, b, c) -> d
uncurry3 a -> b -> c -> d
fn (a
a, b
b, c
c) = a -> b -> c -> d
fn a
a b
b c
c
uncurry4 :: (a -> b -> c -> d -> g) -> (a, b, c, d) -> g
uncurry4 :: forall a b c d g. (a -> b -> c -> d -> g) -> (a, b, c, d) -> g
uncurry4 a -> b -> c -> d -> g
fn (a
a, b
b, c
c, d
d) = a -> b -> c -> d -> g
fn a
a b
b c
c d
d
uncurry5 :: (a -> b -> c -> d -> e -> f) -> (a, b, c, d, e) -> f
uncurry5 :: forall a b c d e f.
(a -> b -> c -> d -> e -> f) -> (a, b, c, d, e) -> f
uncurry5 a -> b -> c -> d -> e -> f
fn (a
a, b
b, c
c, d
d, e
e) = a -> b -> c -> d -> e -> f
fn a
a b
b c
c d
d e
e
uncurry6 :: (a -> b -> c -> d -> e -> f -> g) -> (a, b, c, d, e, f) -> g
uncurry6 :: forall a b c d e f g.
(a -> b -> c -> d -> e -> f -> g) -> (a, b, c, d, e, f) -> g
uncurry6 a -> b -> c -> d -> e -> f -> g
fn (a
a, b
b, c
c, d
d, e
e, f
f) = a -> b -> c -> d -> e -> f -> g
fn a
a b
b c
c d
d e
e f
f
uncurry7 :: (a -> b -> c -> d -> e -> f -> g -> h) -> (a, b, c, d, e, f, g) -> h
uncurry7 :: forall a b c d e f g h.
(a -> b -> c -> d -> e -> f -> g -> h)
-> (a, b, c, d, e, f, g) -> h
uncurry7 a -> b -> c -> d -> e -> f -> g -> h
fn (a
a, b
b, c
c, d
d, e
e, f
f, g
g) = a -> b -> c -> d -> e -> f -> g -> h
fn a
a b
b c
c d
d e
e f
f g
g