Safe Haskell | None |
---|---|
Language | Haskell2010 |
Require.File
Description
This module contains functions for file handling. The names of the functions and data types are chosen in a way to suggest a qualified import.
import qualified Require.File as File
Synopsis
- newtype Name = Name Text
- data Input = Input {
- inputName :: Name
- inputContent :: Text
- newtype LineNumber = LineNumber Int
- data LineTag = LineTag !Name !LineNumber
- initialLineTag :: Input -> LineTag
- advanceLineTag :: LineTag -> LineTag
- read :: Name -> IO Input
- writeLines :: Name -> [Text] -> IO ()
- inputLines :: Input -> [(LineTag, Text)]
- nameToPath :: Name -> FilePath
Documentation
Wraps the name of a file as given by the user. Usually this corresponds to the file's path.
Associates a file's contents with the path from which it was read.
Constructors
Input | |
Fields
|
newtype LineNumber Source #
A type-safe wrapper for line numbers.
Constructors
LineNumber Int |
Instances
Enum LineNumber Source # | |
Defined in Require.File Methods succ :: LineNumber -> LineNumber # pred :: LineNumber -> LineNumber # toEnum :: Int -> LineNumber # fromEnum :: LineNumber -> Int # enumFrom :: LineNumber -> [LineNumber] # enumFromThen :: LineNumber -> LineNumber -> [LineNumber] # enumFromTo :: LineNumber -> LineNumber -> [LineNumber] # enumFromThenTo :: LineNumber -> LineNumber -> LineNumber -> [LineNumber] # |
initialLineTag :: Input -> LineTag Source #
Returns the LineTag
referencing the first line in a given FileInput
.
Note that the tag's line number is 1-based, which fits well with how GHC
understands {-# LINE ... #-}
pragmas.
advanceLineTag :: LineTag -> LineTag Source #
Returns a line tag from the same file but referencing the next line.
writeLines :: Name -> [Text] -> IO () Source #
write name lines
writes all every line in lines
to the file identified
by name
and appends a newline.