Safe Haskell | None |
---|---|
Language | Haskell2010 |
directory-layout internals
- newtype Layout a = L {}
- data F a
- data Contents
- data Aux = Aux (Maybe User) (Maybe Group) (Maybe FileMode)
- data User
- data Group
- file :: String -> Layout ()
- symlink :: String -> FilePath -> Layout ()
- dir :: String -> Layout a -> Layout ()
- emptydir :: String -> Layout ()
- dirs :: [String] -> Layout () -> Layout ()
- defaux :: Aux
- contents :: Traversal' (Layout a) (Maybe Contents)
- binary :: ByteString -> Contents
- text :: Text -> Contents
- copyOf :: FilePath -> Contents
- anything :: Maybe a
- source :: Traversal' (Layout a) String
- exists :: Traversal' (Layout a) Bool
- aux :: Traversal' (Layout a) Aux
- user :: Traversal' (Layout a) (Maybe User)
- uid :: UserID -> User
- username :: String -> User
- group :: Traversal' (Layout a) (Maybe Group)
- gid :: GroupID -> Group
- groupname :: String -> Group
- mode :: Traversal' (Layout a) (Maybe FileMode)
- innards :: Traversal' (Layout a) (Layout a)
- into :: String -> Traversal' (Layout ()) (Layout ())
- focus :: String -> Traversal' (Layout ()) (Layout ())
Documentation
Directory layout description
Monad Layout | |
Functor 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) | |
Typeable (* -> *) Layout | |
type Rep (Layout a) |
The underlying Functor
Regular file contents
Auxiliary data
File owner
File group
file :: String -> Layout () Source
Regular file with some contents or empty
>>>
let layout = file "foo"
dir :: String -> Layout a -> Layout () Source
Directory
>>>
:{
let layout = dir "foo" $ do file "bar" file "baz" :}
dirs :: [String] -> Layout () -> Layout () Source
A nested list of directories
>>>
:{
let layout = dirs ["foo", "bar"] $ do file "qux" file "quux" :}
binary :: ByteString -> Contents Source
Binary contents
>>>
let layout = file "foo" & contents ?~ binary (ByteString.pack [1..10])
text :: Text -> Contents Source
Plain text contents
>>>
let layout = file "foo" & contents ?~ text (Data.Text.pack "hello")
copyOf :: FilePath -> Contents Source
Contents are the copy of whose of the real file
>>>
let layout = file "foo" & contents ?~ copyOf "/home/user/.vimrc"
Anything
>>>
let layout = file "foo" & contents .~ anything
>>>
let layout = file "foo" & user .~ anything
source :: Traversal' (Layout a) String Source
An optic into symbolic link source
>>>
symlink "foo" "bar" ^? source
Just "bar"
exists :: Traversal' (Layout a) Bool Source
An optic into symbolic link source expected existence
>>>
let layout = symlink "foo" "bar" & exists .~ True
aux :: Traversal' (Layout a) Aux Source
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
username :: String -> User Source
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
groupname :: String -> Group Source
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