require-0.4.10: Scrap your qualified import clutter
Safe HaskellNone
LanguageHaskell2010

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

Documentation

newtype Name Source #

Wraps the name of a file as given by the user. Usually this corresponds to the file's path.

Constructors

Name Text 

data Input Source #

Associates a file's contents with the path from which it was read.

Constructors

Input 

newtype LineNumber Source #

A type-safe wrapper for line numbers.

Constructors

LineNumber Int 

data LineTag Source #

Identifies a specific line in a file.

Constructors

LineTag !Name !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.

read :: Name -> IO Input Source #

read name reads the contents of the file identified by name.

writeLines :: Name -> [Text] -> IO () Source #

write name lines writes all every line in lines to the file identified by name and appends a newline.

inputLines :: Input -> [(LineTag, Text)] Source #

Splits the input into lines and annotates each with a LineTag.

nameToPath :: Name -> FilePath Source #

Returns the FilePath corresponding a given Name.