monoid-subclasses-0.4.0.3: Subclasses of Monoid

Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Monoid.Instances.Positioned

Description

This module defines two monoid transformer data types, OffsetPositioned and LinePositioned. Both data types add a notion of the current position to their base monoid. In case of OffsetPositioned, the current position is a simple integer offset from the beginning of the monoid, and it can be applied to any StableFactorialMonoid. The base monoid of LinePositioned must be a TextualMonoid, but for the price it will keep track of the current line and column numbers as well.

All positions are zero-based:

> let p = pure "abcd\nefgh\nijkl\nmnop\n" :: LinePositioned String
> p
Line 0, column 0: "abcd\nefgh\nijkl\nmnop\n"
> Data.Monoid.Factorial.drop 13 p
Line 2, column 3: "l\nmnop\n"

Synopsis

Documentation

extract :: Positioned p => p a -> a Source

position :: Positioned p => p a -> Int Source

line :: LinePositioned m -> Int Source

the current line

column :: LinePositioned m -> Int Source

the current column