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
- class CanHandleExisting c where
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
class HasTemp c where Source #
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).
getTempDir :: c -> Maybe (Path Abs Dir) Source #
getNameTemplate :: c -> Maybe String Source #
getPreserveCorpse :: 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 #