{-# LANGUAGE FlexibleInstances     #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies          #-}

module HaskellWorks.Data.Concat
  ( Concat(..)
  ) where

import Data.Int
import Data.Word

import qualified Data.ByteString      as BS
import qualified Data.List            as L
import qualified Data.Vector          as DV
import qualified Data.Vector.Storable as DVS

-- | Class of values that support vector like operations
class Concat v where
  concat :: [v] -> v

instance Concat [a] where
  concat :: [[a]] -> [a]
concat = [[a]] -> [a]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
L.concat
  {-# INLINE concat #-}

instance Concat BS.ByteString where
  concat :: [ByteString] -> ByteString
concat = [ByteString] -> ByteString
BS.concat
  {-# INLINE concat #-}

instance Concat (DV.Vector Word8) where
  concat :: [Vector Word8] -> Vector Word8
concat = [Vector Word8] -> Vector Word8
forall a. [Vector a] -> Vector a
DV.concat
  {-# INLINE concat #-}

instance Concat (DV.Vector Word16) where
  concat :: [Vector Word16] -> Vector Word16
concat = [Vector Word16] -> Vector Word16
forall a. [Vector a] -> Vector a
DV.concat
  {-# INLINE concat #-}

instance Concat (DV.Vector Word32) where
  concat :: [Vector Word32] -> Vector Word32
concat = [Vector Word32] -> Vector Word32
forall a. [Vector a] -> Vector a
DV.concat
  {-# INLINE concat #-}

instance Concat (DV.Vector Word64) where
  concat :: [Vector Word64] -> Vector Word64
concat = [Vector Word64] -> Vector Word64
forall a. [Vector a] -> Vector a
DV.concat
  {-# INLINE concat #-}

instance Concat (DVS.Vector Word8) where
  concat :: [Vector Word8] -> Vector Word8
concat = [Vector Word8] -> Vector Word8
forall a. Storable a => [Vector a] -> Vector a
DVS.concat
  {-# INLINE concat #-}

instance Concat (DVS.Vector Word16) where
  concat :: [Vector Word16] -> Vector Word16
concat = [Vector Word16] -> Vector Word16
forall a. Storable a => [Vector a] -> Vector a
DVS.concat
  {-# INLINE concat #-}

instance Concat (DVS.Vector Word32) where
  concat :: [Vector Word32] -> Vector Word32
concat = [Vector Word32] -> Vector Word32
forall a. Storable a => [Vector a] -> Vector a
DVS.concat
  {-# INLINE concat #-}

instance Concat (DVS.Vector Word64) where
  concat :: [Vector Word64] -> Vector Word64
concat = [Vector Word64] -> Vector Word64
forall a. Storable a => [Vector a] -> Vector a
DVS.concat
  {-# INLINE concat #-}

instance Concat (DV.Vector Int8) where
  concat :: [Vector Int8] -> Vector Int8
concat = [Vector Int8] -> Vector Int8
forall a. [Vector a] -> Vector a
DV.concat
  {-# INLINE concat #-}

instance Concat (DV.Vector Int16) where
  concat :: [Vector Int16] -> Vector Int16
concat = [Vector Int16] -> Vector Int16
forall a. [Vector a] -> Vector a
DV.concat
  {-# INLINE concat #-}

instance Concat (DV.Vector Int32) where
  concat :: [Vector Int32] -> Vector Int32
concat = [Vector Int32] -> Vector Int32
forall a. [Vector a] -> Vector a
DV.concat
  {-# INLINE concat #-}

instance Concat (DV.Vector Int64) where
  concat :: [Vector Int64] -> Vector Int64
concat = [Vector Int64] -> Vector Int64
forall a. [Vector a] -> Vector a
DV.concat
  {-# INLINE concat #-}

instance Concat (DVS.Vector Int8) where
  concat :: [Vector Int8] -> Vector Int8
concat = [Vector Int8] -> Vector Int8
forall a. Storable a => [Vector a] -> Vector a
DVS.concat
  {-# INLINE concat #-}

instance Concat (DVS.Vector Int16) where
  concat :: [Vector Int16] -> Vector Int16
concat = [Vector Int16] -> Vector Int16
forall a. Storable a => [Vector a] -> Vector a
DVS.concat
  {-# INLINE concat #-}

instance Concat (DVS.Vector Int32) where
  concat :: [Vector Int32] -> Vector Int32
concat = [Vector Int32] -> Vector Int32
forall a. Storable a => [Vector a] -> Vector a
DVS.concat
  {-# INLINE concat #-}

instance Concat (DVS.Vector Int64) where
  concat :: [Vector Int64] -> Vector Int64
concat = [Vector Int64] -> Vector Int64
forall a. Storable a => [Vector a] -> Vector a
DVS.concat
  {-# INLINE concat #-}

instance Concat (DVS.Vector Int) where
  concat :: [Vector Int] -> Vector Int
concat = [Vector Int] -> Vector Int
forall a. Storable a => [Vector a] -> Vector a
DVS.concat
  {-# INLINE concat #-}