fs-api-0.3.0.1: Abstract interface for the file system
Safe HaskellSafe-Inferred
LanguageHaskell2010

System.FS.API.Types

Synopsis

Modes

data AllowExisting Source #

When opening a file:

Constructors

AllowExisting

The file may already exist. If it does, it is reopened. If it doesn't, it is created.

MustBeNew

The file may not yet exist. If it does, an error (FsResourceAlreadyExist) is thrown.

Instances

Instances details
Show AllowExisting Source # 
Instance details

Defined in System.FS.API.Types

Condense AllowExisting Source # 
Instance details

Defined in System.FS.API.Types

Eq AllowExisting Source # 
Instance details

Defined in System.FS.API.Types

data OpenMode Source #

How to hOpen a new file.

Instances

Instances details
Show OpenMode Source # 
Instance details

Defined in System.FS.API.Types

Methods

showsPrecIntOpenModeShowS #

showOpenModeString #

showList ∷ [OpenMode] → ShowS #

Condense OpenMode Source # 
Instance details

Defined in System.FS.API.Types

Eq OpenMode Source # 
Instance details

Defined in System.FS.API.Types

Methods

(==)OpenModeOpenModeBool #

(/=)OpenModeOpenModeBool #

data SeekMode #

A mode that determines the effect of 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.

Instances

Instances details
Enum SeekMode

Since: base-4.2.0.0

Instance details

Defined in GHC.IO.Device

Ix SeekMode

Since: base-4.2.0.0

Instance details

Defined in GHC.IO.Device

Read SeekMode

Since: base-4.2.0.0

Instance details

Defined in GHC.IO.Device

Show SeekMode

Since: base-4.2.0.0

Instance details

Defined in GHC.IO.Device

Methods

showsPrecIntSeekModeShowS #

showSeekModeString #

showList ∷ [SeekMode] → ShowS #

Condense SeekMode Source # 
Instance details

Defined in System.FS.API.Types

Eq SeekMode

Since: base-4.2.0.0

Instance details

Defined in GHC.IO.Device

Methods

(==)SeekModeSeekModeBool #

(/=)SeekModeSeekModeBool #

Ord SeekMode

Since: base-4.2.0.0

Instance details

Defined in GHC.IO.Device

Paths

newtype MountPoint Source #

Mount point

FsPaths are not absolute paths, but must be interpreted with respect to a particualar mount point.

Constructors

MountPoint FilePath 

fsPathFromList ∷ [Text] → FsPath Source #

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

fsPathInitHasCallStackFsPathFsPath Source #

Drop the final component of the path

Undefined if the path is empty.

fsPathSplitFsPathMaybe (FsPath, Text) Source #

Split FsPath is essentially (init fp, last fp)

Like init and last, Nothing if empty.

mkFsPath ∷ [String] → FsPath Source #

Constructor for FsPath ensures path is in normal form

(<.>)FsPathStringFsPath infixr 7 Source #

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

This works similarly to <.>.

addExtensionFsPathStringFsPath Source #

An alias for <.>.

(</>)FsPathFsPathFsPath infixr 5 Source #

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

combineFsPathFsPathFsPath Source #

An alias for </>.

opaque

data FsPath Source #

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.

Instances

Instances details
Generic FsPath Source # 
Instance details

Defined in System.FS.API.Types

Associated Types

type Rep FsPathTypeType #

Methods

fromFsPathRep FsPath x #

toRep FsPath x → FsPath #

Show FsPath Source # 
Instance details

Defined in System.FS.API.Types

Methods

showsPrecIntFsPathShowS #

showFsPathString #

showList ∷ [FsPath] → ShowS #

NFData FsPath Source # 
Instance details

Defined in System.FS.API.Types

Methods

rnfFsPath → () #

Condense FsPath Source # 
Instance details

Defined in System.FS.API.Types

Methods

condenseFsPathString Source #

Eq FsPath Source # 
Instance details

Defined in System.FS.API.Types

Methods

(==)FsPathFsPathBool #

(/=)FsPathFsPathBool #

Ord FsPath Source # 
Instance details

Defined in System.FS.API.Types

Methods

compareFsPathFsPathOrdering #

(<)FsPathFsPathBool #

(<=)FsPathFsPathBool #

(>)FsPathFsPathBool #

(>=)FsPathFsPathBool #

maxFsPathFsPathFsPath #

minFsPathFsPathFsPath #

type Rep FsPath Source # 
Instance details

