hpath/src/HPath-Internal.html

63 lines
7.8 KiB
HTML
Raw Normal View History

2016-06-01 12:52:48 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ -->
<title>src/HPath/Internal.hs</title>
<link type='text/css' rel='stylesheet' href='hscolour.css' />
</head>
<body>
<pre><a name="line-1"></a><span class='hs-comment'>{-# LANGUAGE DeriveDataTypeable #-}</span>
<a name="line-2"></a>
<a name="line-3"></a><span class='hs-comment'>-- | Internal types and functions.</span>
<a name="line-4"></a>
<a name="line-5"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>HPath</span><span class='hs-varop'>.</span><span class='hs-conid'>Internal</span>
<a name="line-6"></a> <span class='hs-layout'>(</span><span class='hs-conid'>Path</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-7"></a> <span class='hs-keyword'>where</span>
<a name="line-8"></a>
<a name="line-9"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>DeepSeq</span> <span class='hs-layout'>(</span><span class='hs-conid'>NFData</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-10"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>ByteString</span> <span class='hs-layout'>(</span><span class='hs-conid'>ByteString</span><span class='hs-layout'>)</span>
<a name="line-11"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Data</span>
<a name="line-12"></a>
<a name="line-13"></a><a name="Path"></a><span class='hs-comment'>-- | Path of some base and type.</span>
<a name="line-14"></a><a name="Path"></a><span class='hs-comment'>--</span>
<a name="line-15"></a><a name="Path"></a><span class='hs-comment'>-- Internally is a ByteString. The ByteString can be of two formats only:</span>
<a name="line-16"></a><a name="Path"></a><span class='hs-comment'>--</span>
<a name="line-17"></a><a name="Path"></a><span class='hs-comment'>-- 1. without trailing path separator: @file.txt@, @foo\/bar.txt@, @\/foo\/bar.txt@</span>
<a name="line-18"></a><a name="Path"></a><span class='hs-comment'>-- 2. with trailing path separator: @foo\/@, @\/foo\/bar\/@</span>
<a name="line-19"></a><a name="Path"></a><span class='hs-comment'>--</span>
<a name="line-20"></a><a name="Path"></a><span class='hs-comment'>-- There are no duplicate</span>
<a name="line-21"></a><a name="Path"></a><span class='hs-comment'>-- path separators @\/\/@, no @..@, no @.\/@, no @~\/@, etc.</span>
<a name="line-22"></a><a name="Path"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>Path</span> <span class='hs-varid'>b</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>MkPath</span> <span class='hs-conid'>ByteString</span>
<a name="line-23"></a> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span><span class='hs-conid'>Typeable</span><span class='hs-layout'>)</span>
<a name="line-24"></a>
<a name="line-25"></a><a name="instance%20Eq%20(Path%20b)"></a><span class='hs-comment'>-- | ByteString equality.</span>
<a name="line-26"></a><a name="instance%20Eq%20(Path%20b)"></a><span class='hs-comment'>--</span>
<a name="line-27"></a><a name="instance%20Eq%20(Path%20b)"></a><span class='hs-comment'>-- The following property holds:</span>
<a name="line-28"></a><a name="instance%20Eq%20(Path%20b)"></a><span class='hs-comment'>--</span>
<a name="line-29"></a><a name="instance%20Eq%20(Path%20b)"></a><span class='hs-comment'>-- @show x == show y ≡ x == y@</span>
<a name="line-30"></a><a name="instance%20Eq%20(Path%20b)"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>Eq</span> <span class='hs-layout'>(</span><span class='hs-conid'>Path</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-31"></a> <span class='hs-layout'>(</span><span class='hs-varop'>==</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>y</span>
<a name="line-32"></a>
<a name="line-33"></a><a name="instance%20Ord%20(Path%20b)"></a><span class='hs-comment'>-- | ByteString ordering.</span>
<a name="line-34"></a><a name="instance%20Ord%20(Path%20b)"></a><span class='hs-comment'>--</span>
<a name="line-35"></a><a name="instance%20Ord%20(Path%20b)"></a><span class='hs-comment'>-- The following property holds:</span>
<a name="line-36"></a><a name="instance%20Ord%20(Path%20b)"></a><span class='hs-comment'>--</span>
<a name="line-37"></a><a name="instance%20Ord%20(Path%20b)"></a><span class='hs-comment'>-- @show x \`compare\` show y ≡ x \`compare\` y@</span>
<a name="line-38"></a><a name="instance%20Ord%20(Path%20b)"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>Ord</span> <span class='hs-layout'>(</span><span class='hs-conid'>Path</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-39"></a> <span class='hs-varid'>compare</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>compare</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span>
<a name="line-40"></a>
<a name="line-41"></a><a name="instance%20Show%20(Path%20b)"></a><span class='hs-comment'>-- | Same as 'HPath.toFilePath'.</span>
<a name="line-42"></a><a name="instance%20Show%20(Path%20b)"></a><span class='hs-comment'>--</span>
<a name="line-43"></a><a name="instance%20Show%20(Path%20b)"></a><span class='hs-comment'>-- The following property holds:</span>
<a name="line-44"></a><a name="instance%20Show%20(Path%20b)"></a><span class='hs-comment'>--</span>
<a name="line-45"></a><a name="instance%20Show%20(Path%20b)"></a><span class='hs-comment'>-- @x == y ≡ show x == show y@</span>
<a name="line-46"></a><a name="instance%20Show%20(Path%20b)"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>Show</span> <span class='hs-layout'>(</span><span class='hs-conid'>Path</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-47"></a> <span class='hs-varid'>show</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>show</span> <span class='hs-varid'>x</span>
<a name="line-48"></a>
<a name="line-49"></a><a name="instance%20NFData%20(Path%20b)"></a><span class='hs-keyword'>instance</span> <span class='hs-conid'>NFData</span> <span class='hs-layout'>(</span><span class='hs-conid'>Path</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-50"></a> <span class='hs-varid'>rnf</span> <span class='hs-layout'>(</span><span class='hs-conid'>MkPath</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>rnf</span> <span class='hs-varid'>x</span>
<a name="line-51"></a>
</pre></body>
</html>