Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
A directory forest of files associated with values
This module is meant to be imported like this:
import Data.DirForest (DirForest) import qualified Data.DirForest as DF
Synopsis
- data DirTree a
- newtype DirForest a = DirForest {
- unDirForest :: Map FilePath (DirTree a)
- data InsertionError a
- = FileInTheWay (Path Rel File) a
- | DirInTheWay (Path Rel Dir) (DirForest a)
- data FOD a
- eq1DirTree :: (a -> b -> Bool) -> DirTree a -> DirTree b -> Bool
- ord1DirTree :: (a -> b -> Ordering) -> DirTree a -> DirTree b -> Ordering
- eq1DirForest :: (a -> b -> Bool) -> DirForest a -> DirForest b -> Bool
- ord1DirForest :: (a -> b -> Ordering) -> DirForest a -> DirForest b -> Ordering
- null :: DirForest a -> Bool
- nullFiles :: DirForest a -> Bool
- lookup :: forall a. Path Rel File -> DirForest a -> Maybe a
- empty :: DirForest a
- singletonFile :: Path Rel File -> a -> DirForest a
- singletonDir :: Path Rel Dir -> DirForest a
- insertFile :: forall a. Path Rel File -> a -> DirForest a -> Either (InsertionError a) (DirForest a)
- insertDir :: forall a. Path Rel Dir -> DirForest a -> Either (InsertionError a) (DirForest a)
- mapWithPath :: (Path Rel File -> a -> b) -> DirForest a -> DirForest b
- traverseWithPath :: forall a b f. Applicative f => (Path Rel File -> a -> f b) -> DirForest a -> f (DirForest b)
- traverseWithPath_ :: forall a b f. Applicative f => (Path Rel File -> a -> f b) -> DirForest a -> f ()
- pruneEmptyDirs :: DirForest a -> Maybe (DirForest a)
- anyEmptyDir :: DirForest a -> Bool
- fromFileMap :: Map (Path Rel File) a -> Either (InsertionError a) (DirForest a)
- toFileMap :: DirForest a -> Map (Path Rel File) a
- fromMap :: Map FilePath (FOD a) -> Either (InsertionError a) (DirForest a)
- toMap :: DirForest a -> Map FilePath (FOD a)
- fromFileList :: [(Path Rel File, a)] -> Either (InsertionError a) (DirForest a)
- toFileList :: DirForest a -> [(Path Rel File, a)]
- read :: forall a b m. MonadIO m => Path b Dir -> (Path b File -> m a) -> m (DirForest a)
- readNonHidden :: forall a b m. MonadIO m => Path b Dir -> (Path b File -> m a) -> m (DirForest a)
- readFiltered :: forall a b m. MonadIO m => (Path b File -> Bool) -> (Path b Dir -> Bool) -> Path b Dir -> (Path b File -> m a) -> m (DirForest a)
- readNonHiddenFiltered :: forall a b m. MonadIO m => (Path b File -> Bool) -> (Path b Dir -> Bool) -> Path b Dir -> (Path b File -> m a) -> m (DirForest a)
- readOneLevel :: forall a b m. MonadIO m => Path b Dir -> (Path b File -> m a) -> m (DirForest a)
- readOneLevelNonHidden :: forall a b m. MonadIO m => Path b Dir -> (Path b File -> m a) -> m (DirForest a)
- readOneLevelFiltered :: forall a b m. MonadIO m => (Path b File -> Bool) -> (Path b Dir -> Bool) -> Path b Dir -> (Path b File -> m a) -> m (DirForest a)
- readOneLevelNonHiddenFiltered :: forall a b m. MonadIO m => (Path b File -> Bool) -> (Path b Dir -> Bool) -> Path b Dir -> (Path b File -> m a) -> m (DirForest a)
- hiddenRel :: Path Rel t -> Bool
- write :: forall a b. (Show a, Ord a) => Path b Dir -> DirForest a -> (Path b File -> a -> IO ()) -> IO ()
- data InsertValidation e a
- = InsertionErrors (NonEmpty (InsertionError e))
- | NoInsertionErrors a
- unpackInsertValidation :: InsertValidation e a -> Either (NonEmpty (InsertionError e)) a
- union :: DirForest a -> DirForest a -> InsertValidation a (DirForest a)
- unionWith :: (a -> a -> a) -> DirForest a -> DirForest a -> InsertValidation a (DirForest a)
- unionWithKey :: forall a. (Path Rel File -> a -> a -> a) -> DirForest a -> DirForest a -> InsertValidation a (DirForest a)
- unions :: [DirForest a] -> Either (InsertionError a) (DirForest a)
- intersection :: DirForest a -> DirForest b -> DirForest a
- intersectionWith :: (a -> b -> c) -> DirForest a -> DirForest b -> DirForest c
- intersectionWithKey :: forall a b c. (Path Rel File -> a -> b -> c) -> DirForest a -> DirForest b -> DirForest c
- intersections :: [DirForest a] -> DirForest a
- difference :: DirForest a -> DirForest b -> DirForest a
- differenceWith :: (a -> b -> Maybe a) -> DirForest a -> DirForest b -> DirForest a
- differenceWithKey :: forall a b. (Path Rel File -> a -> b -> Maybe a) -> DirForest a -> DirForest b -> DirForest a
- filter :: (a -> Bool) -> DirForest a -> DirForest a
- filterWithKey :: forall a. (Path Rel File -> a -> Bool) -> DirForest a -> DirForest a
- filterHidden :: forall a. DirForest a -> DirForest a
Dirforest types
Instances
DirForest | |
|
Instances
data InsertionError a Source #
FileInTheWay (Path Rel File) a | |
DirInTheWay (Path Rel Dir) (DirForest a) |
Instances
File or Dir
Instances
Functor FOD Source # | |
Generic (FOD a) Source # | |
Show a => Show (FOD a) Source # | |
Eq a => Eq (FOD a) Source # | |
Ord a => Ord (FOD a) Source # | |
Validity a => Validity (FOD a) Source # | |
Defined in Data.DirForest validate :: FOD a -> Validation # | |
type Rep (FOD a) Source # | |
Defined in Data.DirForest type Rep (FOD a) = D1 ('MetaData "FOD" "Data.DirForest" "dirforest-0.1.0.0-Kx7FjqyA5HqHM6ZA0ofIz0" 'False) (C1 ('MetaCons "F" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: C1 ('MetaCons "D" 'PrefixI 'False) (U1 :: Type -> Type)) |
Comparisons
Query
nullFiles :: DirForest a -> Bool Source #
True iff there are only empty directories in the directory forest
Construction
insertFile :: forall a. Path Rel File -> a -> DirForest a -> Either (InsertionError a) (DirForest a) Source #
insertDir :: forall a. Path Rel Dir -> DirForest a -> Either (InsertionError a) (DirForest a) Source #
Traversal
traverseWithPath :: forall a b f. Applicative f => (Path Rel File -> a -> f b) -> DirForest a -> f (DirForest b) Source #
traverseWithPath_ :: forall a b f. Applicative f => (Path Rel File -> a -> f b) -> DirForest a -> f () Source #
Pruning
anyEmptyDir :: DirForest a -> Bool Source #
Conversion
Map
fromFileMap :: Map (Path Rel File) a -> Either (InsertionError a) (DirForest a) Source #
List
fromFileList :: [(Path Rel File, a)] -> Either (InsertionError a) (DirForest a) Source #
IO
Read
readNonHidden :: forall a b m. MonadIO m => Path b Dir -> (Path b File -> m a) -> m (DirForest a) Source #
readFiltered :: forall a b m. MonadIO m => (Path b File -> Bool) -> (Path b Dir -> Bool) -> Path b Dir -> (Path b File -> m a) -> m (DirForest a) Source #
readNonHiddenFiltered :: forall a b m. MonadIO m => (Path b File -> Bool) -> (Path b Dir -> Bool) -> Path b Dir -> (Path b File -> m a) -> m (DirForest a) Source #
readOneLevel :: forall a b m. MonadIO m => Path b Dir -> (Path b File -> m a) -> m (DirForest a) Source #
readOneLevelNonHidden :: forall a b m. MonadIO m => Path b Dir -> (Path b File -> m a) -> m (DirForest a) Source #
readOneLevelFiltered :: forall a b m. MonadIO m => (Path b File -> Bool) -> (Path b Dir -> Bool) -> Path b Dir -> (Path b File -> m a) -> m (DirForest a) Source #
readOneLevelNonHiddenFiltered :: forall a b m. MonadIO m => (Path b File -> Bool) -> (Path b Dir -> Bool) -> Path b Dir -> (Path b File -> m a) -> m (DirForest a) Source #
Write
write :: forall a b. (Show a, Ord a) => Path b Dir -> DirForest a -> (Path b File -> a -> IO ()) -> IO () Source #
Combinations
Union
data InsertValidation e a Source #
Instances
unpackInsertValidation :: InsertValidation e a -> Either (NonEmpty (InsertionError e)) a Source #
unionWith :: (a -> a -> a) -> DirForest a -> DirForest a -> InsertValidation a (DirForest a) Source #
unionWithKey :: forall a. (Path Rel File -> a -> a -> a) -> DirForest a -> DirForest a -> InsertValidation a (DirForest a) Source #
Intersection
intersectionWithKey :: forall a b c. (Path Rel File -> a -> b -> c) -> DirForest a -> DirForest b -> DirForest c Source #
intersections :: [DirForest a] -> DirForest a Source #
Difference
differenceWithKey :: forall a b. (Path Rel File -> a -> b -> Maybe a) -> DirForest a -> DirForest b -> DirForest a Source #
Filter
filterHidden :: forall a. DirForest a -> DirForest a Source #