Defined in System.FS.API.Types

type Rep FsPath = D1 ('MetaData "FsPath" "System.FS.API.Types" "fs-api-0.3.0.1-inplace" 'True) (C1 ('MetaCons "UnsafeFsPath" 'PrefixI 'True) (S1 ('MetaSel ('Just "fsPathToList") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Text])))

Handles

data Handle h Source #

Constructors

Handle 

Fields

  • handleRaw ∷ !h

    The raw underlying handle

  • handlePath ∷ !FsPath

    The path corresponding to this handle

    This is primarily useful for error reporting.

Instances

Instances details
Generic (Handle h) Source # 
Instance details

Defined in System.FS.API.Types

Associated Types

type Rep (Handle h) ∷ TypeType #

Methods

fromHandle h → Rep (Handle h) x #

toRep (Handle h) x → Handle h #

Show (Handle h) Source # 
Instance details

Defined in System.FS.API.Types

Methods

showsPrecIntHandle h → ShowS #

showHandle h → String #

showList ∷ [Handle h] → ShowS #

NFData h ⇒ NFData (Handle h) Source # 
Instance details

Defined in System.FS.API.Types

Methods

rnfHandle h → () #

Condense (Handle h) Source # 
Instance details

Defined in System.FS.API.Types

Methods

condenseHandle h → String Source #

Eq h ⇒ Eq (Handle h) Source # 
Instance details

Defined in System.FS.API.Types

Methods

(==)Handle h → Handle h → Bool #

(/=)Handle h → Handle h → Bool #

type Rep (Handle h) Source # 
Instance details

Defined in System.FS.API.Types

type Rep (Handle h) = D1 ('MetaData "Handle" "System.FS.API.Types" "fs-api-0.3.0.1-inplace" 'False) (C1 ('MetaCons "Handle" 'PrefixI 'True) (S1 ('MetaSel ('Just "handleRaw") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 h) :*: S1 ('MetaSel ('Just "handlePath") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 FsPath)))

Offset

newtype AbsOffset Source #

Constructors

AbsOffset 

Fields

Instances

Instances details
Bounded AbsOffset Source # 
Instance details

Defined in System.FS.API.Types

Enum AbsOffset Source # 
Instance details

Defined in System.FS.API.Types

Num AbsOffset Source # 
Instance details

Defined in System.FS.API.Types

Show AbsOffset Source # 
Instance details

Defined in System.FS.API.Types

Methods

showsPrecIntAbsOffsetShowS #

showAbsOffsetString #

showList ∷ [AbsOffset] → ShowS #

Eq AbsOffset Source # 
Instance details

Defined in System.FS.API.Types

Methods

(==)AbsOffsetAbsOffsetBool #

(/=)AbsOffsetAbsOffsetBool #

Ord AbsOffset Source # 
Instance details

Defined in System.FS.API.Types

Errors

data FsError Source #

Constructors

FsError 

Fields

Instances

Instances details
Exception FsError Source # 
Instance details

Defined in System.FS.API.Types

Show FsError Source # 
Instance details

Defined in System.FS.API.Types

Methods

showsPrecIntFsErrorShowS #

showFsErrorString #

showList ∷ [FsError] → ShowS #

data FsErrorPath Source #

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.

Instances

Instances details
Show FsErrorPath Source # 
Instance details

Defined in System.FS.API.Types

Condense FsErrorPath Source # 
Instance details

Defined in System.FS.API.Types

Eq FsErrorPath Source #

We only care to compare the FsPath, because the MountPoint may not exist.

Instance details

Defined in System.FS.API.Types

data FsErrorType Source #

Instances

Instances details
Show FsErrorType Source # 
Instance details

Defined in System.FS.API.Types

Eq FsErrorType Source # 
Instance details

Defined in System.FS.API.Types

sameFsErrorFsErrorFsErrorBool Source #

Check if two errors are semantically the same error

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

From IOError to FsError

ioToFsErrorHasCallStackFsErrorPathIOErrorFsError Source #

Translate exceptions thrown by IO functions to FsError

We take the FsPath as an argument. We could try to translate back from a FilePath to an FsPath (given a MountPoint), but we know the FsPath at all times anyway and not all IO exceptions actually include a filepath.

ioToFsErrorTypeIOErrorFsErrorType Source #

Assign an FsErrorType to the given IOError.

Note that we don't always use the classification made by errnoToIOError (also see 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.

Orphan instances

Condense SeekMode Source # 
Instance details