directory-layout- Directory layout DSL

Safe HaskellNone



directory-layout internals



newtype Layout a Source

Directory layout description




unL :: Free F a


Monad Layout 
Functor Layout 
Typeable1 Layout 
Applicative Layout 
Foldable Layout 
Traversable Layout 
Eq (Layout a)

Equality check does not care about the order the files are listed insofar they are consistent, i.e. different things aren't named the same

Generic (Layout a) 
Semigroup (Layout a) 

data F a Source

The underlying Functor


F String (Maybe Contents) Aux a 
SL String FilePath Bool Aux a 
D String a Aux a 


data Aux Source

Auxiliary data


Aux (Maybe User) (Maybe Group) (Maybe FileMode) 

data User Source

File owner


UserID UserID 
Username String 

file :: String -> Layout ()Source

Regular file with some contents or empty

>>> let layout = file "foo"

symlink :: String -> FilePath -> Layout ()Source

Symbolic link

>>> let layout = symlink "foo" "bar"

dir :: String -> Layout a -> Layout ()Source


>>> :{
let layout = dir "foo" $ do
      file "bar"
      file "baz"

emptydir :: String -> Layout ()Source

Empty directory

>>> let layout = emptydir "foo"

dirs :: [String] -> Layout () -> Layout ()Source

A nested list of directories

>>> :{
let layout = dirs ["foo", "bar"] $ do
               file "qux"
               file "quux"

defaux :: AuxSource

The default (empty) auxiliary data

contents :: Traversal' (Layout a) (Maybe Contents)Source

An optic into file contents

binary :: ByteString -> ContentsSource

Binary contents

>>> let layout = file "foo" & contents ?~ binary (ByteString.pack [1..10])

text :: Text -> ContentsSource

Plain text contents

>>> let layout = file "foo" & contents ?~ text (Data.Text.pack "hello")

copyOf :: FilePath -> ContentsSource

Contents are the copy of whose of the real file

>>> let layout = file "foo" & contents ?~ copyOf "/home/user/.vimrc"

anything :: Maybe aSource


>>> let layout = file "foo" & contents .~ anything
>>> let layout = file "foo" & user .~ anything

source :: Traversal' (Layout a) StringSource

An optic into symbolic link source

>>> symlink "foo" "bar" ^? source
Just "bar"

exists :: Traversal' (Layout a) BoolSource

An optic into symbolic link source expected existence

>>> let layout = symlink "foo" "bar" & exists .~ True

aux :: Traversal' (Layout a) AuxSource

An optic into file auxiliary data

user :: Traversal' (Layout a) (Maybe User)Source

An optic into file owner

>>> let layout = file "foo" & user ?~ uid 0

uid :: UserID -> UserSource

Set the file owner by uid

username :: String -> UserSource

Set the file owner by username

>>> let layout = file "foo" & user ?~ username "root"

group :: Traversal' (Layout a) (Maybe Group)Source

An optic into file group

>>> let layout = file "foo" & group ?~ gid 0

gid :: GroupID -> GroupSource

Set the file group by groupname

groupname :: String -> GroupSource

Set the file group by groupname

>>> let layout = file "foo" & group ?~ groupname "wheel"

mode :: Traversal' (Layout a) (Maybe FileMode)Source

An optic into file mode

>>> let layout = file "foo" & mode ?~ 0o100777

innards :: Traversal' (Layout a) (Layout a)Source

An optic into directory contents

into :: String -> Traversal' (Layout ()) (Layout ())Source

An optic into the directory contents of the particular directory

>>> :{
dirs ["foo", "bar", "baz"] (symlink "qux" "quux")
  ^? into "foo".into "bar".into "baz".focus "qux".source
Just "quux"

focus :: String -> Traversal' (Layout ()) (Layout ())Source

An optic into the particular node