directory-layout-0.3.1.0: Declare, construct and verify directory layout

Safe HaskellNone

System.Directory.Layout.Lens

Description

Control.Lens based extractors for DL

Synopsis

Documentation

>>> :set -XOverloadedStrings
>>> import           Control.Lens
>>> let layout = F "foo" (T "not empty" ()) (D "bar" (F "baz" (E ()) (F "quux" (T "something" ()) (E ()))) (F "swaks" (E ()) (E ())))

text :: Prism Layout Layout Text TextSource

Get Text out of the current Layout (if possible)

>>> layout ^? text
Nothing
>>> layout ^? file "foo" . text
Just "not empty"
>>> layout ^? directory "bar" . file "quux" . text
Just "something"

file :: FilePath -> IndexedTraversal' FilePath Layout LayoutSource

Look into the file in the current Layout (if possible)

>>> layout ^? file "biz"
Nothing
>>> layout ^? file "swaks"
Just (E ())
>>> layout ^? directory "bar" . file "baz"
Just (E ())

directory :: FilePath -> IndexedTraversal' FilePath Layout LayoutSource

Go into the directory in the current Layout (if possible)

>>> layout ^? directory "foo"
Nothing
>>> layout ^? directory "bar"
Just (F "baz" (E ()) (F "quux" (T "something" ()) (E ())))