text-zipper-monad-0.2.0.0: Monadic interface to the text-zipper package

Copyright(c) Kwang Yul Seo 2016
LicenseBSD-style (see the file LICENSE)
Maintainerkwangyul.seo@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Data.Text.Zipper.Edit

Contents

Description

This module provides a monadic interface to TextZipper.

Synopsis

Documentation

type Edit t a = EditT t Identity a Source #

An edit monad

data EditT t m a Source #

An edit transformer monad

Instances

Monad m => MonadState (TextZipper t) (EditT t m) Source # 

Methods

get :: EditT t m (TextZipper t) #

put :: TextZipper t -> EditT t m () #

state :: (TextZipper t -> (a, TextZipper t)) -> EditT t m a #

Monad m => Monad (EditT t m) Source # 

Methods

(>>=) :: EditT t m a -> (a -> EditT t m b) -> EditT t m b #

(>>) :: EditT t m a -> EditT t m b -> EditT t m b #

return :: a -> EditT t m a #

fail :: String -> EditT t m a #

Functor m => Functor (EditT t m) Source # 

Methods

fmap :: (a -> b) -> EditT t m a -> EditT t m b #

(<$) :: a -> EditT t m b -> EditT t m a #

Monad m => Applicative (EditT t m) Source # 

Methods

pure :: a -> EditT t m a #

(<*>) :: EditT t m (a -> b) -> EditT t m a -> EditT t m b #

(*>) :: EditT t m a -> EditT t m b -> EditT t m b #

(<*) :: EditT t m a -> EditT t m b -> EditT t m a #

execEditT :: (Monoid t, Monad m) => EditT t m a -> TextZipper t -> m (TextZipper t) Source #

Execute the edit session with the given zipper and return the modified zipper.

execEdit :: Monoid t => Edit t a -> TextZipper t -> TextZipper t Source #

Execute the edit session with the given zipper and return the modified zipper.

Extraction functions

clearZipper :: (Monoid t, Monad m) => EditT t m () Source #

Empty a zipper.

getText :: (Monoid t, Monad m) => EditT t m [t] Source #

Get the text contents of the zipper.

currentLine :: (Monoid t, Monad m) => EditT t m t Source #

The line of text on which the zipper's cursor currently resides.

cursorPosition :: (Monoid t, Monad m) => EditT t m (Int, Int) Source #

Get the cursor position of the zipper; returns (row, col). row ranges from [0..num_rows-1] inclusive; col ranges from [0..length of current line] inclusive. Column values equal to line width indicate a cursor that is just past the end of a line of text.

lineLengths :: (Monoid t, Monad m) => EditT t m [Int] Source #

Return the lengths of the lines in the zipper.

getLineLimit :: (Monoid t, Monad m) => EditT t m (Maybe Int) Source #

Get the line limit, if any, for a zipper.

Navigation and editing functions

moveCursor :: (Monoid t, Monad m) => (Int, Int) -> EditT t m () Source #

Move the cursor to the specified row and column. Invalid cursor positions will be ignored. Valid cursor positions range as described for cursorPosition.

insertChar :: (Monoid t, Monad m) => Char -> EditT t m () Source #

Insert a character at the current cursor position. Move the cursor one position to the right.

breakLine :: (Monoid t, Monad m) => EditT t m () Source #

Insert a line break at the current cursor position.

killToBOL :: (Monoid t, Monad m) => EditT t m () Source #

Remove all text from the cursor position to the beginning of the current line.

killToEOL :: (Monoid t, Monad m) => EditT t m () Source #

Remove all text from the cursor position to the end of the current line. If the cursor is at the beginning of a line and the line is empty, the entire line will be removed.

gotoEOL :: (Monoid t, Monad m) => EditT t m () Source #

Move the cursor to the end of the current line.

gotoBOL :: (Monoid t, Monad m) => EditT t m () Source #

Move the cursor to the beginning of the current line.

deletePrevChar :: (Eq t, Monoid t, Monad m) => EditT t m () Source #

Delete the character preceding the cursor position, and move the cursor backwards by one character.

deleteChar :: (Monoid t, Monad m) => EditT t m () Source #

Delete the character at the cursor position. Leaves the cursor position unchanged. If the cursor is at the end of a line of text, this combines the line with the line below.

moveRight :: (Monoid t, Monad m) => EditT t m () Source #

Move the cursor right by one position. If the cursor is at the end of a line, the cursor is moved to the first position of the following line (if any).

moveLeft :: (Monoid t, Monad m) => EditT t m () Source #

Move the cursor left by one position. If the cursor is at the beginning of a line, the cursor is moved to the last position of the preceding line (if any).

moveUp :: (Monoid t, Monad m) => EditT t m () Source #

Move the cursor up by one row. If there no are rows above the current one, move to the first position of the current row. If the row above is shorter, move to the end of that row.

moveDown :: (Monoid t, Monad m) => EditT t m () Source #

Move the cursor down by one row. If there are no rows below the current one, move to the last position of the current row. If the row below is shorter, move to the end of that row.