lens-3.7.4: Lenses, Folds and Traversals

PortabilityRank2Types
Stabilityexperimental
MaintainerEdward Kmett <ekmett@gmail.com>
Safe HaskellNone

System.FilePath.Lens

Contents

Description

 

Synopsis

Operators

(</>~) :: Setting s t FilePath FilePath -> FilePath -> s -> tSource

Modify the path by adding another path.

>>> both </>~ "bin" $ ("hello","world")
("hello/bin","world/bin")
 (</>~) :: Setter s a FilePath FilePath -> FilePath -> s -> a
 (</>~) :: Iso s a FilePath FilePath -> FilePath -> s -> a
 (</>~) :: Lens s a FilePath FilePath -> FilePath -> s -> a
 (</>~) :: Traversal s a FilePath FilePath -> FilePath -> s -> a

(<</>~) :: LensLike ((,) FilePath) s a FilePath FilePath -> FilePath -> s -> (FilePath, a)Source

Add a path onto the end of the target of a Lens and return the result

When you do not need the result of the operation, (</>~) is more flexible.

(<.>~) :: Setting s a FilePath FilePath -> String -> s -> aSource

Modify the path by adding extension.

>>> both <.>~ "txt" $ ("hello","world")
("hello.txt","world.txt")
 (<.>~) :: Setter s a FilePath FilePath -> String -> s -> a
 (<.>~) :: Iso s a FilePath FilePath -> String -> s -> a
 (<.>~) :: Lens s a FilePath FilePath -> String -> s -> a
 (<.>~) :: Traversal s a FilePath FilePath -> String -> s -> a

(<<.>~) :: LensLike ((,) FilePath) s a FilePath FilePath -> String -> s -> (FilePath, a)Source

Add an extension onto the end of the target of a Lens and return the result

>>> _1 <<.>~ "txt" $ ("hello","world")
("hello.txt",("hello.txt","world"))

When you do not need the result of the operation, (<.>~) is more flexible.

(</>=) :: MonadState s m => SimpleSetting s FilePath -> FilePath -> m ()Source

Modify the target(s) of a Simple Lens, Iso, Setter or Traversal by adding a path.

>>> execState (both </>= "bin") ("hello","world")
("hello/bin","world/bin")
 (</>=) :: MonadState s m => Simple Setter s FilePath -> FilePath -> m ()
 (</>=) :: MonadState s m => Simple Iso s FilePath -> FilePath -> m ()
 (</>=) :: MonadState s m => Simple Lens s FilePath -> FilePath -> m ()
 (</>=) :: MonadState s m => Simple Traversal s FilePath -> FilePath -> m ()

(<</>=) :: MonadState s m => SimpleLensLike ((,) FilePath) s FilePath -> FilePath -> m FilePathSource

Add a path onto the end of the target of a Lens into your monad's state and return the result.

When you do not need the result of the operation, (</>=) is more flexible.

(<.>=) :: MonadState s m => SimpleSetting s FilePath -> String -> m ()Source

Modify the target(s) of a Simple Lens, Iso, Setter or Traversal by adding an extension.

>>> execState (both <.>= "txt") ("hello","world")
("hello.txt","world.txt")
 (<.>=) :: MonadState s m => Simple Setter s FilePath -> String -> m ()
 (<.>=) :: MonadState s m => Simple Iso s FilePath -> String -> m ()
 (<.>=) :: MonadState s m => Simple Lens s FilePath -> String -> m ()
 (<.>=) :: MonadState s m => Simple Traversal s FilePath -> String -> m ()

(<<.>=) :: MonadState s m => SimpleLensLike ((,) FilePath) s FilePath -> String -> m FilePathSource

Add an extension onto the end of the target of a Lens into your monad's state and return the result.

>>> evalState (_1 <<.>= "txt") $("hello","world")
"hello.txt"

When you do not need the result of the operation, (<.>=) is more flexible.

Lenses

basename :: Simple Lens FilePath FilePathSource

A Lens for reading and writing to the basename

>>> basename .~ "filename" $ "path/name.png"
"path/filename.png"

directory :: Simple Lens FilePath FilePathSource

A Lens for reading and writing to the directory

>>> "long/path/name.txt" ^. directory
"long/path"

extension :: Simple Lens FilePath FilePathSource

A Lens for reading and writing to the extension

>>> extension .~ ".png" $ "path/name.txt"
"path/name.png"

filename :: Simple Lens FilePath FilePathSource

A Lens for reading and writing to the full filename

>>> filename .~ "name.txt" $ "path/name.png"
"path/name.txt"