{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}

module System.FilePath.FilePather.ReadFilePaths (
  ReadFilePathsT
, ReadFilePaths
, ReadFilePathsT1
, ReadFilePaths1
, readFilePaths1
, readFilePaths
, swapReadFilePaths
, pureReadFilePaths
, liftReadFilePaths
, successReadFilePaths
, errorReadFilePaths
, maybeReadFilePaths
, tryReadFilePaths
) where

import Control.Applicative ( Applicative((<*>), pure) )
import Control.Category ( Category((.)) )
import Control.Exception ( try, Exception )
import Control.Lens
    ( view,
      iso,
      swapped,
      _Wrapped,
      Field1(_1),
      Iso,
      Rewrapped,
      Wrapped(..) )
import Control.Monad
    ( join, Monad(return, (>>=)) )
import Control.Monad.Cont.Class ( MonadCont(callCC) )
import Control.Monad.Error.Class ( MonadError(throwError, catchError) )
import Control.Monad.Fail ( MonadFail(fail) )
import Control.Monad.Fix ( MonadFix(mfix) )
import Control.Monad.IO.Class ( MonadIO(liftIO) )
import Control.Monad.Morph ( MFunctor(hoist), MMonad(embed) )
import Control.Monad.Reader.Class ( MonadReader(reader, local, ask) )
import Control.Monad.State.Class ( MonadState(state, get, put) )
import Control.Monad.Trans.Class(MonadTrans(lift))
import Control.Monad.Writer.Class ( MonadWriter(pass, tell, writer, listen) )
import Control.Monad.Zip ( MonadZip(mzipWith) )
import Data.Either ( Either(..), either )
import Data.Functor ( Functor(fmap) )
import Data.Functor.Alt ( Apply((<.>)), Alt((<!>)) )
import Data.Functor.Bind ( Bind((>>-)) )
import Data.Functor.Identity( Identity(..) )
import Data.Maybe ( Maybe, maybe )
import Data.Monoid ( Monoid(mempty, mappend) )
import Data.Semigroup ( Semigroup((<>)) )
import System.FilePath ( FilePath )
import System.FilePath.FilePather.ReadFilePath
    ( ReadFilePathT(..) )
import System.IO ( IO )

newtype ReadFilePathsT e f a =
  ReadFilePathsT ([FilePath] -> f (Either e a))

instance ReadFilePathsT e f a ~ t =>
  Rewrapped (ReadFilePathsT e' f' a') t

instance Wrapped (ReadFilePathsT e f a) where
  type Unwrapped (ReadFilePathsT e f a) =
    [FilePath]
    -> f (Either e a)
  _Wrapped' :: Iso' (ReadFilePathsT e f a) (Unwrapped (ReadFilePathsT e f a))
_Wrapped' =
    forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso (\(ReadFilePathsT [FilePath] -> f (Either e a)
x) -> [FilePath] -> f (Either e a)
x) forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT
  {-# INLINE _Wrapped' #-}

type ReadFilePaths e a =
  ReadFilePathsT e Identity a

type ReadFilePathsT1 e f =
  ReadFilePathsT e f ()

type ReadFilePaths1 e f =
  ReadFilePaths e ()

readFilePaths1 ::
  ReadFilePathsT e f a
  -> ReadFilePathT e f a
readFilePaths1 :: forall e (f :: * -> *) a.
ReadFilePathsT e f a -> ReadFilePathT e f a
readFilePaths1 ReadFilePathsT e f a
x =
  forall e (f :: * -> *) a.
(FilePath -> f (Either e a)) -> ReadFilePathT e f a
ReadFilePathT (forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall s t. Rewrapping s t => Iso s t (Unwrapped s) (Unwrapped t)
_Wrapped ReadFilePathsT e f a
x forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall (f :: * -> *) a. Applicative f => a -> f a
pure)
{-# INLINE readFilePaths1 #-}

readFilePaths ::
  Iso
    (ReadFilePaths e a)
    (ReadFilePaths e' a')
    ([FilePath] -> Either e a)
    ([FilePath] -> Either e' a')
readFilePaths :: forall e a e' a'.
Iso
  (ReadFilePaths e a)
  (ReadFilePaths e' a')
  ([FilePath] -> Either e a)
  ([FilePath] -> Either e' a')
readFilePaths =
  forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
    (\(ReadFilePathsT [FilePath] -> Identity (Either e a)
x) -> forall a. Identity a -> a
runIdentity forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [FilePath] -> Identity (Either e a)
x)
    (\[FilePath] -> Either e' a'
p -> forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT (forall a. a -> Identity a
Identity forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [FilePath] -> Either e' a'
p))
{-# INLINE readFilePaths #-}

swapReadFilePaths ::
  Functor f =>
  Iso
    (ReadFilePathsT e f a)
    (ReadFilePathsT e' f a')
    (ReadFilePathsT a f e)
    (ReadFilePathsT a' f e')
swapReadFilePaths :: forall (f :: * -> *) e a e' a'.
Functor f =>
Iso
  (ReadFilePathsT e f a)
  (ReadFilePathsT e' f a')
  (ReadFilePathsT a f e)
  (ReadFilePathsT a' f e')
swapReadFilePaths =
  forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
    (\ReadFilePathsT e f a
r -> forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall (p :: * -> * -> *) a b c d.
Swap p =>
Iso (p a b) (p c d) (p b a) (p d c)
swapped) forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall s t. Rewrapping s t => Iso s t (Unwrapped s) (Unwrapped t)
_Wrapped ReadFilePathsT e f a
r))
    (\ReadFilePathsT a' f e'
r -> forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall (p :: * -> * -> *) a b c d.
Swap p =>
Iso (p a b) (p c d) (p b a) (p d c)
swapped) forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall s t. Rewrapping s t => Iso s t (Unwrapped s) (Unwrapped t)
_Wrapped ReadFilePathsT a' f e'
r))
{-# INLINE swapReadFilePaths #-}

pureReadFilePaths ::
  Applicative f =>
  ReadFilePaths e a
  -> ReadFilePathsT e f a
pureReadFilePaths :: forall (f :: * -> *) e a.
Applicative f =>
ReadFilePaths e a -> ReadFilePathsT e f a
pureReadFilePaths =
  forall {k} (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist (forall (f :: * -> *) a. Applicative f => a -> f a
pure forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall a. Identity a -> a
runIdentity)
{-# INLINE pureReadFilePaths #-}

liftReadFilePaths ::
  Applicative f =>
  ([FilePath] -> a)
  -> ReadFilePathsT e f a
liftReadFilePaths :: forall (f :: * -> *) a e.
Applicative f =>
([FilePath] -> a) -> ReadFilePathsT e f a
liftReadFilePaths =
  forall (f :: * -> *) e a.
Applicative f =>
ReadFilePaths e a -> ReadFilePathsT e f a
pureReadFilePaths forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
reader
{-# INLINE liftReadFilePaths #-}

successReadFilePaths ::
  Functor f =>
  ([FilePath] -> f a)
  -> ReadFilePathsT e f a
successReadFilePaths :: forall (f :: * -> *) a e.
Functor f =>
([FilePath] -> f a) -> ReadFilePathsT e f a
successReadFilePaths [FilePath] -> f a
k =
  forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. b -> Either a b
Right forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [FilePath] -> f a
k)
{-# INLINE successReadFilePaths #-}

errorReadFilePaths ::
  Functor f =>
  ([FilePath] -> f e)
  -> ReadFilePathsT e f a
errorReadFilePaths :: forall (f :: * -> *) e a.
Functor f =>
([FilePath] -> f e) -> ReadFilePathsT e f a
errorReadFilePaths [FilePath] -> f e
k =
  forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. a -> Either a b
Left forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [FilePath] -> f e
k)
{-# INLINE errorReadFilePaths #-}

maybeReadFilePaths ::
  Functor f =>
  ([FilePath] -> f (Maybe a))
  -> ReadFilePathsT () f a
maybeReadFilePaths :: forall (f :: * -> *) a.
Functor f =>
([FilePath] -> f (Maybe a)) -> ReadFilePathsT () f a
maybeReadFilePaths [FilePath] -> f (Maybe a)
k =
  forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall b a. b -> (a -> b) -> Maybe a -> b
maybe (forall a b. a -> Either a b
Left ()) forall a b. b -> Either a b
Right) forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [FilePath] -> f (Maybe a)
k)
{-# INLINE maybeReadFilePaths #-}

tryReadFilePaths ::
  Exception e =>
  ([FilePath] -> IO a)
  -> ReadFilePathsT e IO a
tryReadFilePaths :: forall e a.
Exception e =>
([FilePath] -> IO a) -> ReadFilePathsT e IO a
tryReadFilePaths [FilePath] -> IO a
k =
  forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT (forall e a. Exception e => IO a -> IO (Either e a)
try forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [FilePath] -> IO a
k)
{-# INLINE tryReadFilePaths #-}

instance (Monad f, Semigroup a) => Semigroup (ReadFilePathsT e f a) where
  ReadFilePathsT [FilePath] -> f (Either e a)
x <> :: ReadFilePathsT e f a
-> ReadFilePathsT e f a -> ReadFilePathsT e f a
<> ReadFilePathsT [FilePath] -> f (Either e a)
y =
    forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT (\[FilePath]
p -> [FilePath] -> f (Either e a)
x [FilePath]
p forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (forall (f :: * -> *) a. Applicative f => a -> f a
pure forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall a b. a -> Either a b
Left) (\a
a -> forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (a
a forall a. Semigroup a => a -> a -> a
<>)) ([FilePath] -> f (Either e a)
y [FilePath]
p)))
  {-# INLINE (<>) #-}

instance (Monad f, Monoid a) => Monoid (ReadFilePathsT e f a) where
  mappend :: ReadFilePathsT e f a
-> ReadFilePathsT e f a -> ReadFilePathsT e f a
mappend =
    forall a. Semigroup a => a -> a -> a
(<>)
  {-# INLINE mappend #-}
  mempty :: ReadFilePathsT e f a
mempty =
    forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT (forall (f :: * -> *) a. Applicative f => a -> f a
pure (forall (f :: * -> *) a. Applicative f => a -> f a
pure (forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Monoid a => a
mempty)))
  {-# INLINE mempty #-}

instance Functor f => Functor (ReadFilePathsT e f) where
  fmap :: forall a b.
(a -> b) -> ReadFilePathsT e f a -> ReadFilePathsT e f b
fmap a -> b
f (ReadFilePathsT [FilePath] -> f (Either e a)
x) =
    forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f)) [FilePath] -> f (Either e a)
x)
  {-# INLINE fmap #-}

instance Monad f => Apply (ReadFilePathsT e f) where
  ReadFilePathsT [FilePath] -> f (Either e (a -> b))
f <.> :: forall a b.
ReadFilePathsT e f (a -> b)
-> ReadFilePathsT e f a -> ReadFilePathsT e f b
<.> ReadFilePathsT [FilePath] -> f (Either e a)
k =
    forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT (\[FilePath]
p -> [FilePath] -> f (Either e (a -> b))
f [FilePath]
p forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (forall (f :: * -> *) a. Applicative f => a -> f a
pure forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall a b. a -> Either a b
Left) (\a -> b
a -> forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
a) ([FilePath] -> f (Either e a)
k [FilePath]
p)))
  {-# INLINE (<.>) #-}

instance Monad f => Bind (ReadFilePathsT e f) where
  ReadFilePathsT [FilePath] -> f (Either e a)
f >>- :: forall a b.
ReadFilePathsT e f a
-> (a -> ReadFilePathsT e f b) -> ReadFilePathsT e f b
>>- a -> ReadFilePathsT e f b
g =
    forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT (\[FilePath]
p -> [FilePath] -> f (Either e a)
f [FilePath]
p forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (forall (f :: * -> *) a. Applicative f => a -> f a
pure forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall a b. a -> Either a b
Left) (\a
a -> forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall s t. Rewrapping s t => Iso s t (Unwrapped s) (Unwrapped t)
_Wrapped (a -> ReadFilePathsT e f b
g a
a) [FilePath]
p))
  {-# INLINE (>>-) #-}

instance Monad f => Applicative (ReadFilePathsT e f) where
  <*> :: forall a b.
ReadFilePathsT e f (a -> b)
-> ReadFilePathsT e f a -> ReadFilePathsT e f b
(<*>) =
    forall (f :: * -> *) a b. Apply f => f (a -> b) -> f a -> f b
(<.>)
  pure :: forall a. a -> ReadFilePathsT e f a
pure =
    forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall (f :: * -> *) a. Applicative f => a -> f a
pure forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall (f :: * -> *) a. Applicative f => a -> f a
pure forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall (f :: * -> *) a. Applicative f => a -> f a
pure

instance Monad f => Alt (ReadFilePathsT e f) where
  ReadFilePathsT [FilePath] -> f (Either e a)
a <!> :: forall a.
ReadFilePathsT e f a
-> ReadFilePathsT e f a -> ReadFilePathsT e f a
<!> ReadFilePathsT [FilePath] -> f (Either e a)
b =
    forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT (\[FilePath]
p -> [FilePath] -> f (Either e a)
a [FilePath]
p forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (forall (f :: * -> *) a. Applicative f => a -> f a
pure ([FilePath] -> f (Either e a)
b [FilePath]
p)) (forall (f :: * -> *) a. Applicative f => a -> f a
pure forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall (f :: * -> *) a. Applicative f => a -> f a
pure))
  {-# INLINE (<!>) #-}

instance Monad f => Monad (ReadFilePathsT e f) where
  >>= :: forall a b.
ReadFilePathsT e f a
-> (a -> ReadFilePathsT e f b) -> ReadFilePathsT e f b
(>>=) =
    forall (m :: * -> *) a b. Bind m => m a -> (a -> m b) -> m b
(>>-)
  {-# INLINE (>>=) #-}
  return :: forall a. a -> ReadFilePathsT e f a
return =
    forall (f :: * -> *) a. Applicative f => a -> f a
pure
  {-# INLINE return #-}

instance MonadTrans (ReadFilePathsT e) where
  lift :: forall (m :: * -> *) a. Monad m => m a -> ReadFilePathsT e m a
lift =
    forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall (f :: * -> *) a. Applicative f => a -> f a
pure forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (f :: * -> *) a. Applicative f => a -> f a
pure
  {-# INLINE lift #-}

instance MonadIO f => MonadIO (ReadFilePathsT e f) where
  liftIO :: forall a. IO a -> ReadFilePathsT e f a
liftIO =
    forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall (f :: * -> *) a. Applicative f => a -> f a
pure forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (f :: * -> *) a. Applicative f => a -> f a
pure
  {-# INLINE liftIO #-}

instance MFunctor (ReadFilePathsT e) where
  hoist :: forall (m :: * -> *) (n :: * -> *) b.
Monad m =>
(forall a. m a -> n a)
-> ReadFilePathsT e m b -> ReadFilePathsT e n b
hoist forall a. m a -> n a
k (ReadFilePathsT [FilePath] -> m (Either e b)
f) =
    forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT (forall a. m a -> n a
k forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
.[FilePath] -> m (Either e b)
f)
  {-# INLINE hoist #-}

instance MMonad (ReadFilePathsT e) where
  embed :: forall (n :: * -> *) (m :: * -> *) b.
Monad n =>
(forall a. m a -> ReadFilePathsT e n a)
-> ReadFilePathsT e m b -> ReadFilePathsT e n b
embed forall a. m a -> ReadFilePathsT e n a
k (ReadFilePathsT [FilePath] -> m (Either e b)
f) =
    forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT (\[FilePath]
p -> forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (m :: * -> *) a. Monad m => m (m a) -> m a
join (forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall s t. Rewrapping s t => Iso s t (Unwrapped s) (Unwrapped t)
_Wrapped (forall a. m a -> ReadFilePathsT e n a
k ([FilePath] -> m (Either e b)
f [FilePath]
p)) [FilePath]
p))
  {-# INLINE embed #-}

instance Monad f => MonadReader [FilePath] (ReadFilePathsT e f) where
  ask :: ReadFilePathsT e f [FilePath]
ask =
    forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT (forall (f :: * -> *) a. Applicative f => a -> f a
pure forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall (f :: * -> *) a. Applicative f => a -> f a
pure)
  {-# INLINE ask #-}
  local :: forall a.
([FilePath] -> [FilePath])
-> ReadFilePathsT e f a -> ReadFilePathsT e f a
local [FilePath] -> [FilePath]
k (ReadFilePathsT [FilePath] -> f (Either e a)
f) =
    forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT ([FilePath] -> f (Either e a)
f forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [FilePath] -> [FilePath]
k)
  {-# INLINE local #-}
  reader :: forall a. ([FilePath] -> a) -> ReadFilePathsT e f a
reader [FilePath] -> a
k =
    forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT (forall (f :: * -> *) a. Applicative f => a -> f a
pure forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall (f :: * -> *) a. Applicative f => a -> f a
pure forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [FilePath] -> a
k)
  {-# INLINE reader #-}

instance MonadState [FilePath] f => MonadState [FilePath] (ReadFilePathsT e f) where
  state :: forall a. ([FilePath] -> (a, [FilePath])) -> ReadFilePathsT e f a
state =
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall s (m :: * -> *) a. MonadState s m => (s -> (a, s)) -> m a
state
  {-# INLINE state #-}
  get :: ReadFilePathsT e f [FilePath]
get =
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall s (m :: * -> *). MonadState s m => m s
get
  {-# INLINE get #-}
  put :: [FilePath] -> ReadFilePathsT e f ()
put =
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall s (m :: * -> *). MonadState s m => s -> m ()
put
  {-# INLINE put #-}

instance MonadWriter [FilePath] f => MonadWriter [FilePath] (ReadFilePathsT e f) where
  writer :: forall a. (a, [FilePath]) -> ReadFilePathsT e f a
writer =
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall w (m :: * -> *) a. MonadWriter w m => (a, w) -> m a
writer
  {-# INLINE writer #-}
  tell :: [FilePath] -> ReadFilePathsT e f ()
tell =
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell
  {-# INLINE tell #-}
  listen :: forall a.
ReadFilePathsT e f a -> ReadFilePathsT e f (a, [FilePath])
listen (ReadFilePathsT [FilePath] -> f (Either e a)
f) =
    forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT (\[FilePath]
p -> forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\a
a -> (a
a, [FilePath]
p))) ([FilePath] -> f (Either e a)
f [FilePath]
p))
  {-# INLINE listen #-}
  pass :: forall a.
ReadFilePathsT e f (a, [FilePath] -> [FilePath])
-> ReadFilePathsT e f a
pass (ReadFilePathsT [FilePath] -> f (Either e (a, [FilePath] -> [FilePath]))
f) =
    forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall s t a b. Field1 s t a b => Lens s t a b
_1)) forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [FilePath] -> f (Either e (a, [FilePath] -> [FilePath]))
f)
  {-# INLINE pass #-}

instance MonadFail f => MonadFail (ReadFilePathsT e f) where
  fail :: forall a. FilePath -> ReadFilePathsT e f a
fail =
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall (m :: * -> *) a. MonadFail m => FilePath -> m a
fail
  {-# INLINE fail #-}

instance MonadFix f => MonadFix (ReadFilePathsT e f) where
  mfix :: forall a. (a -> ReadFilePathsT e f a) -> ReadFilePathsT e f a
mfix a -> ReadFilePathsT e f a
f =
    forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT (\[FilePath]
p -> forall (m :: * -> *) a. MonadFix m => (a -> m a) -> m a
mfix (forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (forall (f :: * -> *) a. Applicative f => a -> f a
pure forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall a b. a -> Either a b
Left) (\a
a -> forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall s t. Rewrapping s t => Iso s t (Unwrapped s) (Unwrapped t)
_Wrapped (a -> ReadFilePathsT e f a
f a
a) [FilePath]
p)))
  {-# INLINE mfix #-}

instance MonadZip f => MonadZip (ReadFilePathsT e f) where
  mzipWith :: forall a b c.
(a -> b -> c)
-> ReadFilePathsT e f a
-> ReadFilePathsT e f b
-> ReadFilePathsT e f c
mzipWith a -> b -> c
f (ReadFilePathsT [FilePath] -> f (Either e a)
m) (ReadFilePathsT [FilePath] -> f (Either e b)
n) =
    forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT (\[FilePath]
p -> [FilePath] -> f (Either e a)
m [FilePath]
p forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (forall (f :: * -> *) a. Applicative f => a -> f a
pure forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall a b. a -> Either a b
Left) (\a
a -> forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (a -> b -> c
f a
a)) ([FilePath] -> f (Either e b)
n [FilePath]
p)))
  {-# INLINE mzipWith #-}

instance MonadCont f => MonadCont (ReadFilePathsT e f) where
  callCC :: forall a b.
((a -> ReadFilePathsT e f b) -> ReadFilePathsT e f a)
-> ReadFilePathsT e f a
callCC (a -> ReadFilePathsT e f b) -> ReadFilePathsT e f a
p =
    forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT (\[FilePath]
r -> forall (m :: * -> *) a b. MonadCont m => ((a -> m b) -> m a) -> m a
callCC (\Either e a -> f (Either e b)
c -> forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall s t. Rewrapping s t => Iso s t (Unwrapped s) (Unwrapped t)
_Wrapped ((a -> ReadFilePathsT e f b) -> ReadFilePathsT e f a
p (forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall (f :: * -> *) a. Applicative f => a -> f a
pure forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Either e a -> f (Either e b)
c forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall (f :: * -> *) a. Applicative f => a -> f a
pure)) [FilePath]
r))
  {-# INLINE callCC #-}

instance MonadError e f => MonadError e (ReadFilePathsT e f) where
  throwError :: forall a. e -> ReadFilePathsT e f a
throwError =
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError
  {-# INLINE throwError #-}
  catchError :: forall a.
ReadFilePathsT e f a
-> (e -> ReadFilePathsT e f a) -> ReadFilePathsT e f a
catchError (ReadFilePathsT [FilePath] -> f (Either e a)
f) e -> ReadFilePathsT e f a
g =
    forall e (f :: * -> *) a.
([FilePath] -> f (Either e a)) -> ReadFilePathsT e f a
ReadFilePathsT (\ [FilePath]
r -> forall e (m :: * -> *) a.
MonadError e m =>
m a -> (e -> m a) -> m a
catchError ([FilePath] -> f (Either e a)
f [FilePath]
r) (\ e
e -> forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view forall s t. Rewrapping s t => Iso s t (Unwrapped s) (Unwrapped t)
_Wrapped (e -> ReadFilePathsT e f a
g e
e) [FilePath]
r))
  {-# INLINE catchError #-}