packages feed

filepather-0.8.0.0: src/System/FilePather/Name/PathFunction.hs

{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wall #-}

{- | The name @pathFunction@, targeting @FilePath -> g a@: the function of a 'System.FilePather.FilePather.FilePather', from the file path being operated on.

Any value of the target type has the name, as the identity.

@since 0.8.0.0
-}
module System.FilePather.Name.PathFunction (
  PathFunctionLike (..),
) where

import Control.Lens (Optic)

{- | A field or a constructor named @pathFunction@.

@since 0.8.0.0
-}
class PathFunctionLike p f x x' g g' a a' | x -> g a where
  pathFunction ::
    Optic p f x x' (FilePath -> g a) (FilePath -> g' a')

{- | Identity

@since 0.8.0.0
-}
instance (x' ~ (FilePath -> g' a')) => PathFunctionLike p f (FilePath -> g a) x' g g' a a' where
  pathFunction =
    id
  {-# INLINE pathFunction #-}