Ticket #49 (closed enhancement: fixed)
Read instances
| Reported by: | choener | Owned by: | |
|---|---|---|---|
| Priority: | minor | Milestone: | 0.8 |
| Version: | 0.7 | Keywords: | Read instance |
| Cc: | choener@… |
Description
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
Change History
Note: See
TracTickets for help on using
tickets.
