-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Directory layout DSL -- @package directory-layout @version 0.7.2.0 -- | Convenience quasiquoter to ease the pain working with multiline -- strings module System.Directory.Layout.QQ -- | A handy quasiquoter to work with the multiline file contents -- -- Strips the longest common leading spaces segment. All spacey -- characters are treated equally. The first line is ignored if it's -- spaces only. -- --
-- >>> :{
-- putStr [dedent|
-- hello
-- world
-- !
-- |]
-- :}
-- hello
-- world
-- !
--
dedent :: QuasiQuoter
-- | dedent with variable substitution
--
--
-- >>> let hello = "bye" :: String
--
-- >>> :{
-- putStr [dedentSubst|
-- #{hello}
-- world
-- !
-- |]
-- :}
-- bye
-- world
-- !
--
dedentSubst :: QuasiQuoter
-- | directory-layout internals
module System.Directory.Layout.Internal
-- | Directory layout description
newtype Layout a
L :: Free F a -> Layout a
unL :: Layout a -> Free F a
-- | The underlying Functor
data F a
F :: String -> (Maybe Contents) -> Aux -> a -> F a
SL :: String -> FilePath -> Bool -> Aux -> a -> F a
D :: String -> a -> Aux -> a -> F a
E :: F a
-- | Regular file contents
data Contents
Binary :: ByteString -> Contents
Text :: Text -> Contents
CopyOf :: FilePath -> Contents
-- | Auxiliary data
data Aux
Aux :: (Maybe User) -> (Maybe Group) -> (Maybe FileMode) -> Aux
-- | File owner
data User
UserID :: UserID -> User
Username :: String -> User
-- | File group
data Group
GroupID :: GroupID -> Group
Groupname :: String -> Group
-- | 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
-- | Regular file with some contents or empty
--
-- -- >>> let layout = file "foo" --file :: String -> Layout () -- | Symbolic link -- --
-- >>> let layout = symlink "foo" "bar" --symlink :: String -> FilePath -> Layout () -- | Directory -- --
-- >>> :{
-- let layout = dir "foo" $ do
-- file "bar"
-- file "baz"
-- :}
--
dir :: String -> Layout a -> Layout ()
-- | Empty directory
--
-- -- >>> let layout = emptydir "foo" --emptydir :: String -> Layout () -- | A nested list of directories -- --
-- >>> :{
-- let layout = dirs ["foo", "bar"] $ do
-- file "qux"
-- file "quux"
-- :}
--
dirs :: [String] -> Layout () -> Layout ()
-- | The default (empty) auxiliary data
defaux :: Aux
-- | An optic into file contents
contents :: Traversal' (Layout a) (Maybe Contents)
-- | Binary contents
--
-- -- >>> let layout = file "foo" & contents ?~ binary (ByteString.pack [1..10]) --binary :: ByteString -> Contents -- | Plain text contents -- --
-- >>> let layout = file "foo" & contents ?~ text (Data.Text.pack "hello") --text :: Text -> Contents -- | Contents are the copy of whose of the real file -- --
-- >>> let layout = file "foo" & contents ?~ copyOf "/home/user/.vimrc" --copyOf :: FilePath -> Contents -- | Anything -- --
-- >>> let layout = file "foo" & contents .~ anything -- -- >>> let layout = file "foo" & user .~ anything --anything :: Maybe a -- | An optic into symbolic link source -- --
-- >>> symlink "foo" "bar" ^? source -- Just "bar" --source :: Traversal' (Layout a) String -- | An optic into symbolic link source expected existence -- --
-- >>> let layout = symlink "foo" "bar" & exists .~ True --exists :: Traversal' (Layout a) Bool -- | An optic into file auxiliary data aux :: Traversal' (Layout a) Aux -- | An optic into file owner -- --
-- >>> let layout = file "foo" & user ?~ uid 0 --user :: Traversal' (Layout a) (Maybe User) -- | Set the file owner by uid uid :: UserID -> User -- | Set the file owner by username -- --
-- >>> let layout = file "foo" & user ?~ username "root" --username :: String -> User -- | An optic into file group -- --
-- >>> let layout = file "foo" & group ?~ gid 0 --group :: Traversal' (Layout a) (Maybe Group) -- | Set the file group by groupname gid :: GroupID -> Group -- | Set the file group by groupname -- --
-- >>> let layout = file "foo" & group ?~ groupname "wheel" --groupname :: String -> Group -- | An optic into file mode -- --
-- >>> let layout = file "foo" & mode ?~ 0o100777 --mode :: Traversal' (Layout a) (Maybe FileMode) -- | An optic into directory contents innards :: Traversal' (Layout a) (Layout a) -- | 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"
--
into :: String -> Traversal' (Layout ()) (Layout ())
-- | An optic into the particular node
focus :: String -> Traversal' (Layout ()) (Layout ())
instance Typeable Contents
instance Typeable User
instance Typeable Group
instance Typeable Aux
instance Typeable F
instance Typeable Layout
instance Eq Contents
instance Data Contents
instance Generic Contents
instance Show User
instance Eq User
instance Generic User
instance Show Group
instance Eq Group
instance Generic Group
instance Show Aux
instance Eq Aux
instance Generic Aux
instance Eq a => Eq (F a)
instance Functor F
instance Foldable F
instance Traversable F
instance Generic (F a)
instance Functor Layout
instance Applicative Layout
instance Monad Layout
instance Foldable Layout
instance Traversable Layout
instance Generic (Layout a)
instance Datatype D1Contents
instance Constructor C1_0Contents
instance Constructor C1_1Contents
instance Constructor C1_2Contents
instance Datatype D1User
instance Constructor C1_0User
instance Constructor C1_1User
instance Datatype D1Group
instance Constructor C1_0Group
instance Constructor C1_1Group
instance Datatype D1Aux
instance Constructor C1_0Aux
instance Datatype D1F
instance Constructor C1_0F
instance Constructor C1_1F
instance Constructor C1_2F
instance Constructor C1_3F
instance Datatype D1Layout
instance Constructor C1_0Layout
instance Selector S1_0_0Layout
instance Semigroup (Layout a)
instance Eq (Layout a)
instance IsString Group
instance IsString User
instance IsList Contents
instance IsString Contents
-- | A bunch of Layout description interpreters
module System.Directory.Layout.Interpreter
-- | Pretty print the directory layout
pretty :: Layout a -> String
-- | Interpret the directory layout as a Spec
examples :: FilePath -> Layout a -> Spec
-- | Construct Validation value from the list of errors
--
-- -- >>> fromErrors [] -- Right () ---- --
-- >>> fromErrors Nothing -- Right () ---- --
-- >>> fromErrors "hello"
-- Left ('h' :| "ello")
--
--
--
-- >>> fromErrors (Just "hello")
-- Left ("hello" :| [])
--
fromErrors :: Foldable t => t e -> Either (NonEmpty e) ()
-- | Check the real directory layout fits the description
fit :: FilePath -> Layout a -> IO (Either (NonEmpty FitError) ())
-- | Errors encountered while running fit
data FitError
FitBadFileContents :: FilePath -> FitContentsError -> FitError
FitBadLinkSource :: FilePath -> String -> String -> FitError
FitBadOwnerUser :: FilePath -> User -> User -> FitError
FitBadOwnerGroup :: FilePath -> Group -> Group -> FitError
FitBadFileMode :: FilePath -> FileMode -> FileMode -> FitError
FitIOException :: FilePath -> IOErrorType -> FitError
-- | Expected/actual file contents mismatch
data FitContentsError
FitBadBinary :: ByteString -> ByteString -> FitContentsError
FitBadText :: Text -> Text -> FitContentsError
FitBadCopyOf :: FilePath -> FitContentsError
-- | Make the real directory layout from the description
make :: FilePath -> Layout a -> IO (Either (NonEmpty MakeError) ())
-- | Make the real directory layout from the description removing any
-- previous contents
remake :: FilePath -> Layout a -> IO (Either (NonEmpty MakeError) ())
-- | Errors encountered while running make
data MakeError
MakeIOException :: FilePath -> IOErrorType -> MakeError
instance Typeable FitContentsError
instance Typeable FitError
instance Typeable MakeError
instance Typeable (\/)
instance Eq FitContentsError
instance Generic FitContentsError
instance Eq FitError
instance Generic FitError
instance Show MakeError
instance Eq MakeError
instance Generic MakeError
instance (Show e, Show a) => Show (e \/ a)
instance (Eq e, Eq a) => Eq (e \/ a)
instance (Ord e, Ord a) => Ord (e \/ a)
instance Functor ((\/) e)
instance Foldable ((\/) e)
instance Traversable ((\/) e)
instance (Data e, Data a) => Data (e \/ a)
instance Generic (e \/ a)
instance Datatype D1FitContentsError
instance Constructor C1_0FitContentsError
instance Constructor C1_1FitContentsError
instance Constructor C1_2FitContentsError
instance Datatype D1FitError
instance Constructor C1_0FitError
instance Constructor C1_1FitError
instance Constructor C1_2FitError
instance Constructor C1_3FitError
instance Constructor C1_4FitError
instance Constructor C1_5FitError
instance Datatype D1MakeError
instance Constructor C1_0MakeError
instance Datatype D1\/
instance Constructor C1_0\/
instance Constructor C1_1\/
instance Semigroup e => Applicative ((\/) e)
instance Exception MakeError
instance Exception FitError
instance Show FitError
-- | Directory layout DSL
module System.Directory.Layout
-- | Directory layout description
data Layout a
-- | Regular file with some contents or empty
--
-- -- >>> let layout = file "foo" --file :: String -> Layout () -- | Symbolic link -- --
-- >>> let layout = symlink "foo" "bar" --symlink :: String -> FilePath -> Layout () -- | Directory -- --
-- >>> :{
-- let layout = dir "foo" $ do
-- file "bar"
-- file "baz"
-- :}
--
dir :: String -> Layout a -> Layout ()
-- | A nested list of directories
--
--
-- >>> :{
-- let layout = dirs ["foo", "bar"] $ do
-- file "qux"
-- file "quux"
-- :}
--
dirs :: [String] -> Layout () -> Layout ()
-- | Empty directory
--
-- -- >>> let layout = emptydir "foo" --emptydir :: String -> Layout () -- | An optic into file contents contents :: Traversal' (Layout a) (Maybe Contents) -- | Regular file contents data Contents Binary :: ByteString -> Contents Text :: Text -> Contents CopyOf :: FilePath -> Contents -- | Binary contents -- --
-- >>> let layout = file "foo" & contents ?~ binary (ByteString.pack [1..10]) --binary :: ByteString -> Contents -- | Plain text contents -- --
-- >>> let layout = file "foo" & contents ?~ text (Data.Text.pack "hello") --text :: Text -> Contents -- | A handy quasiquoter to work with the multiline file contents -- -- Strips the longest common leading spaces segment. All spacey -- characters are treated equally. The first line is ignored if it's -- spaces only. -- --
-- >>> :{
-- putStr [dedent|
-- hello
-- world
-- !
-- |]
-- :}
-- hello
-- world
-- !
--
dedent :: QuasiQuoter
-- | Contents are the copy of whose of the real file
--
-- -- >>> let layout = file "foo" & contents ?~ copyOf "/home/user/.vimrc" --copyOf :: FilePath -> Contents -- | An optic into symbolic link source -- --
-- >>> symlink "foo" "bar" ^? source -- Just "bar" --source :: Traversal' (Layout a) String -- | An optic into symbolic link source expected existence -- --
-- >>> let layout = symlink "foo" "bar" & exists .~ True --exists :: Traversal' (Layout a) Bool -- | File owner data User UserID :: UserID -> User Username :: String -> User -- | An optic into file owner -- --
-- >>> let layout = file "foo" & user ?~ uid 0 --user :: Traversal' (Layout a) (Maybe User) -- | Set the file owner by uid uid :: UserID -> User -- | Set the file owner by username -- --
-- >>> let layout = file "foo" & user ?~ username "root" --username :: String -> User -- | File group data Group GroupID :: GroupID -> Group Groupname :: String -> Group -- | An optic into file group -- --
-- >>> let layout = file "foo" & group ?~ gid 0 --group :: Traversal' (Layout a) (Maybe Group) -- | Set the file group by groupname gid :: GroupID -> Group -- | Set the file group by groupname -- --
-- >>> let layout = file "foo" & group ?~ groupname "wheel" --groupname :: String -> Group -- | An optic into file mode -- --
-- >>> let layout = file "foo" & mode ?~ 0o100777 --mode :: Traversal' (Layout a) (Maybe FileMode) -- | Anything -- --
-- >>> let layout = file "foo" & contents .~ anything -- -- >>> let layout = file "foo" & user .~ anything --anything :: Maybe a -- | 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"
--
into :: String -> Traversal' (Layout ()) (Layout ())
-- | An optic into the particular node
focus :: String -> Traversal' (Layout ()) (Layout ())