{-# LANGUAGE OverloadedStrings #-} module CSV ( getCsv ) where import Data.Text (Text) import qualified Data.Text as T getCsv :: [[Text]] -> Text getCsv = T.intercalate "\n" . map (T.intercalate "," . map quote) quote :: Text -> Text quote text = T.concat [ "\"", T.concatMap escape text, "\"" ] escape :: Char -> Text escape '"' = "\"\"" escape x = T.singleton x