Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add FromRecord and ToRecord instances for unboxed Vectors

  • Loading branch information...
commit 5df38de609de054bdbaa73005c0d9e14ecf5ecc3 1 parent 19bc4ca
@tibbe authored
Showing with 7 additions and 0 deletions.
  1. +7 −0 Data/Csv/Conversion.hs
View
7 Data/Csv/Conversion.hs
@@ -44,6 +44,7 @@ import qualified Data.Text.Lazy.Encoding as LT
import Data.Traversable
import Data.Vector (Vector, (!))
import qualified Data.Vector as V
+import qualified Data.Vector.Unboxed as U
import Data.Word
import GHC.Float (double2Float)
import Prelude hiding (takeWhile)
@@ -256,6 +257,12 @@ instance FromField a => FromRecord (V.Vector a) where
instance ToField a => ToRecord (Vector a) where
toRecord = V.map toField
+instance (FromField a, U.Unbox a) => FromRecord (U.Vector a) where
+ parseRecord = fmap U.convert . traverse parseField
+
+instance (ToField a, U.Unbox a) => ToRecord (U.Vector a) where
+ toRecord = V.map toField . U.convert
+
------------------------------------------------------------------------
-- Name-based conversion
Please sign in to comment.
Something went wrong with that request. Please try again.