Haskell Learnings

From MonetDB
Jump to navigationJump to search

Data.Vector[edit]

  • Fast vectors, has things of Data.List like filter, foldl, zip, etc.
  • head, tail

Cassava (Data.Csv)[edit]

{-# LANGUAGE ScopedTypeVariables #-}

import qualified Data.ByteString.Lazy as BL
import Data.Csv
import qualified Data.Vector as V

main :: IO ()
main = do
    csvData <- BL.readFile "salaries.csv"
    case decode csvData of
        Left err -> putStrLn err
        Right v -> V.forM_ v $ \ (name, salary :: Int) ->
            putStrLn $ name ++ " earns " ++ show salary ++ " dollars"