From cf7139b381ab2b17ea5d78eb555540b5880cf144 Mon Sep 17 00:00:00 2001 From: Chris Done Date: Fri, 8 May 2015 14:18:03 +0200 Subject: [PATCH] Add some commentary --- src/Path/Internal.hs | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/Path/Internal.hs b/src/Path/Internal.hs index b537581..56971d2 100644 --- a/src/Path/Internal.hs +++ b/src/Path/Internal.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} @@ -12,8 +13,37 @@ import Data.Data import GHC.Generics -- | Path of some base and type. +-- +-- Internally is a string. The string can be of two formats only: +-- +-- 1. File format: @file.txt@, @foo\/bar.txt@, @\/foo\/bar.txt@ +-- 2. Directory format: @foo\/@, @\/foo\/bar\/@ +-- +-- All directories end in a trailing separator. There are no duplicate +-- path separators @\/\/@, no @..@, no @.\/@, no @~\/@, etc. newtype Path b t = Path FilePath - deriving (Eq,Ord,Typeable,Data,Generic) + deriving (Typeable,Generic) +-- | String equality. +-- +-- The following property holds: +-- +-- @show x == show y ≡ x == y@ +instance Eq (Path b t) where + (==) (Path x) (Path y) = x == y + +-- | String ordering. +-- +-- The following property holds: +-- +-- @show x \`compare\` show y ≡ x \`compare\` y@ +instance Ord (Path b t) where + compare (Path x) (Path y) = compare x y + +-- | Same as 'Path.toFilePath'. +-- +-- The following property holds: +-- +-- @x == y ≡ show x == show y@ instance Show (Path b t) where show (Path x) = show x