plan-b-0.2.1: Failure-tolerant file and directory editing

Copyright© 2016–2017 Mark Karpov
LicenseBSD 3 clause
MaintainerMark Karpov <markkarpov92@gmail.com>
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

System.PlanB.Type

Description

Types and type classes. You usually don't need to import this module because System.PlanB already exports everything you need.

Synopsis

Documentation

data Subject Source #

We use this as a kind with two promoted constructors. The constructors are used as phantom types to index PbConfig.

Constructors

New 
Existing 

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.

Methods

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.

Minimal complete definition

overrideIfExists, useIfExists, howHandleExisting

Methods

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 #