module Data.Sequential (Sequential(..)) where
import Data.Foldable
import Data.Sequence (Seq)
import qualified Data.Sequence as Seq
import Data.Vector (Vector)
import qualified Data.Vector as V
class Foldable f => Sequential f where
toVector :: f a -> Vector a
toSeq :: f a -> Seq a
instance Sequential [] where
{-# INLINE toVector #-}
toVector :: forall a. [a] -> Vector a
toVector = [a] -> Vector a
forall a. [a] -> Vector a
V.fromList
{-# INLINE toSeq #-}
toSeq :: forall a. [a] -> Seq a
toSeq = [a] -> Seq a
forall a. [a] -> Seq a
Seq.fromList
instance Sequential Vector where
{-# INLINE toVector #-}
toVector :: forall a. Vector a -> Vector a
toVector = Vector a -> Vector a
forall a. a -> a
id
{-# INLINE toSeq #-}
toSeq :: forall a. Vector a -> Seq a
toSeq = [a] -> Seq a
forall a. [a] -> Seq a
Seq.fromList ([a] -> Seq a) -> (Vector a -> [a]) -> Vector a -> Seq a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector a -> [a]
forall a. Vector a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList
instance Sequential Seq where
{-# INLINE toVector #-}
toVector :: forall a. Seq a -> Vector a
toVector = [a] -> Vector a
forall a. [a] -> Vector a
V.fromList ([a] -> Vector a) -> (Seq a -> [a]) -> Seq a -> Vector a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Seq a -> [a]
forall a. Seq a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList
{-# INLINE toSeq #-}
toSeq :: forall a. Seq a -> Seq a
toSeq = Seq a -> Seq a
forall a. a -> a
id