{-# OPTIONS_HADDOCK hide #-}
module ForSyDe.Atom.Skel.FastVector.Lib where

import ForSyDe.Atom 
import Data.Maybe
import Control.Applicative
import Data.List.Split
import qualified Data.List as L
import Prelude hiding (take, drop, length, zip, unzip)


-- | In this library 'Vector' is just a wrapper around a list.
newtype Vector a = Vector { Vector a -> [a]
fromVector :: [a] } deriving (Vector a -> Vector a -> Bool
(Vector a -> Vector a -> Bool)
-> (Vector a -> Vector a -> Bool) -> Eq (Vector a)
forall a. Eq a => Vector a -> Vector a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Vector a -> Vector a -> Bool
$c/= :: forall a. Eq a => Vector a -> Vector a -> Bool
== :: Vector a -> Vector a -> Bool
$c== :: forall a. Eq a => Vector a -> Vector a -> Bool
Eq)

vector :: [a] -> Vector a
vector = [a] -> Vector a
forall a. [a] -> Vector a
Vector

instance Functor Vector where
  fmap :: (a -> b) -> Vector a -> Vector b
fmap f :: a -> b
f (Vector a :: [a]
a) = [b] -> Vector b
forall a. [a] -> Vector a
Vector ((a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f [a]
a)

instance Applicative Vector where
  pure :: a -> Vector a
pure a :: a
a = [a] -> Vector a
forall a. [a] -> Vector a
Vector [a
a]
  (Vector fs :: [a -> b]
fs) <*> :: Vector (a -> b) -> Vector a -> Vector b
<*> (Vector as :: [a]
as) = [b] -> Vector b
forall a. [a] -> Vector a
Vector ([b] -> Vector b) -> [b] -> Vector b
forall a b. (a -> b) -> a -> b
$ ZipList b -> [b]
forall a. ZipList a -> [a]
getZipList ([a -> b] -> ZipList (a -> b)
forall a. [a] -> ZipList a
ZipList [a -> b]
fs ZipList (a -> b) -> ZipList a -> ZipList b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [a] -> ZipList a
forall a. [a] -> ZipList a
ZipList [a]
as) 

instance (Show a) => Show (Vector a) where
  showsPrec :: Int -> Vector a -> ShowS
showsPrec p :: Int
p (Vector []) = Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> 9) (String -> ShowS
showString "<>")
  showsPrec p :: Int
p (Vector xs :: [a]
xs) = Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> 9) (Char -> ShowS
showChar '<' ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [a] -> ShowS
forall a. Show a => [a] -> ShowS
showVector1 [a]
xs)
    where
      showVector1 :: [a] -> ShowS
showVector1 [] = Char -> ShowS
showChar '>'            
      showVector1 (y :: a
y:[]) = a -> ShowS
forall a. Show a => a -> ShowS
shows a
y ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar '>'
      showVector1 (y :: a
y:ys :: [a]
ys) = a -> ShowS
forall a. Show a => a -> ShowS
shows a
y ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar ',' 
        ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [a] -> ShowS
showVector1 [a]
ys

instance Foldable Vector where
  foldr :: (a -> b -> b) -> b -> Vector a -> b
