Copyright | © 2016 Mark Karpov |
---|---|
License | BSD 3 clause |
Maintainer | Mark Karpov <markkarpov@openmailbox.org> |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Types and type classes for “Plan B” library. You usually don't need to import this module because System.PlanB already exports everything you need.
- data Subject
- data AlreadyExistsBehavior
- data PbConfig :: Subject -> *
- class HasTemp c where
- tempDir :: Path Abs Dir -> c
- nameTemplate :: String -> c
- preserveCorpse :: c
- moveByRenaming :: c
- getTempDir :: c -> Maybe (Path Abs Dir)
- getNameTemplate :: c -> Maybe String
- getPreserveCorpse :: c -> Bool
- getMoveByRenaming :: c -> Bool
- class CanHandleExisting c where
- overrideIfExists :: c
- useIfExists :: c
- howHandleExisting :: c -> Maybe AlreadyExistsBehavior
Documentation
We use this as named kind with two promoted constructors. The
constructors are used as phantom types to index PbConfig
.
data AlreadyExistsBehavior Source
Custom behavior for cases when something already exists.
AebOverride | First delete that object, then do your thing |
AebUse | Continue to work with that object instead |
data PbConfig :: Subject -> * Source
The configuration allows to control behavior of the library in
details. It's a Monoid
and so various configuration settings can be
combined using mappend
while mempty
represents default behavior.
When combining conflicting configuration settings, the value on the left
side of mappend
wins:
overrideIfExists <> useIfExists -- will override
The type class is for data types that include information specifying how to create temporary files and directories and whether to delete them automatically or not.
tempDir :: Path Abs Dir -> c Source
Specifies name of temporary directory to use. Default is the system temporary directory. If the directory does not exist, it will be created, but not deleted.
nameTemplate :: String -> c Source
Specify template to use to name temporary directory, see
openTempFile
, default is "plan-b"
.
preserveCorpse :: c Source
preserveCorpse
preserves temporary files and directories when
exception is thrown (normally they are removed).
moveByRenaming :: c Source
By default files are moved by copying. Moving by renaming, although not always possible, often more efficient. This option enables it.
getTempDir :: c -> Maybe (Path Abs Dir) Source
getNameTemplate :: c -> Maybe String Source
getPreserveCorpse :: c -> Bool Source
getMoveByRenaming :: c -> Bool Source
class CanHandleExisting c where Source
The type class includes data types that contain information about what to do when some object already exists. There are two scenarios currently supported: override it or use it.
overrideIfExists :: c Source
The option allows to avoid throwing exception if upon completion of specified action file with given name already exists in the file system.
useIfExists :: c Source
The option will copy already existing file into temporary location, so you can edit it instead of creating new file.
howHandleExisting :: c -> Maybe AlreadyExistsBehavior Source