id	summary	reporter	owner	description	type	status	priority	milestone	version	resolution	keywords	cc
49	Read instances	choener		"Hi,

how about Read instances for the library? I like Read/Show a lot for serializing because it costs nothing (cost = my time spent programming that).

Do you want it in the vector library or do you prefer something like ""vector-read-instances""?
It is a vote because I already have the code for unboxed vectors written. ;-)


{{{
{-# LANGUAGE ScopedTypeVariables #-}

-- | Read instance for unboxed vectors.

module Data.Vector.Unboxed.Read where

import qualified Data.Vector.Unboxed as VU
import qualified Text.Read.Lex as L
import GHC.Show
import Text.Read
import Text.ParserCombinators.ReadP

instance (VU.Unbox a, Read a) => Read (VU.Vector a) where
  readPrec =
    parens $ do
        L.Ident ""fromList"" <- lexP
        (vals :: [a])  <- readPrec
        lift $ skipSpaces
        lift $ string ""::""
        lift $ skipSpaces
        lift $ string ""Data.Vector.Unboxed.Vector""
        return $ VU.fromList vals
  readListPrec = readListPrecDefault
  readList     = readListDefault
}}}
"	enhancement	closed	minor	0.8	0.7	fixed	Read instance	choener@…
