Permalink
Browse files

Update examples

  • Loading branch information...
1 parent 5e40fa8 commit 1cee459540dff90f0db58e2b5a39720f7a7d8eb3 @tibbe committed Nov 17, 2012
Showing with 4 additions and 7 deletions.
  1. +1 −1 Data/Csv.hs
  2. +1 −4 examples/IncrementalIndexedBasedDecode.hs
  3. +1 −1 examples/IndexBasedDecode.hs
  4. +1 −1 examples/IndexBasedGeneric.hs
View
@@ -85,7 +85,7 @@ import Data.Csv.Types
--
-- A short decoding usage example:
--
--- @ >>> 'decode' \"John,27\\r\\nJane,28\\r\\n\" :: Either String (Vector (Text, Int))
+-- @ >>> 'decode' 'False' \"John,27\\r\\nJane,28\\r\\n\" :: Either String (Vector (Text, Int))
-- Right (fromList [(\"John\",27),(\"Jane\",28)])
-- @
@@ -19,9 +19,6 @@ main = withFile "salaries.csv" ReadMode $ \ csvFile -> do
if isEof
then return $ k B.empty
else k `fmap` B.hGetSome csvFile 4096
- isEof <- hIsEOF csvFile
- unless isEof $ do
- bytes <- B.hGetSome csvFile 4096
- loop 0 (decode False bytes)
+ loop 0 (decode False)
where
sumSalaries rs = sum [salary | Right (_ :: String, salary :: Int) <- rs]
@@ -7,7 +7,7 @@ import qualified Data.Vector as V
main :: IO ()
main = do
csvData <- BL.readFile "salaries.csv"
- case decode csvData of
+ case decode False csvData of
Left err -> putStrLn err
Right v -> V.forM_ v $ \ (name, salary :: Int) ->
putStrLn $ name ++ " earns " ++ show salary ++ " dollars"
@@ -17,7 +17,7 @@ main :: IO ()
main = do
BL.writeFile "salaries.csv" $ encode (V.fromList persons)
csvData <- BL.readFile "salaries.csv"
- case decode csvData of
+ case decode False csvData of
Left err -> putStrLn err
Right v -> V.forM_ v $ \ (Person name salary) ->
putStrLn $ name ++ " earns " ++ show salary ++ " dollars"

0 comments on commit 1cee459

Please sign in to comment.