HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulelens-5.3.5Haskell2010

System.FilePath.Lens

  • 16 values
  • Packagelens-5.3.5
  • Exports16
  • LanguageHaskell2010
  • LicenceBSD-2-Clause
  • SourceLens.hs

Operators

12 declarations
value(<<.>~)
  1. :: LensLike (Tuple2 FilePath) s a FilePath FilePath
  2. -> String
  3. -> s
  4. -> (FilePath, a)
#

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

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

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

value(<<<.>~)
  1. :: Optical' (->) q (Tuple2 FilePath) s FilePath
  2. -> String
  3. -> q s (FilePath, s)
#

Add an extension onto the end of the target of a Lens but return the old value

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

When you do not need the old value, (<.>~) is more flexible.

value(</>=) :: MonadState s m => ASetter' s FilePath -> FilePath -> m ()
#

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

Example1 expression
execState (both </>= "bin") ("hello","world") == ("hello" </> "bin", "world" </> "bin")True
(</>=) :: MonadState s m => Setter' s FilePath -> FilePath -> m ()
(</>=) :: MonadState s m => Iso' s FilePath -> FilePath -> m ()
(</>=) :: MonadState s m => Lens' s FilePath -> FilePath -> m ()
(</>=) :: MonadState s m => Traversal' s FilePath -> FilePath -> m ()
value(<.>=) :: MonadState s m => ASetter' s FilePath -> String -> m ()
#

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

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

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

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

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

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

Example1 expression
runState (_1 <<<.>= "txt") ("hello","world")("hello",("hello.txt","world"))

When you do not need the old value, (<.>=) is more flexible.

Lenses

4 declarations

A Lens for reading and writing to the basename

Note: This is not a legal Lens unless the outer FilePath has both a directory and filename component and the generated basenames are not null and contain no directory separators.

Example1 expression
(basename .~ "filename" $ "path" </> "name.png") == "path" </> "filename.png"True

A Lens for reading and writing to the directory

Note: this is not a legal Lens unless the outer FilePath already has a directory component, and generated directories are not null.

Example1 expression
(("long" </> "path" </> "name.txt") ^. directory) == "long" </> "path"True

A Lens for reading and writing to the extension

Note: This is not a legal Lens, unless you are careful to ensure that generated extension FilePath components are either null or start with System.FilePath.extSeparator and do not contain any internal System.FilePath.extSeparators.

Example1 expression
(extension .~ ".png" $ "path" </> "name.txt") == "path" </> "name.png"True

A Lens for reading and writing to the full filename

Note: This is not a legal Lens, unless you are careful to ensure that generated filename FilePath components are not null and do not contain any elements of System.FilePath.pathSeparatorss.

Example1 expression
(filename .~ "name.txt" $ "path" </> "name.png") == "path" </> "name.txt"True