Skip to content
Snippets Groups Projects
Commit 63f82c9f authored by Alice Brenon's avatar Alice Brenon
Browse files

Factorise and expose TSV option decoder to client code

parent 5c766a5a
No related branches found
No related tags found
No related merge requests found
{-# LANGUAGE ScopedTypeVariables #-}
module GEODE.Metadata.TSV
( readNamedTsv
( fromTsv
, readNamedTsv
, readTsv
, toTsv
, tsvFile
......@@ -15,16 +16,15 @@ import Data.Foldable (toList)
import Data.Vector (Vector)
import GEODE.Metadata.TSV.Header (HasDefaultHeader, getHeader, for)
fromTsv :: DecodeOptions
fromTsv = DecodeOptions {decDelimiter = fromIntegral (fromEnum '\t')}
readNamedTsv :: FromNamedRecord a => FilePath -> IO (Either String (Vector a))
readNamedTsv source =
(fmap snd . decodeByNameWith fromTsv) <$> ByteString.readFile source
where
fromTsv = DecodeOptions {decDelimiter = fromIntegral (fromEnum '\t')}
readTsv :: FromRecord a => FilePath -> IO (Either String (Vector a))
readTsv source = decodeWith fromTsv NoHeader <$> ByteString.readFile source
where
fromTsv = DecodeOptions {decDelimiter = fromIntegral (fromEnum '\t')}
toTsv :: EncodeOptions
toTsv = defaultEncodeOptions
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment