{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE NoImplicitPrelude #-}

module System.FilePath.FilePather.Compose(
  composeToRead
, (->>-)
, composeReadTo
, (-<<-)
) where

import Control.Lens ( view, Wrapped(_Wrapped') )
import Data.Functor.Bind ( (-<-), (->-), Bind )
import System.FilePath.FilePather.ReadFilePath
    ( ReadFilePathT(..) )
import System.FilePath.FilePather.ToFilePath ( ToFilePathT(..) )

composeToRead ::
  Bind f =>
  ToFilePathT f a
  -> ReadFilePathT f b
  -> a
  -> f b
composeToRead :: ToFilePathT f a -> ReadFilePathT f b -> a -> f b
composeToRead ToFilePathT f a
f ReadFilePathT f b
g =
  Getting (a -> f FilePath) (ToFilePathT f a) (a -> f FilePath)
-> ToFilePathT f a -> a -> f FilePath
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting (a -> f FilePath) (ToFilePathT f a) (a -> f FilePath)
forall s. Wrapped s => Iso' s (Unwrapped s)
_Wrapped' ToFilePathT f a
f (a -> f FilePath) -> (FilePath -> f b) -> a -> f b
forall (m :: * -> *) a b c.
Bind m =>
(a -> m b) -> (b -> m c) -> a -> m c
->- Getting (FilePath -> f b) (ReadFilePathT f b) (FilePath -> f b)
-> ReadFilePathT f b -> FilePath -> f b
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting (FilePath -> f b) (ReadFilePathT f b) (FilePath -> f b)
forall s. Wrapped s => Iso' s (Unwrapped s)
_Wrapped' ReadFilePathT f b
g

(->>-) ::
  Bind f =>
  ToFilePathT f a
  -> ReadFilePathT f b
  -> a
  -> f b
->>- :: ToFilePathT f a -> ReadFilePathT f b -> a -> f b
(->>-) =
  ToFilePathT f a -> ReadFilePathT f b -> a -> f b
forall (f :: * -> *) a b.
Bind f =>
ToFilePathT f a -> ReadFilePathT f b -> a -> f b
composeToRead

infixr 1 ->>-

composeReadTo ::
  Bind f =>
  ReadFilePathT f b
  -> ToFilePathT f a
  -> a
  -> f b
composeReadTo :: ReadFilePathT f b -> ToFilePathT f a -> a -> f b
composeReadTo ReadFilePathT f b
f ToFilePathT f a
g =
  Getting (FilePath -> f b) (ReadFilePathT f b) (FilePath -> f b)
-> ReadFilePathT f b -> FilePath -> f b
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting (FilePath -> f b) (ReadFilePathT f b) (FilePath -> f b)
forall s. Wrapped s => Iso' s (Unwrapped s)
_Wrapped' ReadFilePathT f b
f (FilePath -> f b) -> (a -> f FilePath) -> a -> f b
forall (m :: * -> *) b c a.
Bind m =>
(b -> m c) -> (a -> m b) -> a -> m c
-<- Getting (a -> f FilePath) (ToFilePathT f a) (a -> f FilePath)
-> ToFilePathT f a -> a -> f FilePath
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting (a -> f FilePath) (ToFilePathT f a) (a -> f FilePath)
forall s. Wrapped s => Iso' s (Unwrapped s)
_Wrapped' ToFilePathT f a
g

(-<<-) ::
  Bind f =>
  ReadFilePathT f b
  -> ToFilePathT f a
  -> a
  -> f b
-<<- :: ReadFilePathT f b -> ToFilePathT f a -> a -> f b
(-<<-) =
  ReadFilePathT f b -> ToFilePathT f a -> a -> f b
forall (f :: * -> *) b a.
Bind f =>
ReadFilePathT f b -> ToFilePathT f a -> a -> f b
composeReadTo

infixr 1 -<<-