foldr f :: a -> b -> b
f x :: b
x (Vector a :: [a]
a) = (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr a -> b -> b
f b
x [a]
a

farm11 :: (a -> b) -> f a -> f b
farm11 f :: a -> b
f = (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f
farm21 :: (a -> a -> b) -> f a -> f a -> f b
farm21 f :: a -> a -> b
f a :: f a
a b :: f a
b = a -> a -> b
f (a -> a -> b) -> f a -> f (a -> b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f a
a f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> f a
b
farm31 :: (a -> a -> a -> b) -> f a -> f a -> f a -> f b
farm31 f :: a -> a -> a -> b
f a :: f a
a b :: f a
b c :: f a
c = a -> a -> a -> b
f (a -> a -> a -> b) -> f a -> f (a -> a -> b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f a
a f (a -> a -> b) -> f a -> f (a -> b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> f a
b f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> f a
c
farm41 :: (a -> a -> a -> a -> b) -> f a -> f a -> f a -> f a -> f b
farm41 f :: a -> a -> a -> a -> b
f a :: f a
a b :: f a
b c :: f a
c d :: f a
d = a -> a -> a -> a -> b
f (a -> a -> a -> a -> b) -> f a -> f (a -> a -> a -> b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f a
a f (a -> a -> a -> b) -> f a -> f (a -> a -> b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> f a
b f (a -> a -> b) -> f a -> f (a -> b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> f a
c f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> f a
d
farm51 :: (a -> a -> a -> a -> a -> b)
-> f a -> f a -> f a -> f a -> f a -> f b
farm51 f :: a -> a -> a -> a -> a -> b
f a :: f a
a b :: f a
b c :: f a
c d :: f a
d e :: f a
e = a -> a -> a -> a -> a -> b
f (a -> a -> a -> a -> a -> b) -> f a -> f (a -> a -> a -> a -> b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f a
a f (a -> a -> a -> a -> b) -> f a -> f (a -> a -> a -> b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> f a
b f (a -> a -> a -> b) -> f a -> f (a -> a -> b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> f a
c f (a -> a -> b) -> f a -> f (a -> b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> f a
d f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> f a
e
farm12 :: (a -> (a1, b)) -> f a -> (f a1, f b)
farm12 f :: a -> (a1, b)
f = f (a1, b) -> (f a1, f b)
forall (f :: * -> *) a1 b. Functor f => f (a1, b) -> (f a1, f b)
(|<) (f (a1, b) -> (f a1, f b))
-> (f a -> f (a1, b)) -> f a -> (f a1, f b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> (a1, b)) -> f a -> f (a1, b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> (a1, b)
f
farm22 :: (a -> a -> (a1, b)) -> f a -> f a -> (f a1, f b)
farm22 f :: a -> a -> (a1, b)
f a :: f a
a = f (a1, b) -> (f a1, f b)
forall (f :: * -> *) a1 b. Functor f => f (a1, b) -> (f a1, f b)
(|<) (f (a1, b) -> (f a1, f b))
-> (f a -> f (a1, b)) -> f a -> (f a1, f b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> a -> (a1, b)) -> f a -> f a -> f (a1, b)
forall (f :: * -> *) a a b.
Applicative f =>
(a -> a -> b) -> f a -> f a -> f b
farm21 a -> a -> (a1, b)
f f a
a

infixr 5 <++>
(Vector a :: [a]
a) <++> :: Vector a -> Vector a -> Vector a
<++> (Vector b :: [a]
b) = [a] -> Vector a
forall a. [a] -> Vector a
Vector ([a]
a [a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
++ [a]
b)

unsafeApply :: ([a] -> t) -> Vector a -> t
unsafeApply f :: [a] -> t
f (Vector a :: [a]
a) = [a] -> t
f [a]
a
unsafeLift :: ([a] -> [a]) -> Vector a -> Vector a
unsafeLift  f :: [a] -> [a]
f (Vector a :: [a]
a) = [a] -> Vector a
forall a. [a] -> Vector a
Vector ([a] -> [a]
f [a]
a)

-- | See 'ForSyDe.Atom.Skel.Vector.reduce'.
reduce :: (t -> t -> t) -> Vector t -> t
reduce f :: t -> t -> t
f = ([t] -> t) -> Vector t -> t
forall a t. ([a] -> t) -> Vector a -> t
unsafeApply ((t -> t -> t) -> [t] -> t
forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
L.foldr1 t -> t -> t
f)

-- | See 'ForSyDe.Atom.Skel.Vector.length'.
length :: Vector a -> Int
length = ([a] -> Int) -> Vector a -> Int
forall a t. ([a] -> t) -> Vector a -> t
unsafeApply ([a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
L.length)

-- | See 'ForSyDe.Atom.Skel.Vector.drop'.
drop :: Int -> Vector a -> Vector a
drop n :: Int
n = ([a] -> [a]) -> Vector a -> Vector a
forall a a. ([a] -> [a]) -> Vector a -> Vector a
unsafeLift (Int -> [a] -> [a]
forall a. Int -> [a] -> [a]
L.drop Int
n)

-- | See 'ForSyDe.Atom.Skel.Vector.take'.
take :: Int -> Vector a -> Vector a
take n :: Int
n = ([a] -> [a]) -> Vector a -> Vector a
forall a a. ([a] -> [a]) -> Vector a -> Vector a
unsafeLift (Int -> [a] -> [a]
forall a. Int -> [a] -> [a]
L.take Int
n)

-- | See 'ForSyDe.Atom.Skel.Vector.first'.
first :: Vector t -> t
first = ([t] -> t) -> Vector t -> t
forall a t. ([a] -> t) -> Vector a -> t
unsafeApply [t] -> t
forall a. [a] -> a
L.head

-- | See 'ForSyDe.Atom.Skel.Vector.group'.
group :: Int -> Vector a -> Vector (Vector a)
group :: Int -> Vector a -> Vector (Vector a)
group n :: Int
n (Vector a :: [a]
a) = [Vector a] -> Vector (Vector a)
forall a. [a] -> Vector a
vector ([Vector a] -> Vector (Vector a))
-> [Vector a] -> Vector (Vector a)
forall a b. (a -> b) -> a -> b
$ ([a] -> Vector a) -> [[a]] -> [Vector a]
forall a b. (a -> b) -> [a] -> [b]
map [a] -> Vector a
forall a. [a] -> Vector a
vector ([[a]] -> [Vector a]) -> [[a]] -> [Vector a]
forall a b. (a -> b) -> a -> b
$ Int -> [a] -> [[a]]
forall e. Int -> [e] -> [[e]]
chunksOf Int
n [a]
a

-- | See 'ForSyDe.Atom.Skel.Vector.fanout'.
fanout :: a -> Vector a
fanout    = [a] -> Vector a
forall a. [a] -> Vector a
vector ([a] -> Vector a) -> (a -> [a]) -> a -> Vector a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> [a]
forall a. a -> [a]
L.repeat

-- | See 'ForSyDe.Atom.Skel.Vector.fanoutn'.
fanoutn :: Int -> a -> Vector a
fanoutn n :: Int
n = [a] -> Vector a
forall a. [a] -> Vector a
vector ([a] -> Vector a) -> (a -> [a]) -> a -> Vector a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> a -> [a]
forall a. Int -> a -> [a]
L.replicate Int
n

-- | See 'ForSyDe.Atom.Skel.Vector.stencil'.
stencil :: Int -> Vector a -> Vector (Vector a)
stencil n :: Int
n v :: Vector a
v = (Vector a -> Vector a) -> Vector (Vector a) -> Vector (Vector a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
farm11 (Int -> Vector a -> Vector a
forall a. Int -> Vector a -> Vector a
take Int
n) (Vector (Vector a) -> Vector (Vector a))
-> Vector (Vector a) -> Vector (Vector a)
forall a b. (a -> b) -> a -> b
$ Int -> Vector (Vector a) -> Vector (Vector a)
forall a. Int -> Vector a -> Vector a
dropFromEnd Int
n (Vector (Vector a) -> Vector (Vector a))
-> Vector (Vector a) -> Vector (Vector a)
forall a b. (a -> b) -> a -> b
$ Vector a -> Vector (Vector a)
forall a. Vector a -> Vector (Vector a)
tails Vector a
v
  where dropFromEnd :: Int -> Vector a -> Vector a
dropFromEnd n :: Int
n = Int -> Vector a -> Vector a
forall a. Int -> Vector a -> Vector a
take (Vector a -> Int
forall a. Vector a -> Int
length Vector a
v Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
+ 1)

-- | See 'ForSyDe.Atom.Skel.Vector.tails'.
tails :: Vector a -> Vector (Vector a)
tails = ([a] -> [Vector a]) -> Vector a -> Vector (Vector a)
forall a a. ([a] -> [a]) -> Vector a -> Vector a
unsafeLift ([Vector a] -> [Vector a]
forall a. [a] -> [a]
L.init ([Vector a] -> [Vector a])
-> ([a] -> [Vector a]) -> [a] -> [Vector a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([a] -> Vector a) -> [[a]] -> [Vector a]
forall a b. (a -> b) -> [a] -> [b]
map [a] -> Vector a
forall a. [a] -> Vector a
vector ([[a]] -> [Vector a]) -> ([a] -> [[a]]) -> [a] -> [Vector a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [a] -> [[a]]
forall a. [a] -> [[a]]
L.tails)

-- | See 'ForSyDe.Atom.Skel.Vector.concat'.
concat :: Vector (Vector a) -> Vector a
concat = ([Vector a] -> [a]) -> Vector (Vector a) -> Vector a
forall a a. ([a] -> [a]) -> Vector a -> Vector a
unsafeLift ([[a]] -> [a]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
L.concat ([[a]] -> [a]) -> ([Vector a] -> [[a]]) -> [Vector a] -> [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Vector a -> [a]) -> [Vector a] -> [[a]]
forall a b. (a -> b) -> [a] -> [b]
map Vector a -> [a]
forall a. Vector a -> [a]
fromVector)

-- | See 'ForSyDe.Atom.Skel.Vector.iterate'.
iterate :: Int -> (a -> a) -> a -> Vector a
iterate n :: Int
n f :: a -> a
f i :: a
i = [a] -> Vector a
forall a. [a] -> Vector a
vector ([a] -> Vector a) -> [a] -> Vector a
forall a b. (a -> b) -> a -> b
$ Int -> [a] -> [a]
forall a. Int -> [a] -> [a]
L.take Int
n ([a] -> [a]) -> [a] -> [a]
forall a b. (a -> b) -> a -> b
$ (a -> a) -> a -> [a]
forall a. (a -> a) -> a -> [a]
L.iterate a -> a
f a
i 

-- | See 'ForSyDe.Atom.Skel.Vector.pipe'.
pipe :: Vector (a -> a) -> a -> a
pipe (Vector []) i :: a
i = a
i
pipe v :: Vector (a -> a)
v i :: a
i = ([a -> a] -> a -> a) -> Vector (a -> a) -> a -> a
forall a t. ([a] -> t) -> Vector a -> t
unsafeApply (((a -> a) -> (a -> a) -> a -> a) -> [a -> a] -> a -> a
forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
L.foldr1 (a -> a) -> (a -> a) -> a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.)) Vector (a -> a)
v a
i

-- | See 'ForSyDe.Atom.Skel.Vector.pipe1'.
pipe1 :: (a -> t -> t) -> Vector a -> t -> t
pipe1 f :: a -> t -> t
f v :: Vector a
v i :: t
i = ([a] -> t) -> Vector a -> t
forall a t. ([a] -> t) -> Vector a -> t
unsafeApply ((a -> t -> t) -> t -> [a] -> t
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
L.foldr a -> t -> t
f t
i) Vector a
v

-- | See 'ForSyDe.Atom.Skel.Vector.reverse'.
reverse :: Vector a -> Vector a
reverse = ([a] -> [a]) -> Vector a -> Vector a
forall a a. ([a] -> [a]) -> Vector a -> Vector a
unsafeLift [a] -> [a]
forall a. [a] -> [a]
L.reverse

-- | See 'ForSyDe.Atom.Skel.Vector.recuri'.
recuri :: Vector (b -> b) -> b -> Vector b
recuri ps :: Vector (b -> b)
ps s :: b
s = (Vector (b -> b) -> b) -> Vector (Vector (b -> b)) -> Vector b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
farm11 (Vector (b -> b) -> b -> b
forall a. Vector (a -> a) -> a -> a
`pipe` b
s) (([b -> b] -> [Vector (b -> b)])
-> Vector (b -> b) -> Vector (Vector (b -> b))
forall a a. ([a] -> [a]) -> Vector a -> Vector a
unsafeLift (([b -> b] -> Vector (b -> b)) -> [[b -> b]] -> [Vector (b -> b)]
forall a b. (a -> b) -> [a] -> [b]
L.map [b -> b] -> Vector (b -> b)
forall a. [a] -> Vector a
vector ([[b -> b]] -> [Vector (b -> b)])
-> ([b -> b] -> [[b -> b]]) -> [b -> b] -> [Vector (b -> b)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [b -> b] -> [[b -> b]]
forall a. [a] -> [[a]]
L.tails) Vector (b -> b)
ps)



-- reducei1 p i v1 vs       = S.farm21 p v1 vs =<<= i
-- tail'  Null = Null
-- tail'  xs   = V.tail xs
-- first' Null = Null
-- first' xs   = V.first xs

-- -- | The function 'rotate' rotates a vector based on an index offset.
-- --
-- -- * @(> 0)@ : rotates the vector left with the corresponding number
-- -- of positions.
-- --
-- -- * @(= 0)@ : does not modify the vector.
-- --
-- -- * @(< 0)@ : rotates the vector right with the corresponding number
-- -- of positions.
-- rotate :: Int -> Vector a -> Vector a
-- rotate n
--   | n > 0     = V.pipe (V.fanoutn (abs n) V.rotl)
--   | n < 0     = V.pipe (V.fanoutn (abs n) V.rotr)
--   | otherwise = id


-- -- | takes the first /n/ elements of a vector.
-- --
-- -- >>> take 5 $ vector [1,2,3,4,5,6,7,8,9]
-- -- <1,2,3,4,5>
-- --
-- -- <<fig/eqs-skel-vector-take.png>>
-- take _ Null = Null
-- take n v    = reducei1 sel Null indexes . S.farm11 unit $ v
--   where sel i x y = if i < n then x <++> y else x

-- -- | drops the first /n/ elements of a vector.
-- --
-- -- >>> drop 5 $ vector [1,2,3,4,5,6,7,8,9]
-- -- <6,7,8,9>
-- --
-- -- <<fig/eqs-skel-vector-drop.png>>
-- drop _ Null = Null
-- drop n v    = reducei1 sel Null indexes . S.farm11 unit $ v
--   where sel i x y = if i > n then x <++> y else y

-- -- | groups a vector into sub-vectors of /n/ elements.
-- --
-- -- >>> group 3 $ vector [1,2,3,4,5,6,7,8]
-- -- <<1,2,3>,<4,5,6>,<7,8>>
-- --
-- -- <<fig/eqs-skel-vector-group.png>>
-- --
-- -- <<fig/skel-vector-comm-group.png>>
-- -- <<fig/skel-vector-comm-group-net.png>>
-- group :: Int -> Vector a -> Vector (Vector a)
-- group _ Null = unit Null
-- group n v = reducei1 sel Null indexes . S.farm11 (unit . unit) $ v
--   where sel i x y
--           | i `mod` n == 0 = x <++> y
--           | otherwise      = (S.first x <++> first' y) :> tail' y

-- | See 'ForSyDe.Atom.Skel.Vector.get'.
get :: Int -> Vector a -> Maybe a 
get :: Int -> Vector a -> Maybe a
get _ (Vector []) = Maybe a
forall a. Maybe a
Nothing
get n :: Int
n v :: Vector a
v | Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Vector a -> Int
forall a. Vector a -> Int
length Vector a
v = Maybe a
forall a. Maybe a
Nothing
        | Bool
otherwise = a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> a -> Maybe a
forall a b. (a -> b) -> a -> b
$ Vector a -> [a]
forall a. Vector a -> [a]
fromVector Vector a
v [a] -> Int -> a
forall a. [a] -> Int -> a
!! Int
n

-- -- | the same as 'get' but with flipped arguments.
-- v <@  ix = get ix v

-- -- | unsafe version of '<@>'. Throws an exception if /n > l/.
-- v <@! ix | isNothing e = error "get!: index out of bounds"
--          | otherwise   = fromJust e
--   where e = get ix v


-- indexes = V.vector [1..] :: Vector Int

-- indexesTo n = take n $ indexes


-- -- | Returns a stencil of @n@ neighboring elements for each possible
-- -- element in a vector.
-- --
-- -- >>> stencilV 3 $ vector [1..5]
-- -- <<1,2,3>,<2,3,4>,<3,4,5>>
-- stencil :: Int               -- ^ stencil size @= n@
--         -> Vector a          -- ^ /length/ = @la@ 
--         -> Vector (Vector a) -- ^ /length/ = @la - n + 1@ 
-- stencil n v = V.farm11 (take n) $ dropFromEnd n $ V.tails v
--   where dropFromEnd n = take (length v - n + 1)


-- zip = farm21 (,)

-- unzip = farm12 id

evensF :: [a] -> [a]
evensF [] = []
evensF [x :: a
x] = [a
x]
evensF (x :: a
x:_:xs :: [a]
xs) = a
xa -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a] -> [a]
evensF [a]
xs
oddsF :: [a] -> [a]
oddsF  [] = []
oddsF  [_] = []
oddsF  (_:y :: a
y:xs :: [a]
xs) = a
ya -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a] -> [a]
oddsF [a]
xs

-- | See 'ForSyDe.Atom.Skel.Vector.DSP.evens'.
evens :: Vector a -> Vector a
evens = ([a] -> [a]) -> Vector a -> Vector a
forall a a. ([a] -> [a]) -> Vector a -> Vector a
unsafeLift [a] -> [a]
forall a. [a] -> [a]
evensF

-- | See 'ForSyDe.Atom.Skel.Vector.DSP.odds'.
odds :: Vector a -> Vector a
odds = ([a] -> [a]) -> Vector a -> Vector a
forall a a. ([a] -> [a]) -> Vector a -> Vector a
unsafeLift [a] -> [a]
forall a. [a] -> [a]
oddsF