hsdev-0.1.3.4: Haskell development library and tool with support of autocompletion, symbol info, go to declaration, find references etc.

Safe HaskellNone
LanguageHaskell98

Data.Mark

Contents

Synopsis

Documentation

data Point Source

Point at text: line and column

Constructors

Point 

Fields

pointLine :: Int
 
pointColumn :: Int
 

(.-.) :: Point -> Point -> Point Source

Distance between points is measured in lines and columns. And it is defined, that distance between point at l:c and point (l + 1):0 is one line no matter c is because we need to go to new line to reach destination point Columns are taken into account only if points are on the same line pt .-. base is distance from base to pt Distance can't be less then zero lines and columns

(.+.) :: Point -> Point -> Point Source

Opposite to ".-.", (pt .-. base) .+. base = pt

linesSize :: Int -> Point Source

Distance in n lines

stringSize :: Int -> Point Source

Distance in n chars within one line

data Region Source

Region from Point to Point

Constructors

Region 

regionLines :: Region -> Int Source

Region height in lines. Any Region at least of one line height

line :: Int -> Region Source

n'th line region, starts at the beginning of line and ends on the next line

region :: Point -> Point -> Region Source

Make region

regionSize :: Point -> Size -> Region Source

Make region from starting point and its size

at :: Editable a => Contents a -> Region -> Contents a Source

Get contents at specified region

Mappings

newtype Map Source

Main idea is that there are only two basic actions , that chances regions: inserting and cutting When something is cutted out or inserted in, region positions must be updated All editings can be represented as many cuts and inserts, so we can combine them to get function which maps source regions to regions on updated data Because insert is dual to cut (and therefore composes iso), we can also get function to map regions back Combining this functions while edit, we get function, that maps regions from source data to edited one To get back function, we must also combine opposite actions, or we can represent actions as isomorphisms Same idea goes for modifying contents, represent each action as isomorphism and combine them together

Constructors

Map 

Instances

apply :: Map -> Region -> Region Source

Apply mapping

back :: Map -> Map Source

Back mapping

cut :: Region -> Map Source

Cut region mapping

insert :: Region -> Map Source

Opposite to "cut"

cutRegion :: Region -> Region -> Region Source

Update second region position as if it was data cutted at first region

insertRegion :: Region -> Region -> Region Source

Update second region position as if it was data inserted at first region

Edited data

type Contents a = [a] Source

Contents is list of lines

data Edit a Source

Edit data

Constructors

Edit

Map region from source contents to edited

Fields

editCts :: Contents a -> Contents a

Edit contents splitted by lines

editMap :: Map
 

Instances

newtype EditM s a Source

Edit monad is state on Edit, it also collects region mappings

Constructors

EditM 

Fields

runEditM :: State (Edit s) a
 

Instances

editRegion :: Region -> (Region -> Edit a) -> EditM a () Source

Basic edit action in monad It takes region, region edit function and contents updater and passes mapped region to these functions to get new state

mapRegion :: Region -> EditM a Region Source

Get mapped region

runEdit :: Editable s => EditM s a -> (a, Edit s) Source

Run edit monad

edit :: Editable s => s -> EditM s a -> s Source

Edit contents

editEval :: Editable s => s -> EditM s a -> (a, s) Source

Eval edit

data Prefix a Source

Prefix of contents cutted at some point

Constructors

Prefix 

Fields

prefixLines :: [a]
 
prefixLine :: a
 

Instances

Functor Prefix 
Eq a => Eq (Prefix a) 
Ord a => Ord (Prefix a) 
Read a => Read (Prefix a) 
Show a => Show (Prefix a) 

prefix :: Contents a -> Prefix a Source

Make prefix from full contents

data Suffix a Source

Suffix of contents

Constructors

Suffix 

Fields

suffixLine :: a
 
suffixLines :: [a]
 

Instances

Functor Suffix 
Eq a => Eq (Suffix a) 
Ord a => Ord (Suffix a) 
Read a => Read (Suffix a) 
Show a => Show (Suffix a) 

concatCts :: Monoid a => Prefix a -> Suffix a -> Contents a Source

Concat prefix and suffix. First line of suffix is appended to last line of prefix

splitCts :: Editable a => Point -> Contents a -> (Prefix a, Suffix a) Source

Split contents at point. First argument is function to split one line at position.

Editable class

class Monoid a => Editable a where Source

Methods

splitAt :: Int -> a -> (a, a) Source

length :: a -> Int Source

lines :: a -> [a] Source

unlines :: [a] -> a Source

measure :: Editable s => Contents s -> Size Source

Contents size

Actions

erase :: Editable s => Region -> EditM s () Source

Erase data

write :: Editable s => Point -> Contents s -> EditM s () Source

Paste data at position

replace :: Editable s => Region -> Contents s -> EditM s () Source

Replace data with

data Replace s Source

Replace action

Constructors

Replace 

Instances

Eq s => Eq (Replace s) 
Read s => Read (Replace s) 
Show s => Show (Replace s) 
(Editable s, ToJSON s) => ToJSON (Replace s) 
(Editable s, FromJSON s) => FromJSON (Replace s) 

writer :: Editable s => Point -> s -> Replace s Source

run :: Editable s => [Replace s] -> EditM s () Source