HORIZON HASKELLDocslts/ghc-9.14.xd82dee82026-10-12Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · d82dee8 · 2026-10-12

Modulefs-api-0.4.0.0Haskell2010

System.FS.API.Types

  • 10 types
  • 20 values
  • Packagefs-api-0.4.0.0
  • Exports30
  • LanguageHaskell2010
  • LicenceApache-2.0
  • SourceTypes.hs

Modes

4 declarations
datadata AllowExisting
#

When opening a file:

Constructors

Instances3Eq, Show, Condense
datadata OpenMode
#

How to hOpen a new file.

Each mode of file operation has an associated AllowExisting parameter which specifies the semantics of how to handle the existence or non-existence of the file.

Notably however, opening a file in read mode with the ReadMode value implicitly has the associated AllowExisting value of MustExist. This is because opening a non-existing file in ReadMode provides access to exactly 0 bytes of data and is hence a useless operation.

Instances3Eq, Show, Condense
datadata SeekMode
#

A mode that determines the effect of GHC.Internal.System.IO.hSeek hdl mode i.

Constructors

  • AbsoluteSeek

    the position of hdl is set to i.

  • RelativeSeek

    the position of hdl is set to offset i from the current position.

  • SeekFromEnd

    the position of hdl is set to offset i from the end of the file.

Instances7Enum, Eq, Ord, Read, Show, Ix, …
  • Enum SeekModeDefined in ghc-internal-9.1401.0 · GHC.Internal.IO.Device
  • Eq SeekModeDefined in ghc-internal-9.1401.0 · GHC.Internal.IO.Device
  • Ord SeekModeDefined in ghc-internal-9.1401.0 · GHC.Internal.IO.Device
  • Read SeekModeDefined in ghc-internal-9.1401.0 · GHC.Internal.IO.Device
  • Show SeekModeDefined in ghc-internal-9.1401.0 · GHC.Internal.IO.Device
  • Ix SeekModeDefined in ghc-internal-9.1401.0 · GHC.Internal.IO.Device
  • Condense SeekModeDefined in fs-api-0.4.0.0 · System.FS.Condense

Paths

12 declarations
valuefsPathFromList :: [Text] -> FsPath
#

Create a path from a list of directory/file names. All of the names should be non-empty.

value(<.>) :: FsPath -> String -> FsPath
#

Add an extension, even if there is already one there.

This works similarly to Filepath.<.>.

value(</>) :: FsPath -> FsPath -> FsPath
#

Combine two paths with a path separator.

This works similarly to </>, but since the arguments are relative paths, the corner cases for </> do not apply. Specifically, the second path will never start with a path separator or a drive letter, so the result is simply the concatenation of the two paths.

If either operand is empty, the other operand is returned. The result of combining two empty paths is the empty path

opaque

newtypenewtype FsPath
#

A relative path.

Invariant

The user of this library is tasked with picking sensible names of directories/files on a path. Amongst others, the following should hold:

  • Names are non-empty

  • Names are monotonic, i.e., they are not equal to ..

  • Names should not contain path separators or drive letters

In particular, names that satisfy these invariants should result in an FsPath that remains relative to the HasFS instance root. For example, an FsPath ["/"] would try to access the root folder, which is most likely outside of the scope of the HasFS instance.

".." should not be used because fs-sim will not be able to follow these types of back-links. fs-sim will interpret ".." as a directory name instead.

Instances7Eq, Ord, Show, Generic, NFData, Condense, …

Handles

1 declaration
datadata Handle h
#

Constructors

Instances6Eq, Show, Generic, NFData, Condense, Rep

Offset

1 declaration

Errors

9 declarations
datadata FsError
#

Constructors

Instances2Show, Exception
datadata FsErrorPath
#

For better error reporting to the end user, we want to include the mount point of the file. But the mountpoint may not always be available, like when we mock the fs or we simulate fs errors.

Instances3Eq, Show, Condense
valuesameFsError :: FsError -> FsError -> Bool
#

Check if two errors are semantically the same error

This ignores the error string, the errno, and the callstack.

From IOError to FsError

2 declarations

Assign an FsErrorType to the given IOError.

Note that we don't always use the classification made by errnoToIOError (also see System.IO.Error) because it combines some errors into one IOErrorType, e.g., EMFILE (too many open files) and ENOSPC (no space left on device) both result in ResourceExhausted while we want to keep them separate. For this reason, we do a classification of our own based on the errno while sometimes deferring to the existing classification.

See the ERRNO(3) man page for the meaning of the different errnos.