hpath/HPath.html
travis-ci 2eed840024 Lastest docs updated
travis build: 68
commit: c5bcb90b65
auto-pushed to gh-pages
2016-06-05 13:05:20 +00:00

105 lines
30 KiB
HTML

<!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 type="text/javascript">//<![CDATA[
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> :: <a href="https://hackage.haskell.org/package/bytestring-0.10.6.0/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.6.0/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.6.0/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.6.0/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.6.0/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.6.0/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.6.0/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="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</li><li class="src short"><a href="#v:basename">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>)</li><li class="src short"><a href="#v:dirname">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></li><li class="src short"><a href="#v:isParentOf">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.8.1.0/docs/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:getAllParents">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>]</li><li class="src short"><a href="#v:stripDir">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>)</li><li class="src short"><a href="#v:withAbsPath">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.6.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; <a href="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> a) -&gt; <a href="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> a</li><li class="src short"><a href="#v:withRelPath">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.6.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; <a href="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> a) -&gt; <a href="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> a</li><li class="src short"><a href="#v:withFnPath">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.6.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; <a href="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> a) -&gt; <a href="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> a</li></ul></div><div id="interface"><h1 id="g:1">Types</h1><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:Abs" class="def">Abs</a> <a href="src/HPath.html#Abs" class="link">Source</a></p><div class="doc"><p>An absolute path.</p></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:Path" class="def">Path</a> b <a href="src/HPath-Internal.html#Path" class="link">Source</a></p><div class="doc"><p>Path of some base and type.</p><p>Internally is a ByteString. The ByteString can be of two formats only:</p><ol><li>without trailing path separator: <code>file.txt</code>, <code>foo/bar.txt</code>, <code>/foo/bar.txt</code></li><li>with trailing path separator: <code>foo/</code>, <code>/foo/bar/</code></li></ol><p>There are no duplicate
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"><a href="https://hackage.haskell.org/package/base-4.8.1.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></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 class="src clearfix"><span class="inst-left"><a href="https://hackage.haskell.org/package/base-4.8.1.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></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 class="src clearfix"><span class="inst-left"><a href="https://hackage.haskell.org/package/base-4.8.1.0/docs/Text-Show.html#t:Show">Show</a> (<a href="HPath.html#t:Path">Path</a> b)</span> <a href="src/HPath-Internal.html#line-46" class="link">Source</a></td><td class="doc"><p>Same as <code><a href="HPath.html#v:toFilePath">toFilePath</a></code>.</p><p>The following property holds:</p><pre>x == y &#8801; show x == show y</pre></td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="https://hackage.haskell.org/package/deepseq-1.4.1.1/docs/Control-DeepSeq.html#t:NFData">NFData</a> (<a href="HPath.html#t:Path">Path</a> b)</span> <a href="src/HPath-Internal.html#line-49" class="link">Source</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:Rel" class="def">Rel</a> <a href="src/HPath.html#Rel" class="link">Source</a></p><div class="doc"><p>A relative path; one without a root.</p></div><div class="subs instances"><p id="control.i:Rel" class="caption collapser" onclick="toggleSection('i:Rel')">Instances</p><div id="section.i:Rel" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><a href="HPath.html#t:RelC">RelC</a> <a href="HPath.html#t:Rel">Rel</a></span> <a href="src/HPath.html#line-95" class="link">Source</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:Fn" class="def">Fn</a> <a href="src/HPath.html#Fn" class="link">Source</a></p><div class="doc"><p>A filename, without any <code><a href="https://hackage.haskell.org/package/base-4.8.1.0/docs/Prelude.html#v:-47-">/</a></code>.</p></div><div class="subs instances"><p id="control.i:Fn" class="caption collapser" onclick="toggleSection('i:Fn')">Instances</p><div id="section.i:Fn" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><a href="HPath.html#t:RelC">RelC</a> <a href="HPath.html#t:Fn">Fn</a></span> <a href="src/HPath.html#line-96" class="link">Source</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:PathParseException" class="def">PathParseException</a> <a href="src/HPath.html#PathParseException" class="link">Source</a></p><div class="doc"><p>Exception when parsing a location.</p></div><div class="subs instances"><p id="control.i:PathParseException" class="caption collapser" onclick="toggleSection('i:PathParseException')">Instances</p><div id="section.i:PathParseException" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><a href="https://hackage.haskell.org/package/base-4.8.1.0/docs/Text-Show.html#t:Show">Show</a> <a href="HPath.html#t:PathParseException">PathParseException</a></span> <a href="src/HPath.html#line-86" class="link">Source</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="https://hackage.haskell.org/package/base-4.8.1.0/docs/Control-Exception-Base.html#t:Exception">Exception</a> <a href="HPath.html#t:PathParseException">PathParseException</a></span> <a href="src/HPath.html#line-87" class="link">Source</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:PathException" class="def">PathException</a> <a href="src/HPath.html#PathException" class="link">Source</a></p><div class="subs instances"><p id="control.i:PathException" class="caption collapser" onclick="toggleSection('i:PathException')">Instances</p><div id="section.i:PathException" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><a href="https://hackage.haskell.org/package/base-4.8.1.0/docs/Text-Show.html#t:Show">Show</a> <a href="HPath.html#t:PathException">PathException</a></span> <a href="src/HPath.html#line-90" class="link">Source</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="https://hackage.haskell.org/package/base-4.8.1.0/docs/Control-Exception-Base.html#t:Exception">Exception</a> <a href="HPath.html#t:PathException">PathException</a></span> <a href="src/HPath.html#line-91" class="link">Source</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">class</span> <a name="t:RelC" class="def">RelC</a> m <a href="src/HPath.html#RelC" class="link">Source</a></p><div class="subs instances"><p id="control.i:RelC" class="caption collapser" onclick="toggleSection('i:RelC')">Instances</p><div id="section.i:RelC" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><a href="HPath.html#t:RelC">RelC</a> <a href="HPath.html#t:Fn">Fn</a></span> <a href="src/HPath.html#line-96" class="link">Source</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="HPath.html#t:RelC">RelC</a> <a href="HPath.html#t:Rel">Rel</a></span> <a href="src/HPath.html#line-95" class="link">Source</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><h1 id="g:2">PatternSynonyms/ViewPatterns</h1><div class="top"><p class="src"><span class="keyword">pattern</span> <a name="v:Path" class="def">Path</a> :: <a href="https://hackage.haskell.org/package/bytestring-0.10.6.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; <a href="HPath.html#t:Path">Path</a> a <a href="src/HPath.html#Path" class="link">Source</a></p></div><h1 id="g:3">Path Parsing</h1><div class="top"><p class="src"><a name="v:parseAbs" class="def">parseAbs</a> :: MonadThrow m =&gt; <a href="https://hackage.haskell.org/package/bytestring-0.10.6.0/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>) <a href="src/HPath.html#parseAbs" class="link">Source</a></p><div class="doc"><p>Get a location for an absolute path. Produces a normalised path.</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>parseAbs &quot;/abc&quot; :: Maybe (Path Abs)
</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 name="v:parseFn" class="def">parseFn</a> :: MonadThrow m =&gt; <a href="https://hackage.haskell.org/package/bytestring-0.10.6.0/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></p><div class="doc"><p>Parses a filename. Filenames must not contain slashes.
Excludes <code><a href="https://hackage.haskell.org/package/base-4.8.1.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)
</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 name="v:parseRel" class="def">parseRel</a> :: MonadThrow m =&gt; <a href="https://hackage.haskell.org/package/bytestring-0.10.6.0/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></p><div class="doc"><p>Get a location for a relative path. Produces a normalised
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 name="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.6.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> <a href="src/HPath.html#fromAbs" class="link">Source</a></p><div class="doc"><p>Convert an absolute Path to a ByteString type.</p></div></div><div class="top"><p class="src"><a name="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.6.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> <a href="src/HPath.html#fromRel" class="link">Source</a></p><div class="doc"><p>Convert a relative Path to a ByteString type.</p></div></div><div class="top"><p class="src"><a name="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.6.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> <a href="src/HPath.html#toFilePath" class="link">Source</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 name="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></p><div class="doc"><p>Append two paths.</p><p>The second argument must always be a relative path, which ensures
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 name="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></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)
</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 name="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></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;)
</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 name="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.8.1.0/docs/Data-Bool.html#t:Bool">Bool</a> <a href="src/HPath.html#isParentOf" class="link">Source</a></p><div class="doc"><p>Is p a parent of the given location? Implemented in terms of
<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 name="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></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;)
</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 name="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></p><div class="doc"><p>Strip directory from path, making it relative to that directory.
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 name="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.6.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; <a href="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> a) -&gt; <a href="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> a <a href="src/HPath.html#withAbsPath" class="link">Source</a></p></div><div class="top"><p class="src"><a name="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.6.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; <a href="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> a) -&gt; <a href="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> a <a href="src/HPath.html#withRelPath" class="link">Source</a></p></div><div class="top"><p class="src"><a name="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.6.0/docs/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; <a href="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> a) -&gt; <a href="https://hackage.haskell.org/package/base-4.8.1.0/docs/System-IO.html#t:IO">IO</a> a <a href="src/HPath.html#withFnPath" class="link">Source</a></p></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.16.1</p></div></body></html>