module Data.Zip where
import qualified Data.NonEmpty.Class as C
import qualified Data.Traversable as Trav
import Data.Traversable (Traversable, )
import Control.Applicative (Applicative, pure, (<*>), )
newtype T f a = Cons {decons :: f a}
instance Functor f => Functor (T f) where
fmap f (Cons xs) = Cons $ fmap f xs
instance (C.Zip f, C.Repeat f) => Applicative (T f) where
pure a = Cons $ C.repeat a
Cons f <*> Cons x = Cons $ C.zipWith ($) f x
transposeClip ::
(Traversable f, C.Zip g, C.Repeat g) =>
f (g a) -> g (f a)
transposeClip =
decons . Trav.sequenceA . fmap Cons