Generalize stripDir to MonadThrow
This commit is contained in:
parent
87a56a93b8
commit
ffdf4af243
@ -239,9 +239,14 @@ toFilePath (Path l) = l
|
||||
--
|
||||
-- In other words the bases must match.
|
||||
--
|
||||
stripDir :: Path b Dir -> Path b t -> Maybe (Path Rel t)
|
||||
-- Throws: 'Couldn'tStripPrefixDir'
|
||||
--
|
||||
stripDir :: MonadThrow m
|
||||
=> Path b Dir -> Path b t -> m (Path Rel t)
|
||||
stripDir (Path p) (Path l) =
|
||||
fmap Path (stripPrefix p l)
|
||||
case fmap Path (stripPrefix p l) of
|
||||
Nothing -> throwM (Couldn'tStripPrefixDir p l)
|
||||
Just ok -> return ok
|
||||
|
||||
-- | Is p a parent of the given location? Implemented in terms of
|
||||
-- 'stripDir'. The bases must match.
|
||||
|
Loading…
Reference in New Issue
Block a user