newline: newline specifications as values

[ bsd3, library, text ] [ Propose Tags ]

Defines a Newline data type, which is essentially a non-empty string, but with the intention of encoding a family of algorithms for the detection and manipulation of lines of text. In addition, a number of pattern synonyms are also provided, which offer a more self-documenting interface for specifying newlines.

Algorithms to split and merge text by line are also provided. These are generalizations of Prelude's line/unline functions. They are provided with Newline values to specify their exact behavior.

At the moment, little effort has been made to optimize the general line splitting algorithm, and many convenience functions are missing. This is because such improvements are premature for my personal case, but feel free to submit a PR for either. I'll want to make this package a central location for these tasks.

This package also contains algorithms to map lines into byte ranges for a file. There is also an associated file format to serialize this data. See the Text.Newline.LineMap module for this feature.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.0.1.0, 0.0.2.0, 0.0.2.1
Change log CHANGELOG.md
Dependencies base (>=4.11.1 && <4.17), bytestring (>=0.11 && <0.12), text (>=2.0 && <2.1) [details]
License BSD-3-Clause
Copyright 2023 Marseille Bouchard
Author Marseille Bouchard
Maintainer zankoku.okuno@gmail.com
Category Text
Home page https://github.com/edemko/hs-newline
Bug tracker https://github.com/edemko/hs-newline/issues
Source repo head: git clone https://github.com/edemko/hs-newline
Uploaded by edemko at 2023-03-05T22:44:38Z
Distributions
Downloads 115 total (4 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for newline-0.0.2.1

[back to package description]

newline

Hackage Github

Defines a Newline data type, which is essentially a non-empty string, but with the intention of encoding a family of algorithms for the detection and manipulation of lines of text. In addition, a number of pattern synonyms are also provided, which offer a more self-documenting interface for specifying newlines.

Algorithms to split and merge text by line are also provided. These are generalizations of Prelude's line/unline functions. They are provided with Newline values to specify their exact behavior.

At the moment, little effort has been made to optimize the general line splitting algorithm, and many convenience functions are missing. This is because such improvements are premature for my personal case, but feel free to submit a PR for either. I'll want to make this package a central location for these tasks.

Line Maps

This package also contains algorithms to map lines into byte ranges for a file. See the Text.Newline.LineMap module. We currently only support Unix line endings, but if I don't change the algorithm, the byte map should suffice for DOS line endings as well.

There is an associated file format to serialize this data. It is simply a three-colum CSV with header row. The columns are offset, length, and terminator, as above. Offset and length are decimal-encoded unsigned integers. The terminator column must hold one of the following strings:

  • @unix@ for LF (ASCII 0x0A),
  • @dos@ for CRLF (ASCOO 0x0D 0x0A) (WARNING: unimplemented),
  • @eof@ for end of file/input.