yi-language-0.19.2: Collection of language-related Yi libraries.

Copyright | (c) Don Stewart 2007
License | GPL-2
Maintainer | yi-devel@googlegroups.com
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell2010

Extensions

- ScopedTypeVariables
- DeriveFunctor
- DeriveTraversable
- DeriveFoldable
- ExistentialQuantification
- ExplicitForAll

Yi.Syntax

Description

This module defines a common interface for syntax-awareness.

There have been many tens of wasted hours in this and lexer modules. This note is to commemorate those who have fallen in battle.

Synopsis

- data Highlighter cache syntax = SynHL {
  - hlStartState :: cache
  - hlRun :: Scanner Point Char -> Point -> cache -> cache
  - hlGetTree :: cache -> WindowRef -> syntax
  - hlFocus :: Map WindowRef Region -> cache -> cache
  }
- data Cache state result
- data Scanner st a = Scanner {
  - scanInit :: st
  - scanLooked :: st -> Point
  - scanEmpty :: a
  - scanRun :: st -> [(st, a)]
  }
- data ExtHL syntax = ExtHL (Highlighter cache syntax)
- noHighlighter :: Highlighter () syntax
- mkHighlighter :: Show state => (Scanner Point Char -> Scanner state result) -> Highlighter (Cache state result) result
- skipScanner :: Int -> Scanner st a -> Scanner st a
- emptyFileScan :: Scanner Point Char
- newtype Point = Point {
  - fromPoint :: Int
  }
- newtype Size = Size {
  - fromSize :: Int
  }
- type Length = Int
- type Stroke = Span StyleName
- data Span a = Span {
  - spanBegin :: !Point
  - spanContents :: !a
  - spanEnd :: !Point
  }

# Documentation

data Highlighter cache syntax Source #

The main type of syntax highlighters. This record type combines all the required functions, and is parametrized on the type of the internal state.

Constructors

SynHL |

Fields

- hlStartState :: cache

  The start state for the highlighter.

- hlRun :: Scanner Point Char -> Point -> cache -> cache
- hlGetTree :: cache -> WindowRef -> syntax
- hlFocus :: Map WindowRef Region -> cache -> cache

  focus at a given point, and return the corresponding node. (hint -- the root can always be returned, at the cost of performance.)

data Cache state result Source #

data Scanner st a Source #

Constructors

Scanner |

Fields

- scanInit :: st

  Initial state

- scanLooked :: st -> Point

  How far did the scanner look to produce this intermediate state? The state can be reused as long as nothing changes before that point.

- scanEmpty :: a
- scanRun :: st -> [(st, a)]

  Running function returns a list of results and intermediate states. Note: the state is the state before producing the result in the second component.

#### Instances

Instances details

Functor (Scanner st) Source # |
Instance details Defined in Yi.Syntax Methods fmap :: (a -> b) -> Scanner st a -> Scanner st b Source # (<$) :: a -> Scanner st b -> Scanner st a Source #

data ExtHL syntax Source #

Constructors

ExtHL (Highlighter cache syntax) |

noHighlighter :: Highlighter () syntax Source #

mkHighlighter :: Show state => (Scanner Point Char -> Scanner state result) -> Highlighter (Cache state result) result Source #

This takes as input a scanner that returns the "full" result at each element in the list; perhaps in a different form for the purpose of incremental-lazy eval.

skipScanner :: Int -> Scanner st a -> Scanner st a Source #

emptyFileScan :: Scanner Point Char Source #

newtype Point Source #

A point in a buffer

Constructors

Point |

Fields

- fromPoint :: Int

#### Instances

Instances details

Binary Point Source # |
Instance details Defined in Yi.Buffer.Basic Methods put :: Point -> Put Source # get :: Get Point Source # putList :: [Point] -> Put Source #
Bounded Point Source # |
Instance details Defined in Yi.Buffer.Basic Methods minBound :: Point Source # maxBound :: Point Source #
Enum Point Source # |
Instance details Defined in Yi.Buffer.Basic Methods succ :: Point -> Point Source # pred :: Point -> Point Source # toEnum :: Int -> Point Source # fromEnum :: Point -> Int Source # enumFrom :: Point -> [Point] Source # enumFromThen :: Point -> Point -> [Point] Source # enumFromTo :: Point -> Point -> [Point] Source # enumFromThenTo :: Point -> Point -> Point -> [Point] Source #
Ix Point Source # |
Instance details Defined in Yi.Buffer.Basic Methods range :: (Point, Point) -> [Point] Source # index :: (Point, Point) -> Point -> Int Source # unsafeIndex :: (Point, Point) -> Point -> Int Source # inRange :: (Point, Point) -> Point -> Bool Source # rangeSize :: (Point, Point) -> Int Source # unsafeRangeSize :: (Point, Point) -> Int Source #
Num Point Source # |
Instance details Defined in Yi.Buffer.Basic Methods (+) :: Point -> Point -> Point Source # (-) :: Point -> Point -> Point Source # (*) :: Point -> Point -> Point Source # negate :: Point -> Point Source # abs :: Point -> Point Source # signum :: Point -> Point Source # fromInteger :: Integer -> Point Source #
Integral Point Source # |
Instance details Defined in Yi.Buffer.Basic Methods quot :: Point -> Point -> Point Source # rem :: Point -> Point -> Point Source # div :: Point -> Point -> Point Source # mod :: Point -> Point -> Point Source # quotRem :: Point -> Point -> (Point, Point) Source # divMod :: Point -> Point -> (Point, Point) Source # toInteger :: Point -> Integer Source #
Real Point Source # |
Instance details Defined in Yi.Buffer.Basic Methods toRational :: Point -> Rational Source #
Show Point Source # |
Instance details Defined in Yi.Buffer.Basic Methods showsPrec :: Int -> Point -> ShowS Source # show :: Point -> String Source # showList :: [Point] -> ShowS Source #
Eq Point Source # |
Instance details Defined in Yi.Buffer.Basic Methods (==) :: Point -> Point -> Bool Source # (/=) :: Point -> Point -> Bool Source #
Ord Point Source # |
Instance details Defined in Yi.Buffer.Basic Methods compare :: Point -> Point -> Ordering Source # (<) :: Point -> Point -> Bool Source # (<=) :: Point -> Point -> Bool Source # (>) :: Point -> Point -> Bool Source # (>=) :: Point -> Point -> Bool Source # max :: Point -> Point -> Point Source # min :: Point -> Point -> Point Source #
SemiNum Point Size Source # |
Instance details Defined in Yi.Buffer.Basic Methods (+~) :: Point -> Size -> Point Source # (-~) :: Point -> Size -> Point Source # (~-) :: Point -> Point -> Size Source #

