Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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"
- data OffsetPositioned m
- data LinePositioned m
- extract :: Positioned p => p a -> a
- position :: Positioned p => p a -> Int
- line :: LinePositioned m -> Int
- column :: LinePositioned m -> Int
Documentation
data OffsetPositioned m Source
Functor OffsetPositioned | |
Applicative OffsetPositioned | |
Eq m => Eq (OffsetPositioned m) | |
Ord m => Ord (OffsetPositioned m) | |
Show m => Show (OffsetPositioned m) | |
IsString m => IsString (OffsetPositioned m) | |
StableFactorialMonoid m => Monoid (OffsetPositioned m) | |
(StableFactorialMonoid m, PositiveMonoid m) => PositiveMonoid (OffsetPositioned m) | |
(StableFactorialMonoid m, MonoidNull m) => MonoidNull (OffsetPositioned m) | |
StableFactorialMonoid m => StableFactorialMonoid (OffsetPositioned m) | |
StableFactorialMonoid m => FactorialMonoid (OffsetPositioned m) | |
(StableFactorialMonoid m, RightGCDMonoid m) => RightGCDMonoid (OffsetPositioned m) | |
(StableFactorialMonoid m, LeftGCDMonoid m) => LeftGCDMonoid (OffsetPositioned m) | |
(StableFactorialMonoid m, RightReductiveMonoid m) => RightReductiveMonoid (OffsetPositioned m) | |
(StableFactorialMonoid m, LeftReductiveMonoid m) => LeftReductiveMonoid (OffsetPositioned m) | |
(StableFactorialMonoid m, TextualMonoid m) => TextualMonoid (OffsetPositioned m) |
data LinePositioned m Source
line :: LinePositioned m -> Int Source
the current line
column :: LinePositioned m -> Int Source
the current column