-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Failure-tolerant file and directory editing -- -- Failure-tolerant file and directory editing. @package plan-b @version 0.2.0 -- | 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. module System.PlanB.Type -- | We use this as named kind with two promoted constructors. The -- constructors are used as phantom types to index PbConfig. data Subject New :: Subject Existing :: Subject -- | Custom behavior for cases when something already exists. data AlreadyExistsBehavior -- | First delete that object, then do your thing AebOverride :: AlreadyExistsBehavior -- | Continue to work with that object instead AebUse :: AlreadyExistsBehavior -- | 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 --data PbConfig :: Subject -> * -- | 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. class HasTemp c -- | 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. tempDir :: HasTemp c => Path Abs Dir -> c -- | Specify template to use to name temporary directory, see -- openTempFile, default is "plan-b". nameTemplate :: HasTemp c => String -> c -- | preserveCorpse preserves temporary files and directories when -- exception is thrown (normally they are removed). preserveCorpse :: HasTemp c => c -- | By default files are moved by copying. Moving by renaming, although -- not always possible, often more efficient. This option enables it. moveByRenaming :: HasTemp c => c getTempDir :: HasTemp c => c -> Maybe (Path Abs Dir) getNameTemplate :: HasTemp c => c -> Maybe String getPreserveCorpse :: HasTemp c => c -> Bool getMoveByRenaming :: HasTemp c => c -> Bool -- | 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. class CanHandleExisting c -- | The option allows to avoid throwing exception if upon completion of -- specified action file with given name already exists in the file -- system. overrideIfExists :: CanHandleExisting c => c -- | The option will copy already existing file into temporary location, so -- you can edit it instead of creating new file. useIfExists :: CanHandleExisting c => c howHandleExisting :: CanHandleExisting c => c -> Maybe AlreadyExistsBehavior instance GHC.Enum.Bounded System.PlanB.Type.AlreadyExistsBehavior instance GHC.Enum.Enum System.PlanB.Type.AlreadyExistsBehavior instance GHC.Classes.Eq System.PlanB.Type.AlreadyExistsBehavior instance GHC.Base.Monoid (System.PlanB.Type.PbConfig k) instance System.PlanB.Type.HasTemp (System.PlanB.Type.PbConfig k) instance System.PlanB.Type.CanHandleExisting (System.PlanB.Type.PbConfig 'System.PlanB.Type.New) -- | Failure-tolerant file and directory editing. All functions here can -- recover from exceptions thrown while they work. They bring file-system -- to the state it was in before specific function was called. Temporary -- files and backups are handled automatically. module System.PlanB -- | Create new file. Name of the file is taken as the second argument. The -- third argument allows to perform actions (in simplest case just -- creation of file), result of those actions should be new file with -- given file name. -- -- This action throws alreadyExistsErrorType by default instead of -- silently overwriting already existing file, use -- overrideIfExists and useIfExists to change this -- behavior. withNewFile :: (MonadIO m, MonadMask m) => PbConfig New -> Path b File -> (Path Abs File -> m a) -> m a -- | Edit existing file. Name of the file is taken as the second argument. -- The third argument allows to perform actions on temporary copy of -- specified file. -- -- This action throws doesNotExistErrorType exception if target -- file does not exist. withExistingFile :: (MonadIO m, MonadMask m) => PbConfig Existing -> Path b File -> (Path Abs File -> m a) -> m a -- | Create new directory. Name of the directory is specified as the second -- argument. The third argument allows to perform actions in “sandboxed” -- version of new directory. -- -- This action throws alreadyExistsErrorType by default instead of -- silently overwriting already existing directory, use -- overrideIfExists and useIfExiststo change this behavior. withNewDir :: (MonadIO m, MonadMask m) => PbConfig New -> Path b Dir -> (Path Abs Dir -> m a) -> m a -- | Edit existing directory. Name of the directory is specified as the -- second argument. The third argument allows to perform actions in -- “sandboxed” copy of target directory. -- -- This action throws doesNotExistErrorType exception if target -- directory does not exist. withExistingDir :: (MonadIO m, MonadMask m) => PbConfig Existing -> Path b Dir -> (Path Abs Dir -> m a) -> m a -- | Create new container file. This is suitable for processing of all -- sorts of archive-like objects. The first and second arguments specify -- how to unpack directory from file and pack it back. The fourth -- argument names new file. The fifth argument allows to perform actions -- knowing name of temporary directory. -- -- This action throws alreadyExistsErrorType by default instead of -- silently overwriting already existing file, use -- overrideIfExists and useIfExiststo change this behavior. withNewContainer :: (MonadIO m, MonadMask m) => (Path Abs File -> Path Abs Dir -> m ()) -> (Path Abs Dir -> Path b File -> m ()) -> PbConfig New -> Path b File -> (Path Abs Dir -> m a) -> m a -- | Edit existing container file. This is suitable for processing of all -- sorts of archive-like objects. The first and second arguments specify -- how to unpack directory from file and pack it back (overwriting old -- version). Fourth argument names container file to edit. The last -- argument allows to perform actions knowing name of temporary -- directory. -- -- This action throws doesNotExistErrorType exception if target -- file does not exist. withExistingContainer :: (MonadIO m, MonadMask m) => (Path b File -> Path Abs Dir -> m ()) -> (Path Abs Dir -> Path b File -> m ()) -> PbConfig Existing -> Path b File -> (Path Abs Dir -> m a) -> m a -- | 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. tempDir :: HasTemp c => Path Abs Dir -> c -- | Specify template to use to name temporary directory, see -- openTempFile, default is "plan-b". nameTemplate :: HasTemp c => String -> c -- | preserveCorpse preserves temporary files and directories when -- exception is thrown (normally they are removed). preserveCorpse :: HasTemp c => c -- | By default files are moved by copying. Moving by renaming, although -- not always possible, often more efficient. This option enables it. moveByRenaming :: HasTemp c => c -- | The option allows to avoid throwing exception if upon completion of -- specified action file with given name already exists in the file -- system. overrideIfExists :: CanHandleExisting c => c -- | The option will copy already existing file into temporary location, so -- you can edit it instead of creating new file. useIfExists :: CanHandleExisting c => c