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

Safe HaskellNone

System.Directory.Layout

Contents

Description

Language to express directory layouts

Synopsis

Layout declaration

data DL a Source

Representation of directory layouts

Invariants:

  • F second argument is never D _ _ _ or F _ _ _ itself
  • F third argument is never T _ _
  • D second argument is never T _ _
  • D third argument is never T _ _

Instances

Monad DL 
Functor DL 
Applicative DL 
Foldable DL 
Traversable DL 
Apply DL 
Bind DL 
Eq a => Eq (DL a) 
Ord a => Ord (DL a) 
Read a => Read (DL a) 
Show a => Show (DL a) 
Default a => Monoid (DL a) 
Default a => Default (DL a) 
Semigroup (DL a) 

type Layout = DL ()Source

Type synonym to save some acrobatics

file :: FilePath -> Text -> LayoutSource

Declare file with specified contents

file_ :: FilePath -> LayoutSource

Declare empty file

directory :: FilePath -> Layout -> LayoutSource

Declare directory with specified listing

directory_ :: FilePath -> LayoutSource

Declare empty directory

Layout traverses

makeSource

Arguments

:: Layout 
-> FilePath

Root directory

-> IO [LayoutException]

List of warnings

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

checkSource

Arguments

:: Layout 
-> FilePath

Root directory

-> IO [LayoutException]

List of failures

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 []

Errors

data LayoutException Source

Information about cought exceptions in various routines