hpath/HPath.html

105 lines
42 KiB
HTML
Raw Normal View History

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>HPath</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
2016-06-01 12:52:48 +00:00
window.onload = function () {pageLoad();setSynopsis("mini_HPath.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/HPath.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">hpath-0.7.5: Support for well-typed paths</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Copyright</th><td>&#169; 2015&#8211;2016 FP Complete, 2016 Julian Ospald</td></tr><tr><th>License</th><td>BSD 3 clause</td></tr><tr><th>Maintainer</th><td>Julian Ospald &lt;hasufell@posteo.de&gt;</td></tr><tr><th>Stability</th><td>experimental</td></tr><tr><th>Portability</th><td>portable</td></tr><tr><th>Safe Haskell</th><td>Safe</td></tr><tr><th>Language</th><td>Haskell2010</td></tr></table><p class="caption">HPath</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Types</a></li><li><a href="#g:2">PatternSynonyms/ViewPatterns</a></li><li><a href="#g:3">Path Parsing</a></li><li><a href="#g:4">Path Conversion</a></li><li><a href="#g:5">Path Operations</a></li><li><a href="#g:6">Path IO helpers</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Support for well-typed paths.</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">data</span> <a href="#t:Abs">Abs</a></li><li class="src short"><span class="keyword">data</span> <a href="#t:Path">Path</a> b</li><li class="src short"><span class="keyword">data</span> <a href="#t:Rel">Rel</a></li><li class="src short"><span class="keyword">data</span> <a href="#t:Fn">Fn</a></li><li class="src short"><span class="keyword">data</span> <a href="#t:PathParseException">PathParseException</a></li><li class="src short"><span class="keyword">data</span> <a href="#t:PathException">PathException</a></li><li class="src short"><span class="keyword">class</span> <a href="#t:RelC">RelC</a> m</li><li class="src short"><span class="keyword">pattern</span> <a href="#v:Path">Path</a> :: <span class="keyword">forall</span> a. <a href="https://hackage.haskell.org/package/bytestring-0.10.8.1/docs/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; <a href="HPath.html#t:Path">Path</a> a</li><li class="src short"><a href="#v:parseAbs">parseAbs</a> :: MonadThrow m =&gt; <a href="https://hackage.haskell.org/package/bytestring-0.10.8.1/docs/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; m (<a href="HPath.html#t:Path">Path</a> <a href="HPath.html#t:Abs">Abs</a>)</li><li class="src short"><a href="#v:parseFn">parseFn</a> :: MonadThrow m =&gt; <a href="https://hackage.haskell.org/package/bytestring-0.10.8.1/docs/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; m (<a href="HPath.html#t:Path">Path</a> <a href="HPath.html#t:Fn">Fn</a>)</li><li class="src short"><a href="#v:parseRel">parseRel</a> :: MonadThrow m =&gt; <a href="https://hackage.haskell.org/package/bytestring-0.10.8.1/docs/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; m (<a href="HPath.html#t:Path">Path</a> <a href="HPath.html#t:Rel">Rel</a>)</li><li class="src short"><a href="#v:fromAbs">fromAbs</a> :: <a href="HPath.html#t:Path">Path</a> <a href="HPath.html#t:Abs">Abs</a> -&gt; <a href="https://hackage.haskell.org/package/bytestring-0.10.8.1/docs/Data-ByteString.html#t:ByteString">ByteString</a></li><li class="src short"><a href="#v:fromRel">fromRel</a> :: <a href="HPath.html#t:RelC">RelC</a> r =&gt; <a href="HPath.html#t:Path">Path</a> r -&gt; <a href="https://hackage.haskell.org/package/bytestring-0.10.8.1/docs/Data-ByteString.html#t:ByteString">ByteString</a></li><li class="src short"><a href="#v:toFilePath">toFilePath</a> :: <a href="HPath.html#t:Path">Path</a> b -&gt; <a href="https://hackage.haskell.org/package/bytestring-0.10.8.1/docs/Data-ByteString.html#t:ByteString">ByteString</a></li><li class="src short"><a href="#v:-60--47--62-">(&lt;/&gt;)</a> :: <a href="HPath.html#t:RelC">RelC</a> r =&gt; <a href="
path separators <code>//</code>, no <code>..</code>, no <code>./</code>, no <code>~/</code>, etc.</p></div><div class="subs instances"><p id="control.i:Path" class="caption collapser" onclick="toggleSection('i:Path')">Instances</p><div id="section.i:Path" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Path:Eq:1" class="instance expander" onclick="toggleSection('i:id:Path:Eq:1')"></span> <a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/Data-Eq.html#t:Eq">Eq</a> (<a href="HPath.html#t:Path">Path</a> b)</span> <a href="src/HPath-Internal.html#line-30" class="link">Source</a> <a href="#t:Path" class="selflink">#</a></td><td class="doc"><p>ByteString equality.</p><p>The following property holds:</p><pre>show x == show y &#8801; x == y</pre></td></tr><tr><td colspan="2"><div id="section.i:id:Path:Eq:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-61--61-">(==)</a> :: <a href="HPath.html#t:Path">Path</a> b -&gt; <a href="HPath.html#t:Path">Path</a> b -&gt; <a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-61--61-" class="selflink">#</a></p><p class="src"><a href="#v:-47--61-">(/=)</a> :: <a href="HPath.html#t:Path">Path</a> b -&gt; <a href="HPath.html#t:Path">Path</a> b -&gt; <a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-47--61-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Path:Ord:2" class="instance expander" onclick="toggleSection('i:id:Path:Ord:2')"></span> <a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/Data-Ord.html#t:Ord">Ord</a> (<a href="HPath.html#t:Path">Path</a> b)</span> <a href="src/HPath-Internal.html#line-38" class="link">Source</a> <a href="#t:Path" class="selflink">#</a></td><td class="doc"><p>ByteString ordering.</p><p>The following property holds:</p><pre>show x `compare` show y &#8801; x `compare` y</pre></td></tr><tr><td colspan="2"><div id="section.i:id:Path:Ord:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:compare">compare</a> :: <a href="HPath.html#t:Path">Path</a> b -&gt; <a href="HPath.html#t:Path">Path</a> b -&gt; <a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/Data-Ord.html#t:Ordering">Ordering</a> <a href="#v:compare" class="selflink">#</a></p><p class="src"><a href="#v:-60-">(&lt;)</a> :: <a href="HPath.html#t:Path">Path</a> b -&gt; <a href="HPath.html#t:Path">Path</a> b -&gt; <a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-60-" class="selflink">#</a></p><p class="src"><a href="#v:-60--61-">(&lt;=)</a> :: <a href="HPath.html#t:Path">Path</a> b -&gt; <a href="HPath.html#t:Path">Path</a> b -&gt; <a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-60--61-" class="selflink">#</a></p><p class="src"><a href="#v:-62-">(&gt;)</a> :: <a href="HPath.html#t:Path">Path</a> b -&gt; <a href="HPath.html#t:Path">Path</a> b -&gt; <a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-62-" class="selflink">#</a></p><p class="src"><a href="#v:-62--61-">(&gt;=)</a> :: <a href="HPath.html#t:Path">Path</a> b -&gt; <a href="HPath.html#t:Path">Path</a> b -&gt; <a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/Data-Bool.html#t:Bool">Bool</a> <a href="#v:-62--61-" class="selflink">#</a></p><p class="src"><a href="#v:max">max</a> :: <a href="HPath.html#t:Path">Path</a> b -&gt; <a href="HPath.html#t:Path">Path</a> b -&gt; <a href="HPath.html#t:Path">Path</a> b <a href="#v:max" class="selflink">#</a></p><p class="src"><a href="#v:min">min</a> :: <a href="HPath.html#t:Path">Path</a> b -&gt; <a href="HPath.html#t:Path">Path</a> b -&gt; <a href="HPath.html#t:Path">Path</a> b <a href="#v:min" class="selflink">#</a></p></div></div></td
2016-06-01 12:52:48 +00:00
</code></strong>Just &quot;/abc&quot;
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseAbs &quot;/&quot; :: Maybe (Path Abs)
</code></strong>Just &quot;/&quot;
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseAbs &quot;/abc/def&quot; :: Maybe (Path Abs)
</code></strong>Just &quot;/abc/def&quot;
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseAbs &quot;/abc/def/.///&quot; :: Maybe (Path Abs)
</code></strong>Just &quot;/abc/def/&quot;
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseAbs &quot;abc&quot; :: Maybe (Path Abs)
</code></strong>Nothing
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseAbs &quot;&quot; :: Maybe (Path Abs)
</code></strong>Nothing
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseAbs &quot;/abc/../foo&quot; :: Maybe (Path Abs)
</code></strong>Nothing
</pre></div></div><div class="top"><p class="src"><a id="v:parseFn" class="def">parseFn</a> :: MonadThrow m =&gt; <a href="https://hackage.haskell.org/package/bytestring-0.10.8.1/docs/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; m (<a href="HPath.html#t:Path">Path</a> <a href="HPath.html#t:Fn">Fn</a>) <a href="src/HPath.html#parseFn" class="link">Source</a> <a href="#v:parseFn" class="selflink">#</a></p><div class="doc"><p>Parses a filename. Filenames must not contain slashes.
Excludes <code><a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/Data-Function.html#v:.">.</a></code> and '..'.</p><p>Throws: <code><a href="HPath.html#t:PathParseException">PathParseException</a></code></p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseFn &quot;abc&quot; :: Maybe (Path Fn)
2016-06-01 12:52:48 +00:00
</code></strong>Just &quot;abc&quot;
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseFn &quot;...&quot; :: Maybe (Path Fn)
</code></strong>Just &quot;...&quot;
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseFn &quot;def/&quot; :: Maybe (Path Fn)
</code></strong>Nothing
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseFn &quot;abc/def&quot; :: Maybe (Path Fn)
</code></strong>Nothing
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseFn &quot;abc/def/.&quot; :: Maybe (Path Fn)
</code></strong>Nothing
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseFn &quot;/abc&quot; :: Maybe (Path Fn)
</code></strong>Nothing
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseFn &quot;&quot; :: Maybe (Path Fn)
</code></strong>Nothing
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseFn &quot;abc/../foo&quot; :: Maybe (Path Fn)
</code></strong>Nothing
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseFn &quot;.&quot; :: Maybe (Path Fn)
</code></strong>Nothing
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseFn &quot;..&quot; :: Maybe (Path Fn)
</code></strong>Nothing
</pre></div></div><div class="top"><p class="src"><a id="v:parseRel" class="def">parseRel</a> :: MonadThrow m =&gt; <a href="https://hackage.haskell.org/package/bytestring-0.10.8.1/docs/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; m (<a href="HPath.html#t:Path">Path</a> <a href="HPath.html#t:Rel">Rel</a>) <a href="src/HPath.html#parseRel" class="link">Source</a> <a href="#v:parseRel" class="selflink">#</a></p><div class="doc"><p>Get a location for a relative path. Produces a normalised
2016-06-01 12:52:48 +00:00
path.</p><p>Note that <code>filepath</code> may contain any number of <code>./</code> but may not consist
solely of <code>./</code>. It also may not contain a single <code>..</code> anywhere.</p><p>Throws: <code><a href="HPath.html#t:PathParseException">PathParseException</a></code></p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseRel &quot;abc&quot; :: Maybe (Path Rel)
</code></strong>Just &quot;abc&quot;
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseRel &quot;def/&quot; :: Maybe (Path Rel)
</code></strong>Just &quot;def/&quot;
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseRel &quot;abc/def&quot; :: Maybe (Path Rel)
</code></strong>Just &quot;abc/def&quot;
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseRel &quot;abc/def/.&quot; :: Maybe (Path Rel)
</code></strong>Just &quot;abc/def/&quot;
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseRel &quot;/abc&quot; :: Maybe (Path Rel)
</code></strong>Nothing
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseRel &quot;&quot; :: Maybe (Path Rel)
</code></strong>Nothing
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseRel &quot;abc/../foo&quot; :: Maybe (Path Rel)
</code></strong>Nothing
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseRel &quot;.&quot; :: Maybe (Path Rel)
</code></strong>Nothing
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseRel &quot;..&quot; :: Maybe (Path Rel)
</code></strong>Nothing
</pre></div></div><h1 id="g:4">Path Conversion</h1><div class="top"><p class="src"><a id="v:fromAbs" class="def">fromAbs</a> :: <a href="HPath.html#t:Path">Path</a> <a href="HPath.html#t:Abs">Abs</a> -&gt; <a href="https://hackage.haskell.org/package/bytestring-0.10.8.1/docs/Data-ByteString.html#t:ByteString">ByteString</a> <a href="src/HPath.html#fromAbs" class="link">Source</a> <a href="#v:fromAbs" class="selflink">#</a></p><div class="doc"><p>Convert an absolute Path to a ByteString type.</p></div></div><div class="top"><p class="src"><a id="v:fromRel" class="def">fromRel</a> :: <a href="HPath.html#t:RelC">RelC</a> r =&gt; <a href="HPath.html#t:Path">Path</a> r -&gt; <a href="https://hackage.haskell.org/package/bytestring-0.10.8.1/docs/Data-ByteString.html#t:ByteString">ByteString</a> <a href="src/HPath.html#fromRel" class="link">Source</a> <a href="#v:fromRel" class="selflink">#</a></p><div class="doc"><p>Convert a relative Path to a ByteString type.</p></div></div><div class="top"><p class="src"><a id="v:toFilePath" class="def">toFilePath</a> :: <a href="HPath.html#t:Path">Path</a> b -&gt; <a href="https://hackage.haskell.org/package/bytestring-0.10.8.1/docs/Data-ByteString.html#t:ByteString">ByteString</a> <a href="src/HPath.html#toFilePath" class="link">Source</a> <a href="#v:toFilePath" class="selflink">#</a></p><div class="doc"><p>Convert any Path to a ByteString type.</p></div></div><h1 id="g:5">Path Operations</h1><div class="top"><p class="src"><a id="v:-60--47--62-" class="def">(&lt;/&gt;)</a> :: <a href="HPath.html#t:RelC">RelC</a> r =&gt; <a href="HPath.html#t:Path">Path</a> b -&gt; <a href="HPath.html#t:Path">Path</a> r -&gt; <a href="HPath.html#t:Path">Path</a> b <a href="src/HPath.html#%3C%2F%3E" class="link">Source</a> <a href="#v:-60--47--62-" class="selflink">#</a></p><div class="doc"><p>Append two paths.</p><p>The second argument must always be a relative path, which ensures
2016-06-01 12:52:48 +00:00
that undefinable things like `&quot;<em>abc&quot; &lt;</em>&gt; &quot;/def&quot;` cannot happen.</p><p>Technically, the first argument can be a path that points to a non-directory,
because this library is IO-agnostic and makes no assumptions about
file types.</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>(MkPath &quot;/&quot;) &lt;/&gt; (MkPath &quot;file&quot; :: Path Rel)
</code></strong>&quot;/file&quot;
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>(MkPath &quot;/path/to&quot;) &lt;/&gt; (MkPath &quot;file&quot; :: Path Rel)
</code></strong>&quot;/path/to/file&quot;
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>(MkPath &quot;/&quot;) &lt;/&gt; (MkPath &quot;file/lal&quot; :: Path Rel)
</code></strong>&quot;/file/lal&quot;
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>(MkPath &quot;/&quot;) &lt;/&gt; (MkPath &quot;file/&quot; :: Path Rel)
</code></strong>&quot;/file/&quot;
</pre></div></div><div class="top"><p class="src"><a id="v:basename" class="def">basename</a> :: MonadThrow m =&gt; <a href="HPath.html#t:Path">Path</a> b -&gt; m (<a href="HPath.html#t:Path">Path</a> <a href="HPath.html#t:Fn">Fn</a>) <a href="src/HPath.html#basename" class="link">Source</a> <a href="#v:basename" class="selflink">#</a></p><div class="doc"><p>Extract the file part of a path.</p><p>The following properties hold:</p><pre>basename (p &lt;/&gt; a) == basename a</pre><p>Throws: <code><a href="HPath.html#t:PathException">PathException</a></code> if given the root path &quot;/&quot;</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>basename (MkPath &quot;/abc/def/dod&quot;) :: Maybe (Path Fn)
2016-06-01 12:52:48 +00:00
</code></strong>Just &quot;dod&quot;
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>basename (MkPath &quot;/&quot;) :: Maybe (Path Fn)
</code></strong>Nothing
</pre></div></div><div class="top"><p class="src"><a id="v:dirname" class="def">dirname</a> :: <a href="HPath.html#t:Path">Path</a> <a href="HPath.html#t:Abs">Abs</a> -&gt; <a href="HPath.html#t:Path">Path</a> <a href="HPath.html#t:Abs">Abs</a> <a href="src/HPath.html#dirname" class="link">Source</a> <a href="#v:dirname" class="selflink">#</a></p><div class="doc"><p>Extract the directory name of a path.</p><p>The following properties hold:</p><pre>dirname (p &lt;/&gt; a) == dirname p</pre><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>dirname (MkPath &quot;/abc/def/dod&quot;)
2016-06-01 12:52:48 +00:00
</code></strong>&quot;/abc/def&quot;
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>dirname (MkPath &quot;/&quot;)
</code></strong>&quot;/&quot;
</pre></div></div><div class="top"><p class="src"><a id="v:isParentOf" class="def">isParentOf</a> :: <a href="HPath.html#t:Path">Path</a> b -&gt; <a href="HPath.html#t:Path">Path</a> b -&gt; <a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/Data-Bool.html#t:Bool">Bool</a> <a href="src/HPath.html#isParentOf" class="link">Source</a> <a href="#v:isParentOf" class="selflink">#</a></p><div class="doc"><p>Is p a parent of the given location? Implemented in terms of
2016-06-01 12:52:48 +00:00
<code><a href="HPath.html#v:stripDir">stripDir</a></code>. The bases must match.</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>(MkPath &quot;/lal/lad&quot;) `isParentOf` (MkPath &quot;/lal/lad/fad&quot;)
</code></strong>True
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>(MkPath &quot;lal/lad&quot;) `isParentOf` (MkPath &quot;lal/lad/fad&quot;)
</code></strong>True
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>(MkPath &quot;/&quot;) `isParentOf` (MkPath &quot;/&quot;)
</code></strong>False
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>(MkPath &quot;/lal/lad/fad&quot;) `isParentOf` (MkPath &quot;/lal/lad&quot;)
</code></strong>False
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>(MkPath &quot;fad&quot;) `isParentOf` (MkPath &quot;fad&quot;)
</code></strong>False
</pre></div></div><div class="top"><p class="src"><a id="v:getAllParents" class="def">getAllParents</a> :: <a href="HPath.html#t:Path">Path</a> <a href="HPath.html#t:Abs">Abs</a> -&gt; [<a href="HPath.html#t:Path">Path</a> <a href="HPath.html#t:Abs">Abs</a>] <a href="src/HPath.html#getAllParents" class="link">Source</a> <a href="#v:getAllParents" class="selflink">#</a></p><div class="doc"><p>Get all parents of a path.</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>getAllParents (MkPath &quot;/abs/def/dod&quot;)
2016-06-01 12:52:48 +00:00
</code></strong>[&quot;/abs/def&quot;,&quot;/abs&quot;,&quot;/&quot;]
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>getAllParents (MkPath &quot;/&quot;)
</code></strong>[]
</pre></div></div><div class="top"><p class="src"><a id="v:stripDir" class="def">stripDir</a> :: MonadThrow m =&gt; <a href="HPath.html#t:Path">Path</a> b -&gt; <a href="HPath.html#t:Path">Path</a> b -&gt; m (<a href="HPath.html#t:Path">Path</a> <a href="HPath.html#t:Rel">Rel</a>) <a href="src/HPath.html#stripDir" class="link">Source</a> <a href="#v:stripDir" class="selflink">#</a></p><div class="doc"><p>Strip directory from path, making it relative to that directory.
2016-06-01 12:52:48 +00:00
Throws <code>Couldn'tStripPrefixDir</code> if directory is not a parent of the path.</p><p>The bases must match.</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>(MkPath &quot;/lal/lad&quot;) `stripDir` (MkPath &quot;/lal/lad/fad&quot;) :: Maybe (Path Rel)
</code></strong>Just &quot;fad&quot;
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>(MkPath &quot;lal/lad&quot;) `stripDir` (MkPath &quot;lal/lad/fad&quot;) :: Maybe (Path Rel)
</code></strong>Just &quot;fad&quot;
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>(MkPath &quot;/&quot;) `stripDir` (MkPath &quot;/&quot;) :: Maybe (Path Rel)
</code></strong>Nothing
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>(MkPath &quot;/lal/lad/fad&quot;) `stripDir` (MkPath &quot;/lal/lad&quot;) :: Maybe (Path Rel)
</code></strong>Nothing
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>(MkPath &quot;fad&quot;) `stripDir` (MkPath &quot;fad&quot;) :: Maybe (Path Rel)
</code></strong>Nothing
</pre></div></div><h1 id="g:6">Path IO helpers</h1><div class="top"><p class="src"><a id="v:withAbsPath" class="def">withAbsPath</a> :: <a href="HPath.html#t:Path">Path</a> <a href="HPath.html#t:Abs">Abs</a> -&gt; (<a href="https://hackage.haskell.org/package/bytestring-0.10.8.1/docs/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; <a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/System-IO.html#t:IO">IO</a> a) -&gt; <a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/System-IO.html#t:IO">IO</a> a <a href="src/HPath.html#withAbsPath" class="link">Source</a> <a href="#v:withAbsPath" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:withRelPath" class="def">withRelPath</a> :: <a href="HPath.html#t:Path">Path</a> <a href="HPath.html#t:Rel">Rel</a> -&gt; (<a href="https://hackage.haskell.org/package/bytestring-0.10.8.1/docs/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; <a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/System-IO.html#t:IO">IO</a> a) -&gt; <a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/System-IO.html#t:IO">IO</a> a <a href="src/HPath.html#withRelPath" class="link">Source</a> <a href="#v:withRelPath" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:withFnPath" class="def">withFnPath</a> :: <a href="HPath.html#t:Path">Path</a> <a href="HPath.html#t:Fn">Fn</a> -&gt; (<a href="https://hackage.haskell.org/package/bytestring-0.10.8.1/docs/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; <a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/System-IO.html#t:IO">IO</a> a) -&gt; <a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/System-IO.html#t:IO">IO</a> a <a href="src/HPath.html#withFnPath" class="link">Source</a> <a href="#v:withFnPath" class="selflink">#</a></p></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>