From 9cb2d041ca41d0b39c8d0698cabd6d8919f9a601 Mon Sep 17 00:00:00 2001
From: Alice BRENON <alice.brenon@ens-lyon.fr>
Date: Thu, 28 Nov 2024 11:15:44 +0100
Subject: [PATCH] Prove that ReadTSV / WriteTSV classes bubble up through
 MonadTrans instances

---
 lib/GEODE/Metadata/TSV.hs | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/GEODE/Metadata/TSV.hs b/lib/GEODE/Metadata/TSV.hs
index 42e0796..54a1538 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
-- 
GitLab