{-# LANGUAGE PostfixOperators #-}
{-# OPTIONS_HADDOCK hide #-}
module ForSyDe.Atom.Skel.Vector.Interface where
import ForSyDe.Atom.MoC
import ForSyDe.Atom.MoC.Stream as S
import ForSyDe.Atom.Skel
import ForSyDe.Atom.Skel.Vector.Core
import ForSyDe.Atom.Skel.Vector.Lib as V (recuri, tail, fanout, fanoutn, reduce1)
import Prelude hiding (tail, map, length)
import Control.Applicative
mapS :: MoC e => (a -> b) -> Stream (e a) -> Stream (e b)
mapS :: (a -> b) -> Stream (e a) -> Stream (e b)
mapS = (e a -> e b) -> Stream (e a) -> Stream (e b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((e a -> e b) -> Stream (e a) -> Stream (e b))
-> ((a -> b) -> e a -> e b)
-> (a -> b)
-> Stream (e a)
-> Stream (e b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> b) -> e a -> e b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
zipx :: MoC e
=> Vector ((Vector a -> Vector a -> Vector a)
-> Fun e (Vector a) (Fun e (Vector a)
(Ret e (Vector a))))
-> Vector (Stream (e a))
-> Stream (e (Vector a))
zipx :: Vector
((Vector a -> Vector a -> Vector a)
-> Fun e (Vector a) (Fun e (Vector a) (Ret e (Vector a))))
-> Vector (Stream (e a)) -> Stream (e (Vector a))
zipx part :: Vector
((Vector a -> Vector a -> Vector a)
-> Fun e (Vector a) (Fun e (Vector a) (Ret e (Vector a))))
part = (((Vector a -> Vector a -> Vector a)
-> Fun e (Vector a) (Fun e (Vector a) (Ret e (Vector a))))
-> Stream (e (Vector a))
-> Stream (e (Vector a))
-> Stream (e (Vector a)))
-> Vector
((Vector a -> Vector a -> Vector a)
-> Fun e (Vector a) (Fun e (Vector a) (Ret e (Vector a))))
-> Vector (Stream (e (Vector a)))
-> Stream (e (Vector a))
forall a1 a. (a1 -> a -> a -> a) -> Vector a1 -> Vector a -> a
V.reduce1 ((Vector a -> Vector a -> Vector a)
-> Fun e (Vector a) (Fun e (Vector a) (Ret e (Vector a))))
-> Stream (e (Vector a))
-> Stream (e (Vector a))
-> Stream (e (Vector a))
forall (e :: * -> *) a a1 a2 b.
MoC e =>
((Vector a -> Vector a -> Vector a)
-> Fun e a1 (Fun e a2 (Ret e b)))
-> Stream (e a1) -> Stream (e a2) -> Stream (e b)
sync Vector
((Vector a -> Vector a -> Vector a)
-> Fun e (Vector a) (Fun e (Vector a) (Ret e (Vector a))))
part (Vector (Stream (e (Vector a))) -> Stream (e (Vector a)))
-> (Vector (Stream (e a)) -> Vector (Stream (e (Vector a))))
-> Vector (Stream (e a))
-> Stream (e (Vector a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Stream (e a) -> Stream (e (Vector a)))
-> Vector (Stream (e a)) -> Vector (Stream (e (Vector a)))
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
farm11 ((a -> Vector a) -> Stream (e a) -> Stream (e (Vector a))
forall (e :: * -> *) a b.
MoC e =>
(a -> b) -> Stream (e a) -> Stream (e b)
mapS a -> Vector a
forall a. a -> Vector a
unit)
where sync :: ((Vector a -> Vector a -> Vector a)
-> Fun e a1 (Fun e a2 (Ret e b)))
-> Stream (e a1) -> Stream (e a2) -> Stream (e b)
sync p :: (Vector a -> Vector a -> Vector a) -> Fun e a1 (Fun e a2 (Ret e b))
p = Fun e a1 (Fun e a2 (Ret e b))
-> Stream (e a1) -> Stream (e a2) -> Stream (e b)
forall (e :: * -> *) a1 a2 b.
MoC e =>
Fun e a1 (Fun e a2 (Ret e b))
-> Stream (e a1) -> Stream (e a2) -> Stream (e b)
comb21 ((Vector a -> Vector a -> Vector a) -> Fun e a1 (Fun e a2 (Ret e b))
p Vector a -> Vector a -> Vector a
forall a. Vector a -> Vector a -> Vector a
(<++>))
unzipx :: (MoC e)
=> (Vector a -> Vector (Ret e a))
-> Integer
-> Stream (e (Vector a))
-> Vector (Stream (e a))
unzipx :: (Vector a -> Vector (Ret e a))
-> Integer -> Stream (e (Vector a)) -> Vector (Stream (e a))
unzipx parts :: Vector a -> Vector (Ret e a)
parts n :: Integer
n = (Stream (e (Vector (Ret e a))) -> Stream (e a))
-> Vector (Stream (e (Vector (Ret e a)))) -> Vector (Stream (e a))
forall (c :: * -> *) a b. Skeleton c => (a -> b) -> c a -> c b
farm11 Stream (e (Vector (Ret e a))) -> Stream (e a)
forall b. Stream (e (Vector (Ret e b))) -> Stream (e b)
rebuild (Vector (Stream (e (Vector (Ret e a)))) -> Vector (Stream (e a)))
-> (Stream (e (Vector a))
-> Vector (Stream (e (Vector (Ret e a)))))
-> Stream (e (Vector a))
-> Vector (Stream (e a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector
(Stream (e (Vector (Ret e a))) -> Stream (e (Vector (Ret e a))))
-> Stream (e (Vector (Ret e a)))
-> Vector (Stream (e (Vector (Ret e a))))
forall b. Vector (b -> b) -> b -> Vector b
recuri Vector
(Stream (e (Vector (Ret e a))) -> Stream (e (Vector (Ret e a))))
forall a. Vector (Stream (e (Vector a)) -> Stream (e (Vector a)))
transpose (Stream (e (Vector (Ret e a)))
-> Vector (Stream (e (Vector (Ret e a)))))
-> (Stream (e (Vector a)) -> Stream (e (Vector (Ret e a))))
-> Stream (e (Vector a))
-> Vector (Stream (e (Vector (Ret e a))))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Vector a -> Vector (Ret e a))
-> Stream (e (Vector a)) -> Stream (e (Vector (Ret e a)))
forall (e :: * -> *) a b.
MoC e =>
(a -> b) -> Stream (e a) -> Stream (e b)
mapS Vector a -> Vector (Ret e a)
parts
where transpose :: Vector (Stream (e (Vector a)) -> Stream (e (Vector a)))
transpose = Integer
-> (Stream (e (Vector a)) -> Stream (e (Vector a)))
-> Vector (Stream (e (Vector a)) -> Stream (e (Vector a)))
forall t a. (Ord t, Num t) => t -> a -> Vector a
fanoutn (Integer
nInteger -> Integer -> Integer
forall a. Num a => a -> a -> a
-1) ((Vector a -> Vector a)
-> Stream (e (Vector a)) -> Stream (e (Vector a))
forall (e :: * -> *) a b.
MoC e =>
(a -> b) -> Stream (e a) -> Stream (e b)
mapS Vector a -> Vector a
forall a. Vector a -> Vector a
tail)
rebuild :: Stream (e (Vector (Ret e b))) -> Stream (e b)
rebuild = Stream (e (Ret e b)) -> Stream (e b)
forall (e :: * -> *) b.
MoC e =>
Stream (e (Ret e b)) -> Stream (e b)
(-*) (Stream (e (Ret e b)) -> Stream (e b))
-> (Stream (e (Vector (Ret e b))) -> Stream (e (Ret e b)))
-> Stream (e (Vector (Ret e b)))
-> Stream (e b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Vector (Ret e b) -> Ret e b)
-> Stream (e (Vector (Ret e b))) -> Stream (e (Ret e b))
forall (e :: * -> *) a b.
MoC e =>
(a -> b) -> Stream (e a) -> Stream (e b)
mapS Vector (Ret e b) -> Ret e b
forall (c :: * -> *) a. Skeleton c => c a -> a
first