newtype Size Source #

Size of a buffer region

Constructors

Size |

Fields

- fromSize :: Int

#### Instances

Instances details

Binary Size Source # |
Instance details Defined in Yi.Buffer.Basic Methods put :: Size -> Put Source # get :: Get Size Source # putList :: [Size] -> Put Source #
Enum Size Source # |
Instance details Defined in Yi.Buffer.Basic Methods succ :: Size -> Size Source # pred :: Size -> Size Source # toEnum :: Int -> Size Source # fromEnum :: Size -> Int Source # enumFrom :: Size -> [Size] Source # enumFromThen :: Size -> Size -> [Size] Source # enumFromTo :: Size -> Size -> [Size] Source # enumFromThenTo :: Size -> Size -> Size -> [Size] Source #
Num Size Source # |
Instance details Defined in Yi.Buffer.Basic Methods (+) :: Size -> Size -> Size Source # (-) :: Size -> Size -> Size Source # (*) :: Size -> Size -> Size Source # negate :: Size -> Size Source # abs :: Size -> Size Source # signum :: Size -> Size Source # fromInteger :: Integer -> Size Source #
Integral Size Source # |
Instance details Defined in Yi.Buffer.Basic Methods quot :: Size -> Size -> Size Source # rem :: Size -> Size -> Size Source # div :: Size -> Size -> Size Source # mod :: Size -> Size -> Size Source # quotRem :: Size -> Size -> (Size, Size) Source # divMod :: Size -> Size -> (Size, Size) Source # toInteger :: Size -> Integer Source #
Real Size Source # |
Instance details Defined in Yi.Buffer.Basic Methods toRational :: Size -> Rational Source #
Show Size Source # |
Instance details Defined in Yi.Buffer.Basic Methods showsPrec :: Int -> Size -> ShowS Source # show :: Size -> String Source # showList :: [Size] -> ShowS Source #
Eq Size Source # |
Instance details Defined in Yi.Buffer.Basic Methods (==) :: Size -> Size -> Bool Source # (/=) :: Size -> Size -> Bool Source #
Ord Size Source # |
Instance details Defined in Yi.Buffer.Basic Methods compare :: Size -> Size -> Ordering Source # (<) :: Size -> Size -> Bool Source # (<=) :: Size -> Size -> Bool Source # (>) :: Size -> Size -> Bool Source # (>=) :: Size -> Size -> Bool Source # max :: Size -> Size -> Size Source # min :: Size -> Size -> Size Source #
SemiNum Point Size Source # |
Instance details Defined in Yi.Buffer.Basic Methods (+~) :: Point -> Size -> Point Source # (-~) :: Point -> Size -> Point Source # (~-) :: Point -> Point -> Size Source #

type Length = Int Source #

type Stroke = Span StyleName Source #

data Span a Source #

Constructors

Span |

Fields

- spanBegin :: !Point
- spanContents :: !a
- spanEnd :: !Point

#### Instances

Instances details

Functor Span Source # |
Instance details Defined in Yi.Syntax Methods fmap :: (a -> b) -> Span a -> Span b Source # (<$) :: a -> Span b -> Span a Source #
Foldable Span Source # |

Instance details

Defined in Yi.Syntax

Methods

fold :: Monoid m => Span m -> m Source #

foldMap :: Monoid m => (a -> m) -> Span a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Span a -> m Source #

foldr :: (a -> b -> b) -> b -> Span a -> b Source #

foldr' :: (a -> b -> b) -> b -> Span a -> b Source #

foldl :: (b -> a -> b) -> b -> Span a -> b Source #

foldl' :: (b -> a -> b) -> b -> Span a -> b Source #

foldr1 :: (a -> a -> a) -> Span a -> a Source #

foldl1 :: (a -> a -> a) -> Span a -> a Source #

toList :: Span a -> [a] Source #

null :: Span a -> Bool Source #

length :: Span a -> Int Source #

elem :: Eq a => a -> Span a -> Bool Source #

maximum :: Ord a => Span a -> a Source #

minimum :: Ord a => Span a -> a Source #

sum :: Num a => Span a -> a Source #

product :: Num a => Span a -> a Source #

Traversable Span Source # |
Instance details Defined in Yi.Syntax Methods traverse :: Applicative f => (a -> f b) -> Span a -> f (Span b) Source # sequenceA :: Applicative f => Span (f a) -> f (Span a) Source # mapM :: Monad m => (a -> m b) -> Span a -> m (Span b) Source # sequence :: Monad m => Span (m a) -> m (Span a) Source #
Show a => Show (Span a) Source # |
Instance details Defined in Yi.Syntax Methods showsPrec :: Int -> Span a -> ShowS Source # show :: Span a -> String Source # showList :: [Span a] -> ShowS Source #