@@ -6,7 +6,6 @@ module FileSizes where
66import Control.Exception
77import Control.Monad.IO.Class
88import Data.IORef
9−import Data.Tuple
109import System.Posix
1110
1211-- effectful
@@ -27,8 +26,10 @@ import qualified Control.Monad.Freer.State as FS
2726#endif
2827
2928-- mtl
29+#ifdef VERSION_mtl
3030import qualified Control.Monad.State as M
3131import qualified Control.Monad.Reader as M
32+#endif
3233
3334-- polysemy
3435#ifdef VERSION_polysemy
@@ -155,10 +156,13 @@ eff_runLogging
155156 :: L.Eff (Eff_Logging : es) a
156157 -> L.Eff es (a, [String])
157158eff_runLogging
158− = fmap swap . L.runState [] . L.interpret \case
159+ = fmap eff_swap . L.runState [] . L.interpret \case
159160 Eff_logMsg msg -> L.modify (msg :)
160161 . L.lift
161162
163+eff_swap :: (a, b) -> (b, a)
164+eff_swap (x, y) = (y, x)
165+
162166----------
163167
164168eff_calculateFileSize
@@ -263,6 +267,8 @@ fs_calculateFileSizesDeep = FS.runM
263267----------------------------------------
264268-- mtl
265269
270+#ifdef VERSION_mtl
271+
266272class Monad m => MonadFile m where
267273 mtl_tryFileSize :: FilePath -> m (Maybe Int)
268274
@@ -329,6 +335,8 @@ mtl_calculateFileSizesDeep
329335 where
330336 runR = flip M.runReaderT ()
331337
338+#endif
339+
332340----------------------------------------
333341-- polysemy
334342
@@ -351,9 +359,12 @@ poly_logMsg :: P.Member Poly_Logging es => String -> P.Sem es ()
351359poly_logMsg = P.send . Poly_logMsg
352360
353361poly_runLogging :: P.Sem (Poly_Logging : es) a -> P.Sem es (a, [String])
354−poly_runLogging = fmap swap . P.runState [] . P.reinterpret \case
362+poly_runLogging = fmap poly_swap . P.runState [] . P.reinterpret \case
355363 Poly_logMsg msg -> P.modify (msg :)
356364
365+poly_swap :: (a, b) -> (b, a)
366+poly_swap (x, y) = (y, x)
367+
357368----------
358369
359370poly_calculateFileSize