Copyright | © 2016–2017 Mark Karpov |
---|---|
License | BSD 3 clause |
Maintainer | Mark Karpov <markkarpov92@gmail.com> |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Types and type classes. 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
- class CanHandleExisting c where
Documentation
We use this as a 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
class HasTemp c where Source #
The type class is for the data types that include information specifying how to create temporary files and directories and whether to delete them automatically or not.
tempDir, nameTemplate, preserveCorpse, moveByRenaming, getTempDir, getNameTemplate, getPreserveCorpse, getMoveByRenaming
tempDir :: Path Abs Dir -> c Source #
Specify name of temporary directory to use. The default is the system temporary directory. If the directory does not exist, it will be created, but won't be deleted.
nameTemplate :: String -> c Source #
Specify the template string 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 #