| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Charon.Data.Paths
Description
Provides functionality for distinguishing path types.
Synopsis
- newtype PathI (i :: PathIndex) = MkPathI {}
- data PathIndex
- isEmpty :: MonadThrow m => PathI i -> m Bool
- isRoot :: MonadThrow m => PathI i -> m Bool
- isRoot' :: MonadThrow m => OsPath -> m Bool
- isDots :: MonadThrow m => PathI i -> m Bool
- toString :: PathI i -> String
- toText :: PathI i -> Text
- showPaths :: [PathI a] -> String
- reindex :: PathI i -> PathI j
- (<//>) :: PathI i1 -> PathI i2 -> PathI i3
- (<//) :: PathI i1 -> OsPath -> PathI i2
- (//>) :: OsPath -> PathI i1 -> PathI i2
- applyPathI :: HasCallStack => (HasCallStack => OsPath -> a) -> PathI i -> a
- liftPathI :: (OsPath -> OsPath) -> PathI i -> PathI j
- liftPathI' :: (OsPath -> OsPath) -> PathI i -> PathI i
- liftPathIF :: (Functor f, HasCallStack) => (HasCallStack => OsPath -> f OsPath) -> PathI i -> f (PathI j)
- liftPathIF' :: Functor f => (HasCallStack => OsPath -> f OsPath) -> PathI i -> f (PathI i)
Types
newtype PathI (i :: PathIndex) Source #
Indexed OsPath so that we can prevent mixing up different filepaths.
Instances
| (Dysfunctional "unPathI" k (PathI i1) (PathI i2) a b, k ~ An_Iso, a ~ OsPath, b ~ OsPath) => LabelOptic "unPathI" k (PathI i1) (PathI i2) a b Source # | |
Defined in Charon.Data.Paths | |
| Generic (PathI i) Source # | |
| Show (PathI i) Source # | |
| Serial (PathI i) Source # | |
Defined in Charon.Data.Paths Associated Types type DecodeExtra (PathI i) Source # | |
| NFData (PathI i) Source # | |
Defined in Charon.Data.Paths | |
| Eq (PathI i) Source # | |
| Ord (PathI i) Source # | |
| Hashable (PathI i) Source # | |
| type Rep (PathI i) Source # | |
Defined in Charon.Data.Paths | |
| type DecodeExtra (PathI i) Source # | |
Defined in Charon.Data.Paths | |
Types of filepaths used in Charon.
Constructors
| TrashHome | The trash directory. |
| TrashLog | The trash log file. |
| TrashDirFiles | The directory to the trash files themselves i.e. trash/files. |
| TrashDirInfo | The directory to the trash info files i.e. trash/info. |
| TrashEntryPath | The full trash path i.e. |
| TrashEntryInfo | The full trash info path i.e. |
| TrashEntryFileName | The name corresponding to some file/directory in the trash directory. |
| TrashEntryOriginalPath | The original path for some file/directory in the trash directory. |
Functions
Specific
isDots :: MonadThrow m => PathI i -> m Bool Source #
Returns true if the path ends in nothing but dots e.g.
pathtodots...
General
These functions allows for lifting arbitrary OsPath functions onto our
PathI. Note that this can easily invalidate any invariants we would
like to hold (e.g. appending a path can turn a directory into a file),
so caution must be exercised.
showPaths :: [PathI a] -> String Source #
Pretty-print a list of paths.
>>>showPaths ["one", "two"]"one, two"
applyPathI :: HasCallStack => (HasCallStack => OsPath -> a) -> PathI i -> a Source #
liftPathI' :: (OsPath -> OsPath) -> PathI i -> PathI i Source #
liftPathI specialized to the same index. This should be preferred
as the former is easier to use incorrectly.
liftPathIF :: (Functor f, HasCallStack) => (HasCallStack => OsPath -> f OsPath) -> PathI i -> f (PathI j) Source #
liftPathIF' :: Functor f => (HasCallStack => OsPath -> f OsPath) -> PathI i -> f (PathI i) Source #
liftPathIF specialized to the same index. This should be preferred
as the former is easier to use incorrectly.