packages feed

unboxing-vector 0.1.1.0 → 0.2.0.0

raw patch · 9 files changed

+311/−185 lines, 9 files

Files

ChangeLog.md view
@@ -1,5 +1,11 @@ # Changelog for unboxing-vector +## Version 0.2.0.0 (2020-09-27)++- Add coercion functions for mutable vectors.+- Add `Unboxable` instance for several mode types: `Data.Semigroup.Arg`, `Data.Monoid.Alt`, `Data.Functor.Compose`.+- The dependency on mono-traversable can be disabled via a package flag.+ ## Version 0.1.1.0 (2019-07-01)  - Support older GHC versions.
README.md view
@@ -1,7 +1,5 @@ # unboxing-vector: A newtype-friendly variant of unboxed vectors -[![Build Status](https://travis-ci.org/minoki/unboxing-vector.svg?branch=master)](https://travis-ci.org/minoki/unboxing-vector)- This package provides newtype-friendly wrappers for `Data.Vector.Unboxed` in [`vector` package](http://hackage.haskell.org/package/vector).  ## Description
src/Data/Vector/Unboxing.hs view
@@ -78,6 +78,7 @@   ,convert -- from Data.Vector.Generic   ,toUnboxedVector   ,fromUnboxedVector+  ,coercionWithUnboxedVector   ,coerceVector   ,liftCoercion   ,vectorCoercion@@ -90,6 +91,7 @@ import qualified Data.Vector.Generic as G import Data.Vector.Generic (convert) import Data.Vector.Unboxing.Internal+import Data.Vector.Unboxing.Instances () import Control.Monad.ST import Control.Monad.Primitive (PrimMonad,PrimState) 
+ src/Data/Vector/Unboxing/Instances.hs view
@@ -0,0 +1,164 @@+{-# LANGUAGE BangPatterns #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE TypeFamilies #-}+{-# OPTIONS_GHC -Wno-orphans -Wno-unused-imports #-}+{-# OPTIONS_HADDOCK hide #-}+module Data.Vector.Unboxing.Instances () where+import Data.Vector.Unboxing.Internal+import qualified Data.Vector.Generic as G++#if defined(ENABLE_MONO_TRAVERSABLE)++import qualified Data.MonoTraversable -- from mono-traversable+import qualified Data.Sequences       -- from mono-traversable++--+-- Classes from mono-traversable+--++type instance Data.MonoTraversable.Element (Vector a) = a++instance (Unboxable a) => Data.MonoTraversable.MonoFunctor (Vector a) where+  omap = G.map+  {-# INLINE omap #-}++instance (Unboxable a) => Data.MonoTraversable.MonoFoldable (Vector a) where+  ofoldMap f = G.foldr (mappend . f) mempty+  ofoldr = G.foldr+  ofoldl' = G.foldl'+  otoList = G.toList+  oall = G.all+  oany = G.any+  onull = G.null+  olength = G.length+  olength64 = fromIntegral . G.length+  -- ocompareLength : use default+  -- otraverse_ : use default+  -- ofor_ : use default+  -- omapM_ : use default (G.mapM_ requires a Monad, unfortunately)+  -- oforM_ : use default (G.forM_ requires a Monad, unfortunately)+  ofoldlM = G.foldM+  -- ofoldMap1Ex : use default+  ofoldr1Ex = G.foldr1+  ofoldl1Ex' = G.foldl1'+  headEx = G.head+  lastEx = G.last+  unsafeHead = G.unsafeHead+  unsafeLast = G.unsafeLast+  maximumByEx = G.maximumBy+  minimumByEx = G.minimumBy+  oelem = G.elem+  onotElem = G.notElem+  {-# INLINE ofoldMap #-}+  {-# INLINE ofoldr #-}+  {-# INLINE ofoldl' #-}+  {-# INLINE otoList #-}+  {-# INLINE oall #-}+  {-# INLINE oany #-}+  {-# INLINE onull #-}+  {-# INLINE olength #-}+  {-# INLINE olength64 #-}+  {-# INLINE ofoldlM #-}+  {-# INLINE ofoldr1Ex #-}+  {-# INLINE ofoldl1Ex' #-}+  {-# INLINE headEx #-}+  {-# INLINE lastEx #-}+  {-# INLINE unsafeHead #-}+  {-# INLINE unsafeLast #-}+  {-# INLINE maximumByEx #-}+  {-# INLINE minimumByEx #-}+  {-# INLINE oelem #-}+  {-# INLINE onotElem #-}++instance (Unboxable a) => Data.MonoTraversable.MonoTraversable (Vector a) where+  otraverse f v = let !n = G.length v+                  in G.fromListN n <$> traverse f (G.toList v)+  omapM = Data.MonoTraversable.otraverse+  {-# INLINE otraverse #-}+  {-# INLINE omapM #-}++instance (Unboxable a) => Data.MonoTraversable.MonoPointed (Vector a) where+  opoint = G.singleton+  {-# INLINE opoint #-}++instance (Unboxable a) => Data.MonoTraversable.GrowingAppend (Vector a)++instance (Unboxable a) => Data.Sequences.SemiSequence (Vector a) where+  type Index (Vector a) = Int+  intersperse = Data.Sequences.defaultIntersperse+  reverse = G.reverse+  find = G.find+  sortBy = Data.Sequences.vectorSortBy+  cons = G.cons+  snoc = G.snoc+  {-# INLINE intersperse #-}+  {-# INLINE reverse #-}+  {-# INLINE find #-}+  {-# INLINE sortBy #-}+  {-# INLINE cons #-}+  {-# INLINE snoc #-}++instance (Unboxable a) => Data.Sequences.IsSequence (Vector a) where+  fromList = G.fromList+  lengthIndex = G.length+  break = G.break+  span = G.span+  dropWhile = G.dropWhile+  takeWhile = G.takeWhile+  splitAt = G.splitAt+  -- unsafeSplitAt : use default+  take = G.take+  unsafeTake = G.unsafeTake+  drop = G.drop+  unsafeDrop = G.unsafeDrop+  -- dropEnd : use default+  partition = G.partition+  uncons v | G.null v = Nothing+           | otherwise = Just (G.head v, G.tail v)+  unsnoc v | G.null v = Nothing+           | otherwise = Just (G.init v, G.last v)+  filter = G.filter+  filterM = G.filterM+  replicate = G.replicate+  replicateM = G.replicateM+  -- groupBy : use default+  -- groupAllOn : use default+  -- subsequences : use default+  -- permutations : use default+  tailEx = G.tail+  -- tailMay : use default+  initEx = G.init+  -- initMay : use default+  unsafeTail = G.unsafeTail+  unsafeInit = G.unsafeInit+  index = (G.!?)+  indexEx = (G.!)+  unsafeIndex = G.unsafeIndex+  -- splitWhen : use default+  {-# INLINE fromList #-}+  {-# INLINE lengthIndex #-}+  {-# INLINE break #-}+  {-# INLINE span #-}+  {-# INLINE dropWhile #-}+  {-# INLINE takeWhile #-}+  {-# INLINE splitAt #-}+  {-# INLINE take #-}+  {-# INLINE unsafeTake #-}+  {-# INLINE drop #-}+  {-# INLINE unsafeDrop #-}+  {-# INLINE partition #-}+  {-# INLINE uncons #-}+  {-# INLINE unsnoc #-}+  {-# INLINE filter #-}+  {-# INLINE filterM #-}+  {-# INLINE replicate #-}+  {-# INLINE replicateM #-}+  {-# INLINE tailEx #-}+  {-# INLINE initEx #-}+  {-# INLINE unsafeTail #-}+  {-# INLINE unsafeInit #-}+  {-# INLINE index #-}+  {-# INLINE indexEx #-}+  {-# INLINE unsafeIndex #-}++#endif
src/Data/Vector/Unboxing/Internal.hs view
@@ -6,7 +6,6 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-}@@ -24,6 +23,9 @@   ,toUnboxedVector   ,fromUnboxedVector   ,coercionWithUnboxedVector+  ,coerceMVector+  ,liftCoercionM+  ,mVectorCoercion   ,toUnboxedMVector   ,fromUnboxedMVector   ,coercionWithUnboxedMVector@@ -44,11 +46,10 @@ import qualified Data.Complex import qualified Data.Functor.Identity import qualified Data.Functor.Const+import qualified Data.Functor.Compose import qualified Data.Ord import qualified Data.Semigroup import qualified Data.Monoid-import qualified Data.MonoTraversable -- from mono-traversable-import qualified Data.Sequences       -- from mono-traversable import GHC.Exts (IsList(..)) import Control.DeepSeq (NFData(..)) import Text.Read (Read(..),readListPrecDefault)@@ -122,6 +123,18 @@ fromUnboxedVector = coerce {-# INLINE fromUnboxedVector #-} +coerceMVector :: (Coercible a b, Unboxable a, Unboxable b, CoercibleRep a ~ CoercibleRep b, Rep a ~ Rep b) => MVector s a -> MVector s b+coerceMVector = coerce+{-# INLINE coerceMVector #-}++liftCoercionM :: (Unboxable a, Unboxable b, CoercibleRep a ~ CoercibleRep b, Rep a ~ Rep b) => Coercion a b -> Coercion (MVector s a) (MVector s b)+liftCoercionM Coercion = Coercion+{-# INLINE liftCoercionM #-}++mVectorCoercion :: (Coercible a b, Unboxable a, Unboxable b, CoercibleRep a ~ CoercibleRep b, Rep a ~ Rep b) => Coercion (MVector s a) (MVector s b)+mVectorCoercion = Coercion+{-# INLINE mVectorCoercion #-}+ toUnboxedMVector :: (Unboxable a, Rep a ~ a, IsTrivial a ~ 'True) => MVector s a -> UM.MVector s a toUnboxedMVector = coerce {-# INLINE toUnboxedMVector #-}@@ -326,155 +339,6 @@   {-# INLINE elemseq #-}  ----- Classes from mono-traversable-----type instance Data.MonoTraversable.Element (Vector a) = a--instance (Unboxable a) => Data.MonoTraversable.MonoFunctor (Vector a) where-  omap = G.map-  {-# INLINE omap #-}--instance (Unboxable a) => Data.MonoTraversable.MonoFoldable (Vector a) where-  ofoldMap f = G.foldr (mappend . f) mempty-  ofoldr = G.foldr-  ofoldl' = G.foldl'-  otoList = G.toList-  oall = G.all-  oany = G.any-  onull = G.null-  olength = G.length-  olength64 = fromIntegral . G.length-  -- ocompareLength : use default-  -- otraverse_ : use default-  -- ofor_ : use default-  -- omapM_ : use default (G.mapM_ requires a Monad, unfortunately)-  -- oforM_ : use default (G.forM_ requires a Monad, unfortunately)-  ofoldlM = G.foldM-  -- ofoldMap1Ex : use default-  ofoldr1Ex = G.foldr1-  ofoldl1Ex' = G.foldl1'-  headEx = G.head-  lastEx = G.last-  unsafeHead = G.unsafeHead-  unsafeLast = G.unsafeLast-  maximumByEx = G.maximumBy-  minimumByEx = G.minimumBy-  oelem = G.elem-  onotElem = G.notElem-  {-# INLINE ofoldMap #-}-  {-# INLINE ofoldr #-}-  {-# INLINE ofoldl' #-}-  {-# INLINE otoList #-}-  {-# INLINE oall #-}-  {-# INLINE oany #-}-  {-# INLINE onull #-}-  {-# INLINE olength #-}-  {-# INLINE olength64 #-}-  {-# INLINE ofoldlM #-}-  {-# INLINE ofoldr1Ex #-}-  {-# INLINE ofoldl1Ex' #-}-  {-# INLINE headEx #-}-  {-# INLINE lastEx #-}-  {-# INLINE unsafeHead #-}-  {-# INLINE unsafeLast #-}-  {-# INLINE maximumByEx #-}-  {-# INLINE minimumByEx #-}-  {-# INLINE oelem #-}-  {-# INLINE onotElem #-}--instance (Unboxable a) => Data.MonoTraversable.MonoTraversable (Vector a) where-  otraverse f v = let !n = G.length v-                  in G.fromListN n <$> traverse f (G.toList v)-  omapM = Data.MonoTraversable.otraverse-  {-# INLINE otraverse #-}-  {-# INLINE omapM #-}--instance (Unboxable a) => Data.MonoTraversable.MonoPointed (Vector a) where-  opoint = G.singleton-  {-# INLINE opoint #-}--instance (Unboxable a) => Data.MonoTraversable.GrowingAppend (Vector a)--instance (Unboxable a) => Data.Sequences.SemiSequence (Vector a) where-  type Index (Vector a) = Int-  intersperse = Data.Sequences.defaultIntersperse-  reverse = G.reverse-  find = G.find-  sortBy = Data.Sequences.vectorSortBy-  cons = G.cons-  snoc = G.snoc-  {-# INLINE intersperse #-}-  {-# INLINE reverse #-}-  {-# INLINE find #-}-  {-# INLINE sortBy #-}-  {-# INLINE cons #-}-  {-# INLINE snoc #-}--instance (Unboxable a) => Data.Sequences.IsSequence (Vector a) where-  fromList = G.fromList-  lengthIndex = G.length-  break = G.break-  span = G.span-  dropWhile = G.dropWhile-  takeWhile = G.takeWhile-  splitAt = G.splitAt-  -- unsafeSplitAt : use default-  take = G.take-  unsafeTake = G.unsafeTake-  drop = G.drop-  unsafeDrop = G.unsafeDrop-  -- dropEnd : use default-  partition = G.partition-  uncons v | G.null v = Nothing-           | otherwise = Just (G.head v, G.tail v)-  unsnoc v | G.null v = Nothing-           | otherwise = Just (G.init v, G.last v)-  filter = G.filter-  filterM = G.filterM-  replicate = G.replicate-  replicateM = G.replicateM-  -- groupBy : use default-  -- groupAllOn : use default-  -- subsequences : use default-  -- permutations : use default-  tailEx = G.tail-  -- tailMay : use default-  initEx = G.init-  -- initMay : use default-  unsafeTail = G.unsafeTail-  unsafeInit = G.unsafeInit-  index = (G.!?)-  indexEx = (G.!)-  unsafeIndex = G.unsafeIndex-  -- splitWhen : use default-  {-# INLINE fromList #-}-  {-# INLINE lengthIndex #-}-  {-# INLINE break #-}-  {-# INLINE span #-}-  {-# INLINE dropWhile #-}-  {-# INLINE takeWhile #-}-  {-# INLINE splitAt #-}-  {-# INLINE take #-}-  {-# INLINE unsafeTake #-}-  {-# INLINE drop #-}-  {-# INLINE unsafeDrop #-}-  {-# INLINE partition #-}-  {-# INLINE uncons #-}-  {-# INLINE unsnoc #-}-  {-# INLINE filter #-}-  {-# INLINE filterM #-}-  {-# INLINE replicate #-}-  {-# INLINE replicateM #-}-  {-# INLINE tailEx #-}-  {-# INLINE initEx #-}-  {-# INLINE unsafeTail #-}-  {-# INLINE unsafeInit #-}-  {-# INLINE index #-}-  {-# INLINE indexEx #-}-  {-# INLINE unsafeIndex #-}---- -- Unboxable instances -- @@ -569,57 +433,57 @@  instance Unboxable a => Unboxable (Data.Functor.Identity.Identity a) where   type Rep (Data.Functor.Identity.Identity a) = Rep a-  unboxingFrom = coerce (unboxingFrom @a)-  unboxingTo = coerce (unboxingTo @a)+  unboxingFrom = unboxingFrom .# Data.Functor.Identity.runIdentity+  unboxingTo = Data.Functor.Identity.Identity #. unboxingTo   {-# INLINE unboxingFrom #-}   {-# INLINE unboxingTo #-}  instance Unboxable a => Unboxable (Data.Functor.Const.Const a b) where   type Rep (Data.Functor.Const.Const a b) = Rep a-  unboxingFrom = coerce (unboxingFrom @a)-  unboxingTo = coerce (unboxingTo @a)+  unboxingFrom = unboxingFrom .# Data.Functor.Const.getConst+  unboxingTo = Data.Functor.Const.Const #. unboxingTo   {-# INLINE unboxingFrom #-}   {-# INLINE unboxingTo #-}  instance Unboxable a => Unboxable (Data.Semigroup.Min a) where   type Rep (Data.Semigroup.Min a) = Rep a-  unboxingFrom = coerce (unboxingFrom @a)-  unboxingTo = coerce (unboxingTo @a)+  unboxingFrom = unboxingFrom .# Data.Semigroup.getMin+  unboxingTo = Data.Semigroup.Min #. unboxingTo   {-# INLINE unboxingFrom #-}   {-# INLINE unboxingTo #-}  instance Unboxable a => Unboxable (Data.Semigroup.Max a) where   type Rep (Data.Semigroup.Max a) = Rep a-  unboxingFrom = coerce (unboxingFrom @a)-  unboxingTo = coerce (unboxingTo @a)+  unboxingFrom = unboxingFrom .# Data.Semigroup.getMax+  unboxingTo = Data.Semigroup.Max #. unboxingTo   {-# INLINE unboxingFrom #-}   {-# INLINE unboxingTo #-}  instance Unboxable a => Unboxable (Data.Semigroup.First a) where   type Rep (Data.Semigroup.First a) = Rep a-  unboxingFrom = coerce (unboxingFrom @a)-  unboxingTo = coerce (unboxingTo @a)+  unboxingFrom = unboxingFrom .# Data.Semigroup.getFirst+  unboxingTo = Data.Semigroup.First #. unboxingTo   {-# INLINE unboxingFrom #-}   {-# INLINE unboxingTo #-}  instance Unboxable a => Unboxable (Data.Semigroup.Last a) where   type Rep (Data.Semigroup.Last a) = Rep a-  unboxingFrom = coerce (unboxingFrom @a)-  unboxingTo = coerce (unboxingTo @a)+  unboxingFrom = unboxingFrom .# Data.Semigroup.getLast+  unboxingTo = Data.Semigroup.Last #. unboxingTo   {-# INLINE unboxingFrom #-}   {-# INLINE unboxingTo #-}  instance Unboxable a => Unboxable (Data.Semigroup.WrappedMonoid a) where   type Rep (Data.Semigroup.WrappedMonoid a) = Rep a-  unboxingFrom = coerce (unboxingFrom @a)-  unboxingTo = coerce (unboxingTo @a)+  unboxingFrom = unboxingFrom .# Data.Semigroup.unwrapMonoid+  unboxingTo = Data.Semigroup.WrapMonoid #. unboxingTo   {-# INLINE unboxingFrom #-}   {-# INLINE unboxingTo #-}  instance Unboxable a => Unboxable (Data.Monoid.Dual a) where   type Rep (Data.Monoid.Dual a) = Rep a-  unboxingFrom = coerce (unboxingFrom @a)-  unboxingTo = coerce (unboxingTo @a)+  unboxingFrom = unboxingFrom .# Data.Monoid.getDual+  unboxingTo = Data.Monoid.Dual #. unboxingTo   {-# INLINE unboxingFrom #-}   {-# INLINE unboxingTo #-} @@ -631,22 +495,22 @@  instance Unboxable a => Unboxable (Data.Monoid.Sum a) where   type Rep (Data.Monoid.Sum a) = Rep a-  unboxingFrom = coerce (unboxingFrom @a)-  unboxingTo = coerce (unboxingTo @a)+  unboxingFrom = unboxingFrom .# Data.Monoid.getSum+  unboxingTo = Data.Monoid.Sum #. unboxingTo   {-# INLINE unboxingFrom #-}   {-# INLINE unboxingTo #-}  instance Unboxable a => Unboxable (Data.Monoid.Product a) where   type Rep (Data.Monoid.Product a) = Rep a-  unboxingFrom = coerce (unboxingFrom @a)-  unboxingTo = coerce (unboxingTo @a)+  unboxingFrom = unboxingFrom .# Data.Monoid.getProduct+  unboxingTo = Data.Monoid.Product #. unboxingTo   {-# INLINE unboxingFrom #-}   {-# INLINE unboxingTo #-}  instance Unboxable a => Unboxable (Data.Ord.Down a) where   type Rep (Data.Ord.Down a) = Rep a-  unboxingFrom = coerce (unboxingFrom @a)-  unboxingTo = coerce (unboxingTo @a)+  unboxingFrom = unboxingFrom .# (\(Data.Ord.Down x) -> x)+  unboxingTo = Data.Ord.Down #. unboxingTo   {-# INLINE unboxingFrom #-}   {-# INLINE unboxingTo #-} @@ -656,3 +520,45 @@   unboxingTo y = toEnum (fromIntegral y)   {-# INLINE unboxingFrom #-}   {-# INLINE unboxingTo #-}++instance (Unboxable a, Unboxable b) => Unboxable (Data.Semigroup.Arg a b) where+  type Rep (Data.Semigroup.Arg a b) = (Rep a, Rep b)+  unboxingFrom (Data.Semigroup.Arg x y) = (unboxingFrom x, unboxingFrom y)+  unboxingTo (x, y) = Data.Semigroup.Arg (unboxingTo x) (unboxingTo y)+  {-# INLINE unboxingFrom #-}+  {-# INLINE unboxingTo #-}++instance Unboxable (f a) => Unboxable (Data.Monoid.Alt f a) where+  type Rep (Data.Monoid.Alt f a) = Rep (f a)+  unboxingFrom = unboxingFrom .# Data.Monoid.getAlt+  unboxingTo = Data.Monoid.Alt #. unboxingTo+  {-# INLINE unboxingFrom #-}+  {-# INLINE unboxingTo #-}++{-+-- Since base-4.12.0.0+instance Unboxable (f a) => Unboxable (Data.Monoid.Ap f a) where+  type Rep (Data.Monoid.Ap f a) = Rep (f a)+  unboxingFrom = unboxingFrom .# Data.Monoid.getAp+  unboxingTo = Data.Monoid.Ap #. unboxingTo+  {-# INLINE unboxingFrom #-}+  {-# INLINE unboxingTo #-}+-}++instance Unboxable (f (g a)) => Unboxable (Data.Functor.Compose.Compose f g a) where+  type Rep (Data.Functor.Compose.Compose f g a) = Rep (f (g a))+  unboxingFrom = unboxingFrom .# Data.Functor.Compose.getCompose+  unboxingTo = Data.Functor.Compose.Compose #. unboxingTo+  {-# INLINE unboxingFrom #-}+  {-# INLINE unboxingTo #-}++infixr 9 #.+infixl 8 .#++(#.) :: Coercible b c => (b -> c) -> (a -> b) -> a -> c+_ #. f = coerce f+{-# INLINE (#.) #-}++(.#) :: Coercible a b => (b -> c) -> (a -> b) -> a -> c+f .# _ = coerce f+{-# INLINE (.#) #-}
src/Data/Vector/Unboxing/Mutable.hs view
@@ -30,14 +30,19 @@   -- ** Filling and copying   ,set,copy,move,unsafeCopy,unsafeMove   -- * Conversions from/to other vector types+  ,coerceMVector+  ,liftCoercionM+  ,mVectorCoercion   ,toUnboxedMVector   ,fromUnboxedMVector+  ,coercionWithUnboxedMVector   ) where  import Prelude (Int,Bool,Ord) import qualified Data.Vector.Generic.Mutable as G import qualified Data.Vector.Unboxed.Mutable as UM import Data.Vector.Unboxing.Internal+import Data.Vector.Unboxing.Instances () import Control.Monad.ST import Control.Monad.Primitive (PrimMonad,PrimState) import Data.Coerce
test-gnd/Spec.hs view
@@ -1,13 +1,23 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE UndecidableInstances #-} import Prelude import Test.HUnit+import qualified Data.Vector.Generic as G import qualified Data.Vector.Unboxing as V import Data.Monoid (Sum(..))+#if defined(ENABLE_MONO_TRAVERSABLE) import Data.MonoTraversable (ofold)+#endif --- import Foo (Foo,mkFoo)++#if !defined(ENABLE_MONO_TRAVERSABLE)+-- Ad-hoc definition+ofold :: (Monoid a, G.Vector v a) => v a -> a+ofold = mconcat . G.toList+#endif  newtype IntMod17 = IntMod17 Int   deriving (Eq,Show)
test/Spec.hs view
@@ -1,16 +1,26 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE UndecidableInstances #-} import Prelude import Test.HUnit+import qualified Data.Vector.Generic as G import qualified Data.Vector.Unboxing as V import qualified Data.Vector.Unboxed import Data.Monoid (Sum(..))+#if defined(ENABLE_MONO_TRAVERSABLE) import Data.MonoTraversable (ofold)+#endif --- import TestTypeErrors import Foo (Foo,mkFoo)++#if !defined(ENABLE_MONO_TRAVERSABLE)+-- Ad-hoc definition+ofold :: (Monoid a, G.Vector v a) => v a -> a+ofold = mconcat . G.toList+#endif  testInt = TestCase $ do   let v = V.fromList [2,-5,42] :: V.Vector Int
unboxing-vector.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.31.2.+-- This file has been generated from package.yaml by hpack version 0.33.0. -- -- see: https://github.com/sol/hpack ----- hash: 8fec698d5a4391032074d2a71e767bc6f667b179e962ed429de29ca13c44b918+-- hash: aab8ac481656db609980811ae840b2e93bd1beb65b3da7423f6086ef13d529ea  name:           unboxing-vector-version:        0.1.1.0+version:        0.2.0.0 synopsis:       A newtype-friendly variant of unboxed vectors description:    Please see the README on GitHub at <https://github.com/minoki/unboxing-vector#readme> category:       Data, Data Structures@@ -15,7 +15,7 @@ bug-reports:    https://github.com/minoki/unboxing-vector/issues author:         ARATA Mizuki <minorinoki@gmail.com> maintainer:     ARATA Mizuki <minorinoki@gmail.com>-copyright:      2019 ARATA Mizuki+copyright:      2020 ARATA Mizuki license:        BSD3 license-file:   LICENSE build-type:     Simple@@ -27,21 +27,30 @@   type: git   location: https://github.com/minoki/unboxing-vector +flag mono-traversable+  description: Define instances for MonoTraversable+  manual: True+  default: True+ library   exposed-modules:       Data.Vector.Unboxing       Data.Vector.Unboxing.Mutable   other-modules:       Data.Vector.Unboxing.Internal+      Data.Vector.Unboxing.Instances   hs-source-dirs:       src   ghc-options: -Wall   build-depends:       base >=4.9 && <5     , deepseq-    , mono-traversable     , primitive     , vector+  if flag(mono-traversable)+    cpp-options: -DENABLE_MONO_TRAVERSABLE+    build-depends:+        mono-traversable   default-language: Haskell2010  test-suite unboxing-vector-test@@ -59,11 +68,14 @@       HUnit     , base >=4.9 && <5     , deepseq-    , mono-traversable     , primitive     , should-not-typecheck     , unboxing-vector     , vector+  if flag(mono-traversable)+    cpp-options: -DENABLE_MONO_TRAVERSABLE+    build-depends:+        mono-traversable   default-language: Haskell2010  test-suite unboxing-vector-test-deriving-via@@ -82,11 +94,14 @@       HUnit     , base >=4.9 && <5     , deepseq-    , mono-traversable     , primitive     , should-not-typecheck     , unboxing-vector     , vector+  if flag(mono-traversable)+    cpp-options: -DENABLE_MONO_TRAVERSABLE+    build-depends:+        mono-traversable   if impl(ghc >= 8.6.1)     buildable: True   else@@ -106,10 +121,13 @@       HUnit     , base >=4.9 && <5     , deepseq-    , mono-traversable     , primitive     , unboxing-vector     , vector+  if flag(mono-traversable)+    cpp-options: -DENABLE_MONO_TRAVERSABLE+    build-depends:+        mono-traversable   if impl(ghc >= 8.2.1)     buildable: True   else@@ -128,8 +146,15 @@   build-depends:       base >=4.9 && <5     , deepseq-    , mono-traversable     , primitive     , unboxing-vector     , vector+  if flag(mono-traversable)+    cpp-options: -DENABLE_MONO_TRAVERSABLE+    build-depends:+        mono-traversable+  if impl(ghc >= 8.2.1)+    buildable: True+  else+    buildable: False   default-language: Haskell2010