diff --git a/lib/GEODE/Metadata/TSV.hs b/lib/GEODE/Metadata/TSV.hs index 42e07960deccdfe96da18585f41994deb756b024..54a1538383dbece622f52480f5dc7be7e5e1ecc0 100644 --- a/lib/GEODE/Metadata/TSV.hs +++ b/lib/GEODE/Metadata/TSV.hs @@ -7,6 +7,7 @@ module GEODE.Metadata.TSV , fromTSV , toTSV ) where +import Control.Monad.Trans (MonadTrans(..)) import Control.Monad.Except (ExceptT(..)) import Data.ByteString.Lazy as ByteString ( ByteString, getContents, putStr, readFile, writeFile ) @@ -95,6 +96,9 @@ instance FromNamedRecord a => ReadTSV () IO (Document a) where instance FromNamedRecord a => ReadTSV FilePath IO (Document a) where readTSV path = named <$> ByteString.readFile path >>= try +instance (Monad m, MonadTrans t, ReadTSV s m a) => ReadTSV s (t m) a where + readTSV = lift . readTSV + -- * Writing TSV data -- -- | A class type to represent processes which output TSV @@ -128,3 +132,6 @@ instance ToNamedRecord a => WriteTSV () IO (Document a) where instance ToNamedRecord a => WriteTSV FilePath IO (Document a) where writeTSV path (Document {header, rows}) = ByteString.writeFile path . encodeByNameWith toTSV header $ toList rows + +instance (Monad m, MonadTrans t, WriteTSV d m a) => WriteTSV d (t m) a where + writeTSV d = lift . writeTSV d