-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Declare, construct and verify directory layout -- -- Language to express directory layouts @package directory-layout @version 0.4.0.0 -- | Wrappers around exception throwing functions and related routines module System.Directory.Layout.Errored -- | Information about cought exceptions in various routines data LayoutException -- | createDirectory exceptions CD :: IOErrorType -> FilePath -> LayoutException -- | createFile eceptions CF :: IOErrorType -> FilePath -> LayoutException -- | fileExists eceptions FE :: IOErrorType -> FilePath -> LayoutException -- | directoryExists eceptions DE :: IOErrorType -> FilePath -> LayoutException -- | readFile eceptions RF :: IOErrorType -> FilePath -> Text -> LayoutException -- | IO-exceptions-free createDirectory createDirectory :: MonadIO m => FilePath -> m (Either LayoutException ()) -- | IO-exceptions-free writeFile createFile :: MonadIO m => FilePath -> Maybe Text -> m (Either LayoutException ()) -- | doesFileExist that returns Either instead of Bool fileExists :: MonadIO m => FilePath -> m (Either LayoutException ()) -- | doesDirectoryExist that returns Either instead of -- Bool directoryExists :: MonadIO m => FilePath -> m (Either LayoutException ()) -- | IO-exceptions-free readFile readFile :: MonadIO m => FilePath -> Text -> m (Either LayoutException ()) -- | Log failures anyfail :: MonadWriter [w] m => m (Either w a) -> m () -- | Make paths in LayoutException relative to given FilePath relative :: FilePath -> LayoutException -> LayoutException instance Show LayoutException instance Eq LayoutException -- | Free monad based directory layouts module System.Directory.Layout.Internal -- | A representation of directory layouts -- -- Invariants: -- -- data Node a -- | Emptyness, nothing found here E :: !a -> Node a -- | File contents T :: !Text -> !a -> Node a -- | File node F :: !FilePath -> !Layout -> !(Node a) -> Node a -- | Directory node D :: !FilePath -> !Layout -> !(Node a) -> Node a -- | Type synonym to save some acrobatics type Layout = Node () instance Show a => Show (Node a) instance Read a => Read (Node a) instance Eq a => Eq (Node a) instance Ord a => Ord (Node a) instance Traversable Node instance Foldable Node instance Monad Node instance Bind Node instance Applicative Node instance Apply Node instance Functor Node instance Default a => Monoid (Node a) instance Semigroup (Node a) instance Default a => Default (Node a) -- | Layout traverses module System.Directory.Layout.Traverse -- | Make layout as specified -- -- For example, suppose you are in an empty directory -- --
--   % tree
--   .
--   
-- -- and you've written simple layout: -- --
--   layout = do
--     directory "baz" $
--       file_ "twey"
--     directory "foo" $ do
--       directory "bar" $ do
--         file_ "quuz"
--         file_ "tatata"
--       file_ "quux"
--   
-- -- then running it should result in this directory tree: -- --
--   % tree
--   .
--   ├── baz
--   │   └── twey
--   └── foo
--       ├── bar
--       │   ├── quuz
--       │   └── tatata
--       └── quux
--   
make :: Layout -> FilePath -> IO [LayoutException] -- | Check directory layout agrees with specified one -- -- For example, suppose there is a tree: -- --
--   % tree
--   .
--   ├── baz
--   │   └── twey
--   └── foo
--       ├── bar
--       │   ├── quuz
--       │   └── tatata
--       └── quux
--   
-- -- then you can write: -- --
--   layout = do
--     directory "baz" $
--       file_ "twey"
--     directory "foo" $ do
--       directory "bar" $ do
--         file_ "quuz"
--         file_ "tatata"
--       file_ "quux"
--   
-- -- and running check layout "." should result in [] check :: Layout -> FilePath -> IO [LayoutException] -- | Control.Lens based extractors for Layout module System.Directory.Layout.Lens -- | Target Text from the current Layout top (if possible) -- --
--   >>> layout ^? text
--   Nothing
--   
--   >>> layout ^? file "foo" . text
--   Just "not empty"
--   
--   >>> layout ^? directory "bar" . file "quux" . text
--   Just "something"
--   
text :: Prism' Layout Text -- | Target FilePath from the current Layout top (if -- possible) -- --
--   >>> layout ^? name
--   Just "foo"
--   
--   >>> layout ^? directory "bar" . name
--   Just "baz"
--   
--   >>> layout ^? directory "quux" . name
--   Nothing
--   
--   >>> layout & name .~ "boo"
--   F "boo" (T "not empty" ()) (D "bar" (F "baz" (E ()) (F "quux" (T "something" ()) (E ()))) (F "swaks" (E ()) (E ())))
--   
name :: Traversal' Layout FilePath -- | Target all Filpaths from current Layout layer -- --
--   >>> layout ^? names
--   Just "foo"
--   
--   >>> layout ^.. names
--   ["foo","bar","swaks"]
--   
--   >>> layout ^.. directory "bar" . names
--   ["baz","quux"]
--   
--   >>> layout & directory "bar" . names %~ reverse
--   F "foo" (T "not empty" ()) (D "bar" (F "zab" (E ()) (F "xuuq" (T "something" ()) (E ()))) (F "swaks" (E ()) (E ())))
--   
names :: Traversal' Layout FilePath -- | Target next Node -- --
--   >>> layout ^? name
--   Just "foo"
--   
--   >>> layout ^? next . name
--   Just "bar"
--   
--   >>> layout ^? next . next . name
--   Just "swaks"
--   
--   >>> layout ^? next . next . next . name
--   Nothing
--   
next :: Traversal' Layout Layout -- | Target Layout under the current Layout top if it happens -- to be a file -- --
--   >>> layout ^? file "biz"
--   Nothing
--   
--   >>> layout ^? file "swaks"
--   Just (E ())
--   
--   >>> layout ^? directory "bar" . file "baz"
--   Just (E ())
--   
file :: FilePath -> IndexedTraversal' FilePath Layout Layout -- | Target Layout under the current Layout top if it happens -- to be a directory -- --
--   >>> layout ^? directory "foo"
--   Nothing
--   
--   >>> layout ^? directory "bar"
--   Just (F "baz" (E ()) (F "quux" (T "something" ()) (E ())))
--   
directory :: FilePath -> IndexedTraversal' FilePath Layout Layout -- | Target Layout under the current Layout top -- --
--   >>> layout ^? node "foo"
--   Just (T "not empty" ())
--   
--   >>> layout ^? node "bar"
--   Just (F "baz" (E ()) (F "quux" (T "something" ()) (E ())))
--   
--   >>> layout ^? node "what"
--   Nothing
--   
node :: FilePath -> IndexedTraversal' FilePath Layout Layout -- | Language to express directory layouts module System.Directory.Layout -- | A representation of directory layouts -- -- Invariants: -- -- data Node a -- | Type synonym to save some acrobatics type Layout = Node () -- | Declare file with specified contents file :: FilePath -> Text -> Layout -- | Declare empty file file_ :: FilePath -> Layout -- | Declare directory with specified listing directory :: FilePath -> Layout -> Layout -- | Declare empty directory directory_ :: FilePath -> Layout -- | Create layout from directory -- -- Canonicalizes path before traversing, generally understands only -- regular files and directories and ignores anything else it could not -- understand fromDirectory :: FilePath -> IO (Either IOException Layout) -- | Make layout as specified -- -- For example, suppose you are in an empty directory -- --
--   % tree
--   .
--   
-- -- and you've written simple layout: -- --
--   layout = do
--     directory "baz" $
--       file_ "twey"
--     directory "foo" $ do
--       directory "bar" $ do
--         file_ "quuz"
--         file_ "tatata"
--       file_ "quux"
--   
-- -- then running it should result in this directory tree: -- --
--   % tree
--   .
--   ├── baz
--   │   └── twey
--   └── foo
--       ├── bar
--       │   ├── quuz
--       │   └── tatata
--       └── quux
--   
make :: Layout -> FilePath -> IO [LayoutException] -- | Check directory layout agrees with specified one -- -- For example, suppose there is a tree: -- --
--   % tree
--   .
--   ├── baz
--   │   └── twey
--   └── foo
--       ├── bar
--       │   ├── quuz
--       │   └── tatata
--       └── quux
--   
-- -- then you can write: -- --
--   layout = do
--     directory "baz" $
--       file_ "twey"
--     directory "foo" $ do
--       directory "bar" $ do
--         file_ "quuz"
--         file_ "tatata"
--       file_ "quux"
--   
-- -- and running check layout "." should result in [] check :: Layout -> FilePath -> IO [LayoutException] -- | Information about cought exceptions in various routines data LayoutException -- | createDirectory exceptions CD :: IOErrorType -> FilePath -> LayoutException -- | createFile eceptions CF :: IOErrorType -> FilePath -> LayoutException -- | fileExists eceptions FE :: IOErrorType -> FilePath -> LayoutException -- | directoryExists eceptions DE :: IOErrorType -> FilePath -> LayoutException -- | readFile eceptions RF :: IOErrorType -> FilePath -> Text -> LayoutException