module TextShow.Data.Vector (
showbVectorGenericPrec
, liftShowbVectorGenericPrec
) where
import qualified Data.Vector as B (Vector)
#if MIN_VERSION_vector(0,11,0)
import Data.Vector.Fusion.Bundle.Size (Size)
#else
import Data.Vector.Fusion.Stream.Size (Size)
#endif
import qualified Data.Vector.Generic as G (Vector)
import Data.Vector.Generic (toList)
import qualified Data.Vector.Primitive as P (Vector)
import Data.Vector.Primitive (Prim)
import qualified Data.Vector.Storable as S (Vector)
import qualified Data.Vector.Unboxed as U (Vector)
import Data.Vector.Unboxed (Unbox)
import Foreign.Storable (Storable)
import TextShow (TextShow(..), TextShow1(..), Builder)
import TextShow.TH (deriveTextShow)
#if !(MIN_VERSION_vector(0,11,0))
import TextShow.Utils (showbUnaryList, showbUnaryListWith)
#endif
showbVectorGenericPrec :: (G.Vector v a, TextShow a) => Int -> v a -> Builder
#if MIN_VERSION_vector(0,11,0)
showbVectorGenericPrec _ = showbList . toList
#else
showbVectorGenericPrec p = showbUnaryListWith showbList p . toList
#endif
liftShowbVectorGenericPrec :: G.Vector v a => ([a] -> Builder) -> Int -> v a -> Builder
#if MIN_VERSION_vector(0,11,0)
liftShowbVectorGenericPrec sl _ = sl . toList
#else
liftShowbVectorGenericPrec sl p = showbUnaryListWith sl p . toList
#endif
instance TextShow a => TextShow (B.Vector a) where
showbPrec = showbVectorGenericPrec
instance TextShow1 B.Vector where
liftShowbPrec _ sl = liftShowbVectorGenericPrec sl
instance (TextShow a, Prim a) => TextShow (P.Vector a) where
showbPrec = showbVectorGenericPrec
instance (TextShow a, Storable a) => TextShow (S.Vector a) where
showbPrec = showbVectorGenericPrec
instance (TextShow a, Unbox a) => TextShow (U.Vector a) where
showbPrec = showbVectorGenericPrec
$(deriveTextShow ''Size)