Abstract handle to directory contents.
May be closed multiple times and will be automatically closed by GC when it goes out of scope.
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27
Moduledirectory-ospath-streaming-0.3Haskell2010
You’ll most likely be interested in either
getDirectoryContentsRecursive to search directory hierarchy recursively
DirStream, openDirStream, readDirStream, and closeDirStream to traverse single directory efficiently
Abstract handle to directory contents.
May be closed multiple times and will be automatically closed by GC when it goes out of scope.
Returns basename path of the directory entry.
Returns both basename path and full path of a directory entry relative to the passed DirStream root.
For example:
readDirStreamFull =<< openDirStream [osp|.|]
Just ("./bar",Basename {unBasename = "foo"},File Regular)readDirStreamFull =<< openDirStream [osp|foo/|]
Just ("foo/bar",Basename {unBasename = "foo"},File Regular)readDirStreamFull =<< openDirStream [osp|/foo/foo|]
Just ("/foo/foo/bar",Basename {unBasename = "foo"},File Regular)This allows to avoid re-creating the full path on the client side and thus reduce allocations.
Deallocate directory handle. It’s safe to close DirStream multiple times, unlike the underlying OS-specific directory stream handle.
Eq SymlinkTypeDefined in directory-ospath-streaming-0.3 · System.Directory.OsPath.TypesOrd SymlinkTypeDefined in directory-ospath-streaming-0.3 · System.Directory.OsPath.TypesRead SymlinkTypeDefined in directory-ospath-streaming-0.3 · System.Directory.OsPath.TypesShow SymlinkTypeDefined in directory-ospath-streaming-0.3 · System.Directory.OsPath.TypesGeneric SymlinkTypeDefined in directory-ospath-streaming-0.3 · System.Directory.OsPath.TypesNFData SymlinkTypeDefined in directory-ospath-streaming-0.3 · System.Directory.OsPath.Typestype Rep SymlinkType = D1 ('MetaData "SymlinkType"
"System.Directory.OsPath.Types"
"directory-ospath-streaming-0.3-3854tZliPMYHB0V0eRQx2X"
'False) (C1 ('MetaCons "Regular"
'PrefixI 'False) U1 :+: C1 ('MetaCons "Symlink"
'PrefixI 'False) U1)Defined in directory-ospath-streaming-0.3 · System.Directory.OsPath.TypesEq FileTypeDefined in directory-ospath-streaming-0.3 · System.Directory.OsPath.TypesOrd FileTypeDefined in directory-ospath-streaming-0.3 · System.Directory.OsPath.TypesRead FileTypeDefined in directory-ospath-streaming-0.3 · System.Directory.OsPath.TypesShow FileTypeDefined in directory-ospath-streaming-0.3 · System.Directory.OsPath.TypesGeneric FileTypeDefined in directory-ospath-streaming-0.3 · System.Directory.OsPath.TypesNFData FileTypeDefined in directory-ospath-streaming-0.3 · System.Directory.OsPath.Typestype Rep FileType = D1 ('MetaData "FileType"
"System.Directory.OsPath.Types"
"directory-ospath-streaming-0.3-3854tZliPMYHB0V0eRQx2X"
'False) (C1 ('MetaCons "File"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'SourceUnpack 'SourceStrict 'DecidedUnpack) (Rec0 SymlinkType)) :+: (C1 ('MetaCons "Directory"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'SourceUnpack 'SourceStrict 'DecidedUnpack) (Rec0 SymlinkType)) :+: C1 ('MetaCons "Other"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'SourceUnpack 'SourceStrict 'DecidedUnpack) (Rec0 SymlinkType))))Defined in directory-ospath-streaming-0.3 · System.Directory.OsPath.TypesBasename part of filename, without directory separators.
BasenameunBasename :: aFunctor BasenameDefined in directory-ospath-streaming-0.3 · System.Directory.OsPath.TypesFoldable BasenameDefined in directory-ospath-streaming-0.3 · System.Directory.OsPath.TypesTraversable BasenameDefined in directory-ospath-streaming-0.3 · System.Directory.OsPath.TypesGeneric1 BasenameDefined in directory-ospath-streaming-0.3 · System.Directory.OsPath.TypesEq a => Eq (Basename a)Defined in directory-ospath-streaming-0.3 · System.Directory.OsPath.TypesOrd a => Ord (Basename a)Defined in directory-ospath-streaming-0.3 · System.Directory.OsPath.TypesShow a => Show (Basename a)Defined in directory-ospath-streaming-0.3 · System.Directory.OsPath.TypesGeneric (Basename a)Defined in directory-ospath-streaming-0.3 · System.Directory.OsPath.TypesNFData a => NFData (Basename a)Defined in directory-ospath-streaming-0.3 · System.Directory.OsPath.Typestype Rep (Basename a) = D1 ('MetaData "Basename"
"System.Directory.OsPath.Types"
"directory-ospath-streaming-0.3-3854tZliPMYHB0V0eRQx2X"
'True) (C1 ('MetaCons "Basename"
'PrefixI 'True) (S1 ('MetaSel ('Just "unBasename"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))Defined in directory-ospath-streaming-0.3 · System.Directory.OsPath.Typestype Rep1 Basename = D1 ('MetaData "Basename"
"System.Directory.OsPath.Types"
"directory-ospath-streaming-0.3-3854tZliPMYHB0V0eRQx2X"
'True) (C1 ('MetaCons "Basename"
'PrefixI 'True) (S1 ('MetaSel ('Just "unBasename"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))Defined in directory-ospath-streaming-0.3 · System.Directory.OsPath.TypesRecursively list all the files and directories in a directory and all subdirectories.
The directory structure is traversed depth-first.
The result is generated lazily so is not well defined if the source directory structure changes before the list is fully consumed.
Symlinks within directory structure may cause result to be infinitely long.
Recursively list all the files and directories that satisfy given predicate in a directory and all subdirectories. Descending into some subdirectories may be avoided by filtering them out with a visiting predicate.
Not visited directory entry may still be reported depending on the collection predicate.
The directory structure is traversed depth-first.
The result is generated lazily so is not well defined if the source directory structure changes before the list is fully consumed.
Symlinks within directory structure may cause result to be infinitely long, but they can be filtered out with a suitable directory visiting predicate.
listContentsRecFold :: (Foldable f, Coercible b OsPath)=> Maybe IntDepth limit if specified, negative values treated the same as positive ones.
-> (forall c. OsPath -> b -> Relative OsPath -> Basename OsPath -> SymlinkType -> (a -> IO c -> IO c) -> (IO c -> IO c) -> IO c -> IO c)Decide how to fold directory and its children given its path.
Can do IO actions to plan what to do and typically should derive its
result from last IO c argument.
Returns IO c where c is hidden from the user so the only way
to make it is to construct from the passed IO c action.
Arguments:
OsPath - full path to the visited directory relative to root we’re searching in. If the root was absolute then this path would be too, if it was relative then this path would be relative to the same target.
b - root of the visited directory as passed originally in f b to the bigger fold function
Relative OsPath - path to the visited directory relative to the previous b argument
Basename OsPath - name of the visited directory without slashes
SymlinkType - symlink status of the visited directory
(a -> IO c -> IO c) - can be used to record some output (a) about the directory itself
(IO c -> IO c) - traverse inside this directory, can be ignored to skip its children
IO c - continue scanning not yet visited parts, must be used to construct return value (otherwise it won’t typecheck!)
The passed (IO c -> IO c) argument function should (but is not required to)
be applied in the returned function and it will prepend results for subdirectories
of the directory being analyzed. If not applied these subdirectories will be skipped,
this way ignoring particular directory and all its children can be achieved.
-> (OsPath -> b -> Relative OsPath -> Basename OsPath -> FileType -> IO (Maybe a))What to do with file
-> f bRoots to search in, either absolute or relative
-> IO [a]The most general form of gathering directory contents.
Treats symlinks the same as regular files and directories. Folding functions can decide how to handle symlinks.
Both directory and file actions can throw exceptions and this function will try to close finished directory streams promptly (they’ll be closed by GC in the worst case).
Auxiliary constants to refer to different file types without allocations.
Auxiliary constants to refer to different file types without allocations.
Auxiliary constants to refer to different file types without allocations.
Auxiliary constants to refer to different file types without allocations.
Auxiliary constants to refer to different file types without allocations.
Auxiliary constants to refer to different file types without allocations.