@@ -101,14 +101,34 @@ allowExisting openMode = case openMode of
101101-------------------------------------------------------------------------------}
102102
103103-- | A relative path.
104+ --
105+ -- === Invariant
106+ --
107+ -- The user of this library is tasked with picking sensible names of
108+ -- directories/files on a path. Amongst others, the following should hold:
109+ --
110+ -- * Names are non-empty
111+ --
112+ -- * Names are monotonic, i.e., they are not equal to @..@
113+ --
114+ -- * Names should not contain path separators or drive letters
115+ --
116+ -- In particular, names that satisfy these invariants should result in an
117+ -- 'FsPath' that remains relative to the HasFS instance root. For example, an
118+ -- @'FsPath' ["/"]@ would try to access the root folder, which is most likely
119+ -- outside of the scope of the HasFS instance.
120+ --
121+ -- \"@..@\" should not be used because @fs-sim@ will not be able to follow these
122+ -- types of back-links. @fs-sim@ will interpret \"@..@\" as a directory name
123+ -- instead.
104124newtype FsPath = UnsafeFsPath { fsPathToList :: [Strict. Text ] }
105125 deriving (Eq , Ord , Generic )
106126 deriving newtype NFData
107127
108128-- | Create a path from a list of directory/file names. All of the names should
109129-- be non-empty.
110130fsPathFromList :: [Strict. Text ] -> FsPath
111- fsPathFromList xs = assert ( not ( any Strict. null xs)) $ UnsafeFsPath (force xs)
131+ fsPathFromList xs = UnsafeFsPath (force xs)
112132
113133instance Show FsPath where
114134 show = intercalate " /" . map Strict. unpack . fsPathToList
0 commit comments