diff options
author | Joris | 2015-08-30 21:17:27 +0200 |
---|---|---|
committer | Joris | 2015-08-30 21:17:27 +0200 |
commit | c4eb771fa09e3972106d80ada6b3c4a023b85249 (patch) | |
tree | 9214b64628e34089b73ff6b4bdcb0edbc668a51e /src/CSV.hs |
Fetch perfumes according to multiple materials
Diffstat (limited to 'src/CSV.hs')
-rw-r--r-- | src/CSV.hs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/CSV.hs b/src/CSV.hs new file mode 100644 index 0000000..80c6d76 --- /dev/null +++ b/src/CSV.hs @@ -0,0 +1,18 @@ +{-# 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 |