-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | The Haskell-Scriptable Editor -- -- Yi is a text editor written in Haskell and extensible in Haskell. The -- goal of the Yi project is to provide a flexible, powerful, and correct -- editor for haskell hacking. @package yi @version 0.6.2.4 module Yi.Char.Unicode greek :: [(String, String)] symbols :: [(String, String)] subscripts :: [(String, String)] superscripts :: [(String, String)] checkAmbs :: [(String, String)] -> [(String, String)] disamb :: [(String, String)] -> [(String, String)] -- | This is a little helper for completion interfaces. module Yi.Keymap.Completion data CompletionTree a CT :: [(a, CompletionTree a)] -> CompletionTree a stepTree :: (Eq a) => CompletionTree a -> a -> Maybe ([a], CompletionTree a) obvious :: CompletionTree a -> ([a], CompletionTree a) mergeTrees :: (Ord a) => [CompletionTree a] -> CompletionTree a listToTree :: [a] -> CompletionTree a complete :: (Eq a) => CompletionTree a -> [a] -> ([a], CompletionTree a) instance (Show a) => Show (CompletionTree a) module Yi.Debug -- | Set the file to which debugging output should be written. Though this -- is called initDebug. Debugging output is not created by default -- (i.e., if this function is never called.) The target file can not be -- changed, nor debugging disabled. initDebug :: FilePath -> IO () -- | Outputs the given string before returning the second argument. trace :: String -> a -> a -- | Traces x and returns y. traceM :: (Monad m) => String -> a -> m a -- | Like traceM, but returns (). traceM_ :: (Monad m) => String -> m () logPutStrLn :: (MonadIO m) => String -> m () logError :: (MonadIO m) => String -> m () logStream :: (Show a) => String -> Chan a -> IO () error :: String -> a -- | String manipulation utilities module Yi.String isBlank :: String -> Bool -- | Remove any trailing strings matching irs (input record -- separator) from input string. Like perl's chomp(1). chomp :: String -> String -> String capitalize :: String -> String capitalizeFirst :: String -> String -- | Trim spaces at beginning and end dropSpace :: String -> String fillText :: Int -> String -> [String] onLines :: ([String] -> [String]) -> String -> String -- | A helper function for creating functions suitable for -- modifySelectionB and modifyRegionB. To be used when -- the desired function should map across the lines of a region. mapLines :: (String -> String) -> String -> String -- | Split a String in lines. Unlike lines, this does not remove any -- empty line at the end. lines' :: String -> [String] -- | Inverse of lines'. In contrast to unlines, this does not -- add an empty line at the end. unlines' :: [String] -> String padLeft :: Int -> String -> String padRight :: Int -> String -> String module Yi.Monad class Ref ref readRef :: (Ref ref, MonadIO m) => ref a -> m a writeRef :: (Ref ref, MonadIO m) => ref a -> a -> m () modifyRef :: (Ref ref, MonadIO m) => ref a -> (a -> a) -> m () -- | Gets specific component of the state, using a projection function -- supplied. gets :: (MonadState s m) => (s -> a) -> m a getsA :: (MonadState s m) => Accessor s p -> (p -> a) -> m a -- | Combination of the Control.Monad.State modify and gets getsAndModify :: (MonadState s m) => (s -> (s, a)) -> m a maybeM :: (Monad m) => (x -> m ()) -> Maybe x -> m () modifiesRef :: (Ref ref, MonadReader r m, MonadIO m) => (r -> ref a) -> (a -> a) -> m () modifiesThenReadsRef :: (MonadReader r m, MonadIO m) => (r -> IORef a) -> (a -> a) -> m a readsRef :: (Ref ref, MonadReader r m, MonadIO m) => (r -> ref a) -> m a -- | Rerun the monad until the boolean result is false, collecting list of -- results. repeatUntilM :: (Monad m) => m (Bool, a) -> m [a] whenM :: (Monad m) => m Bool -> m () -> m () with :: (MonadReader yi m, MonadIO m) => (yi -> component) -> (component -> IO a) -> m a writesRef :: (MonadReader r m, MonadIO m) => (r -> IORef a) -> a -> m () instance Ref MVar instance Ref IORef module Yi.UI.Pango.Gnome watchSystemFont :: (FontDescription -> IO ()) -> IO () module Yi.Prelude (<>) :: (Monoid a) => a -> a -> a -- | Append two lists, i.e., -- -- [x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn] [x1, -- ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...] -- -- If the first list is not finite, the result is the first list. (++) :: [a] -> [a] -> [a] -- | Same as >>=, but with the arguments interchanged. (=<<) :: (Monad m) => (a -> m b) -> m a -> m b -- | Double-precision floating point numbers. It is desirable that this -- type be at least equal in range and precision to the IEEE -- double-precision type. data Double :: * data Char :: * -- | The Either type represents values with two possibilities: a -- value of type Either a b is either Left -- a or Right b. -- -- The Either type is sometimes used to represent a value which is -- either correct or an error; by convention, the Left constructor -- is used to hold an error value and the Right constructor is -- used to hold a correct value (mnemonic: "right" also means "correct"). data Either a b :: * -> * -> * Left :: a -> Either a b Right :: b -> Either a b type Endom a = a -> a -- | The Eq class defines equality (==) and inequality -- (/=). All the basic datatypes exported by the Prelude -- are instances of Eq, and Eq may be derived for any -- datatype whose constituents are also instances of Eq. -- -- Minimal complete definition: either == or /=. class Eq a (==) :: (Eq a) => a -> a -> Bool (/=) :: (Eq a) => a -> a -> Bool -- | Fractional numbers, supporting real division. -- -- Minimal complete definition: fromRational and (recip or -- (/)) class (Num a) => Fractional a (/) :: (Fractional a) => a -> a -> a recip :: (Fractional a) => a -> a fromRational :: (Fractional a) => Rational -> a -- | The Functor class is used for types that can be mapped over. -- Instances of Functor should satisfy the following laws: -- -- fmap id == id fmap (f . g) == fmap f . fmap g -- -- The instances of Functor for lists, Data.Maybe.Maybe and -- System.IO.IO defined in the Prelude satisfy these laws. class Functor f :: (* -> *) fmap :: (Functor f) => (a -> b) -> f a -> f b (<$) :: (Functor f) => a -> f b -> f a -- | A value of type IO a is a computation which, when -- performed, does some I/O before returning a value of type a. -- -- There is really only one way to "perform" an I/O action: bind it to -- Main.main in your program. When your program is run, the I/O -- will be performed. It isn't possible to perform I/O from an arbitrary -- function, unless that function is itself in the IO monad and -- called at some point, directly or indirectly, from Main.main. -- -- IO is a monad, so IO actions can be combined using -- either the do-notation or the >> and >>= operations from -- the Monad class. data IO a :: * -> * -- | Arbitrary-precision integers. data Integer :: * -- | Integral numbers, supporting integer division. -- -- Minimal complete definition: quotRem and toInteger class (Real a, Enum a) => Integral a quot :: (Integral a) => a -> a -> a rem :: (Integral a) => a -> a -> a div :: (Integral a) => a -> a -> a mod :: (Integral a) => a -> a -> a quotRem :: (Integral a) => a -> a -> (a, a) divMod :: (Integral a) => a -> a -> (a, a) toInteger :: (Integral a) => a -> Integer -- | The Bounded class is used to name the upper and lower limits of -- a type. Ord is not a superclass of Bounded since types -- that are not totally ordered may also have upper and lower bounds. -- -- The Bounded class may be derived for any enumeration type; -- minBound is the first constructor listed in the data -- declaration and maxBound is the last. Bounded may also -- be derived for single-constructor datatypes whose constituent types -- are in Bounded. class Bounded a minBound :: (Bounded a) => a maxBound :: (Bounded a) => a -- | Class Enum defines operations on sequentially ordered types. -- -- The enumFrom... methods are used in Haskell's translation of -- arithmetic sequences. -- -- Instances of Enum may be derived for any enumeration type -- (types whose constructors have no fields). The nullary constructors -- are assumed to be numbered left-to-right by fromEnum from -- 0 through n-1. See Chapter 10 of the Haskell -- Report for more details. -- -- For any type that is an instance of class Bounded as well as -- Enum, the following should hold: -- --
-- P(xs) === all (isPrefixOf (commonPrefix xs)) xs -- length s > length (commonPrefix xs) --> not (all (isPrefixOf s) xs) --commonPrefix :: (Eq a) => [[a]] -> [a] discard :: (Functor f) => f a -> f () -- | Lift an accessor to a traversable structure. (This can be seen as a -- generalization of fmap) every :: (Traversable t) => Accessor whole part -> Accessor (t whole) (t part) -- | general coercion from integral types fromIntegral :: (Integral a, Num b) => a -> b -- | Extract the first component of a pair. fst :: (a, b) -> a fst3 :: (a, b, c) -> a -- | Alternative to groupBy. -- --
-- groupBy' (\a b -> abs (a - b) <= 1) [1,2,3] = [[1,2,3]] ---- -- whereas -- --
-- groupBy (\a b -> abs (a - b) <= 1) [1,2,3] = [[1,2],[3]] ---- -- TODO: Check in ghc 6.12 release if groupBy == groupBy'. groupBy' :: (a -> a -> Bool) -> [a] -> [[a]] list :: b -> (a -> [a] -> b) -> [a] -> b -- | Extract the first element of a list, which must be non-empty. head :: [a] -> a -- | Return all the elements of a list except the last one. The list must -- be non-empty. init :: [a] -> [a] io :: (MonadIO m) => IO a -> m a -- | Extract the last element of a list, which must be finite and -- non-empty. last :: [a] -> a -- | lookup key assocs looks up a key in an association -- list. lookup :: (Eq a) => a -> [(a, b)] -> Maybe b -- | As Map.adjust, but the combining function is applied strictly. mapAdjust' :: (Ord k) => (a -> a) -> k -> Map k a -> Map k a -- | As Map.alter, but the newly inserted element is forced with the map. mapAlter' :: (Ord k) => (Maybe a -> Maybe a) -> k -> Map k a -> Map k a putA :: (MonadState r m) => T r a -> a -> m () getA :: (MonadState r m) => T r a -> m a modA :: (MonadState r m) => T r a -> (a -> a) -> m () data Rope fromString :: String -> Rope toString :: Rope -> String toReverseString :: Rope -> String null :: Rope -> Bool empty :: Rope take :: Int -> Rope -> Rope drop :: Int -> Rope -> Rope -- | Append two strings by merging the two finger trees. append :: Rope -> Rope -> Rope -- | Split the string at the specified position. splitAt :: Int -> Rope -> (Rope, Rope) -- | Split before the specified line. Lines are indexed from 0. splitAtLine :: Int -> Rope -> (Rope, Rope) -- | Get the length of the string. (This information cached, so O(1) -- amortized runtime.) length :: Rope -> Int reverse :: Rope -> Rope -- | Count the number of newlines in the strings. (This information cached, -- so O(1) amortized runtime.) countNewLines :: Rope -> Int readFile :: FilePath -> IO Rope writeFile :: FilePath -> Rope -> IO () -- | Split the rope on a chunk, so that the desired position lies within -- the first chunk of the second rope. splitAtChunkBefore :: Int -> Rope -> (Rope, Rope) -- | As Prelude.nub, but with O(n*log(n)) behaviour. nubSet :: (Ord a) => [a] -> [a] -- | Test whether a list is empty. null :: [a] -> Bool -- | The print function outputs a value of any printable type to the -- standard output device. Printable types are those that are instances -- of class Show; print converts values to strings for -- output using the show operation and adds a newline. -- -- For example, a program to print the first 20 integers and their powers -- of 2 could be written as: -- -- main = print ([(n, 2^n) | n <- [0..19]]) print :: (Show a) => a -> IO () -- | The same as putStr, but adds a newline character. putStrLn :: String -> IO () -- | replicate n x is a list of length n with -- x the value of every element. It is an instance of the more -- general Data.List.genericReplicate, in which n may be of any -- integral type. replicate :: Int -> a -> [a] -- | The read function reads input from a string, which must be -- completely consumed by the input process. read :: (Read a) => String -> a -- | Evaluates its first argument to head normal form, and then returns its -- second argument as the result. seq :: a -> b -> b singleton :: a -> [a] -- | Extract the second component of a pair. snd :: (a, b) -> b snd3 :: (a, b, c) -> b -- | Extract the elements after the head of a list, which must be -- non-empty. tail :: [a] -> [a] trd3 :: (a, b, c) -> c -- | A special case of error. It is expected that compilers will -- recognize this and insert error messages which are more appropriate to -- the context in which undefined appears. undefined :: a -- | unlines is an inverse operation to lines. It joins -- lines, after appending a terminating newline to each. unlines :: [String] -> String -- | Conditional execution of monadic expressions. For example, -- -- when debug (putStr "Debugging\n") -- -- will output the string Debugging\n if the Boolean value -- debug is True, and otherwise do nothing. when :: (Monad m) => Bool -> m () -> m () -- | The computation writeFile file str function writes the -- string str, to the file file. writeFile :: FilePath -> String -> IO () module Yi.Event data Event Event :: Key -> [Modifier] -> Event prettyEvent :: Event -> String data Key KEsc :: Key KFun :: Int -> Key KPrtScr :: Key KPause :: Key KASCII :: Char -> Key KBS :: Key KIns :: Key KHome :: Key KPageUp :: Key KDel :: Key KEnd :: Key KPageDown :: Key KNP5 :: Key KUp :: Key KMenu :: Key KLeft :: Key KDown :: Key KRight :: Key KEnter :: Key KTab :: Key data Modifier MShift :: Modifier MCtrl :: Modifier MMeta :: Modifier MSuper :: Modifier -- | Map an Event to a Char. This is used in the emacs keymap for Ctrl-Q -- and vim keymap insertSpecialChar eventToChar :: Event -> Char instance Eq Event instance Eq Key instance Show Key instance Ord Key instance Show Modifier instance Eq Modifier instance Ord Modifier instance Show Event instance Ord Event -- | Colors and friends. module Yi.Style -- | Visual text attributes to be applied during layout. data Attributes Attributes :: !Color -> !Color -> !Bool -> !Bool -> !Bool -> !Bool -> Attributes foreground :: Attributes -> !Color background :: Attributes -> !Color -- | The text should be show as active or selected. This can -- be implemented by reverse video on the terminal. reverseAttr :: Attributes -> !Bool bold :: Attributes -> !Bool italic :: Attributes -> !Bool underline :: Attributes -> !Bool emptyAttributes :: Attributes -- | The style is used to transform attributes by modifying one or more of -- the visual text attributes. type Style = Endo Attributes -- | The UI type data UIStyle UIStyle :: Attributes -> Style -> Attributes -> Style -> Style -> Attributes -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> Style -> UIStyle -- | ground attributes for the modeline modelineAttributes :: UIStyle -> Attributes -- | transformation of modeline in focus modelineFocusStyle :: UIStyle -> Style -- | ground attributes for the tabbar tabBarAttributes :: UIStyle -> Attributes -- | a tab that currently holds the focus tabInFocusStyle :: UIStyle -> Style -- | a tab that does not have the current focus tabNotFocusedStyle :: UIStyle -> Style -- | ground attributes for the main text views baseAttributes :: UIStyle -> Attributes -- | the selected portion selectedStyle :: UIStyle -> Style -- | empty file marker colours eofStyle :: UIStyle -> Style -- | indicates errors in text errorStyle :: UIStyle -> Style -- | search matchesparen matchesother hints hintStyle :: UIStyle -> Style -- | current search match strongHintStyle :: UIStyle -> Style -- | all comments commentStyle :: UIStyle -> Style -- | additional only for block comments blockCommentStyle :: UIStyle -> Style -- | applied to language keywords keywordStyle :: UIStyle -> Style -- | numbers numberStyle :: UIStyle -> Style -- | preprocessor directive (often in Haskell or C) preprocessorStyle :: UIStyle -> Style -- | constant strings stringStyle :: UIStyle -> Style -- | additional style for long strings longStringStyle :: UIStyle -> Style -- | type name (such as class in an OO language) typeStyle :: UIStyle -> Style -- | data constructor dataConstructorStyle :: UIStyle -> Style -- | style of import names importStyle :: UIStyle -> Style -- | builtin things, e.g. Array in JavaScript builtinStyle :: UIStyle -> Style -- | regular expressions regexStyle :: UIStyle -> Style -- | any standard variable (identifier) variableStyle :: UIStyle -> Style -- | infix operators operatorStyle :: UIStyle -> Style -- | Style of a quotation (e.g. in template haskell) quoteStyle :: UIStyle -> Style -- | stuff that's passed to the shell in a Makefile makeFileAction :: UIStyle -> Style -- | makefile rule headers makeFileRuleHead :: UIStyle -> Style -- | A StyleName determines what style to use, taking into account the set -- of rendering preferences given by a UIStyle. Typically, style -- names will be Style-valued field names of UIStyle. type StyleName = UIStyle -> Style withBg :: Color -> Style withFg :: Color -> Style -- | A style that sets the foreground. -- -- A style that sets the background. withItlc :: Bool -> Style withUnderline :: Bool -> Style withBd :: Bool -> Style -- | A style that sets the font to bold -- -- A style that sets the style to italics -- -- A style that sets the style to underlined -- -- A style that sets the style to underlined -- -- The identity transform. defaultStyle :: StyleName data Color RGB :: !!Word8 -> !!Word8 -> !!Word8 -> Color -- | The system-default color of the engine used. e.g. in Gtk this should -- pick whatever the user has chosen as default color (background or -- forground depending on usage) for the text. Default :: Color -- | Convert a color to its text specification, as to be accepted by -- XParseColor colorToText :: Color -> String grey :: Color lightGrey :: Color darkred :: Color red :: Color darkgreen :: Color green :: Color brown :: Color yellow :: Color black :: Color blue :: Color purple :: Color magenta :: Color darkcyan :: Color cyan :: Color white :: Color brightwhite :: Color darkblue :: Color instance Eq Color instance Ord Color instance Show Color instance Eq Attributes instance Ord Attributes instance Show Attributes module Yi.Style.Library type Theme = Proto UIStyle -- | Abstract theme that provides useful defaults. defaultTheme :: Theme -- | The default Theme defaultLightTheme :: Theme -- | A Theme inspired by the darkblue colorscheme of Vim. darkBlueTheme :: Theme -- | Theme originally designed by Joseph Andrew Magnani for TextMate, and -- redistributed with explicit permission. It is not usable in the vty -- UI. happyDeluxe :: Theme -- | Theme originally developed by Matthew Ratzloff for TextMate, and -- redistributed with explicit permission. It is not usable in the vty -- UI. textExMachina :: Theme -- | Basic types useful everywhere we play with buffers. module Yi.Buffer.Basic -- | Direction of movement inside a buffer data Direction Backward :: Direction Forward :: Direction reverseDir :: Direction -> Direction -- | reverse if Backward mayReverse :: Direction -> [a] -> [a] -- | direction is in the same style of maybe or -- either functions, It takes one argument per direction -- (backward, then forward) and a direction to select the output. directionElim :: Direction -> a -> a -> a -- | A mark in a buffer newtype Mark Mark :: Int -> Mark markId :: Mark -> Int -- | Reference to a buffer. newtype BufferRef BufferRef :: Int -> BufferRef -- | A point in a buffer newtype Point Point :: Int -> Point fromPoint :: Point -> Int -- | Size of a buffer region newtype Size Size :: Int -> Size fromSize :: Size -> Int fromString :: String -> Rope instance Typeable Point instance Typeable BufferRef instance Typeable Mark instance Integral Point instance Real Point instance Num Point instance Num BufferRef instance Show Size instance Eq Size instance Ord Size instance Num Size instance Enum Size instance Real Size instance Integral Size instance Binary Size instance Eq Point instance Ord Point instance Enum Point instance Bounded Point instance Binary Point instance Ix Point instance Eq BufferRef instance Ord BufferRef instance Binary BufferRef instance Eq Mark instance Ord Mark instance Show Mark instance Binary Mark instance SemiNum Point Size instance Show Point instance Show BufferRef instance Binary Direction instance Typeable Direction instance Eq Direction instance Ord Direction instance Show Direction module Yi.Regex data SearchOption -- | Compile for matching that ignores char case IgnoreCase :: SearchOption -- | Compile for newline-insensitive matching NoNewLine :: SearchOption -- | Treat the input not as a regex but as a literal string to search for. QuoteRegex :: SearchOption makeSearchOptsM :: [SearchOption] -> String -> Either String SearchExp data SearchExp SearchExp :: String -> Regex -> Regex -> SearchExp seInput :: SearchExp -> String seCompiled :: SearchExp -> Regex seBackCompiled :: SearchExp -> Regex searchString :: SearchExp -> String searchRegex :: Direction -> SearchExp -> Regex emptySearch :: SearchExp -- | The regular expression that matches nothing. emptyRegex :: Regex -- | Return an escaped (for parseRegex use) version of the string. regexEscapeString :: String -> String instance Eq SearchOption instance Uniplate Pattern module Yi.KillRing data Killring krKilled :: Killring -> Bool krContents :: Killring -> [String] -- | Finish an atomic command, for the purpose of killring accumulation. krEndCmd :: Killring -> Killring -- | Put some text in the killring. It's accumulated if the last command -- was a kill too krPut :: Direction -> String -> Killring -> Killring -- | Set the top of the killring. Never accumulate the previous content. krSet :: String -> Killring -> Killring -- | Get the top of the killring. krGet :: Killring -> String krEmpty :: Killring instance Binary Killring instance Show Killring module Yi.Dynamic -- | Class of values that can go in the extensible state component -- -- The default value. If a function tries to get a copy of the state, but -- the state hasn't yet been created, initial will be called to -- supply *some* value. The value of initial will probably be something -- like Nothing, [], "", or Data.Sequence.empty - compare the -- mempty of Data.Monoid. class (Typeable a) => Initializable a initial :: (Initializable a) => a toDyn :: (Initializable a) => a -> Dynamic fromDynamic :: (Typeable a) => Dynamic -> Maybe a -- | Accessor for a dynamic component dynamicValueA :: (Initializable a) => Accessor DynamicValues a -- | The empty record emptyDV :: DynamicValues -- | The class Typeable allows a concrete representation of a type -- to be calculated. class Typeable a data Dynamic -- | An extensible record, indexed by type type DynamicValues = Map String Dynamic instance (Typeable a) => Initializable (Maybe a) -- | This module defines the Region ADT module Yi.Region -- | The region data type. The region is semi open: it includes the start -- but not the end bound. This allows simpler region-manipulation -- algorithms. Invariant : regionStart r <= regionEnd r data Region -- | The empty region emptyRegion :: Region regionIsEmpty :: Region -> Bool -- | Construct a region from its bounds, emacs style: the right bound is -- excluded mkRegion :: Point -> Point -> Region mkRegion' :: Direction -> Point -> Point -> Region mkSizeRegion :: Point -> Size -> Region regionStart :: Region -> Point regionEnd :: Region -> Point regionSize :: Region -> Size regionDirection :: Region -> Direction -- | True if the given point is inside the given region. inRegion :: Point -> Region -> Bool -- | True if the given point is inside the given region or at the end of -- it. nearRegion :: Point -> Region -> Bool -- | Returns if a region (1st arg) is included in another (2nd arg) includedRegion :: Region -> Region -> Bool fmapRegion :: (Point -> Point) -> Region -> Region -- | Take the intersection of two regions intersectRegion :: Region -> Region -> Region -- | Take the union of two regions (including what is between them) unionRegion :: Region -> Region -> Region regionFirst :: Region -> Point regionLast :: Region -> Point regionsOverlap :: Bool -> Region -> Region -> Bool instance Typeable Region instance Show Region module Yi.Window -- | A window onto a buffer. type WindowRef = Int data Window Window :: !Bool -> !BufferRef -> ![BufferRef] -> Int -> Region -> !WindowRef -> Window -- | regular or mini window? isMini :: Window -> !Bool -- | the buffer this window opens to bufkey :: Window -> !BufferRef -- | list of last accessed buffers (former bufKeys). Last accessed one is -- first element bufAccessList :: Window -> ![BufferRef] -- | height of the window (in number of lines displayed) height :: Window -> Int -- | view area. note that the top point is also available as a buffer mark. winRegion :: Window -> Region -- | identifier for the window (for UI sync) wkey :: Window -> !WindowRef -- | Get the identification of a window. winkey :: Window -> (Bool, BufferRef) dummyWindowKey :: Int -- | Return a fake window onto a buffer. dummyWindow :: BufferRef -> Window instance Typeable Window instance Eq Window instance Show Window instance Binary Window -- | This module defines a common interface for syntax-awareness. module Yi.Syntax -- | The main type of syntax highlighters. This record type combines all -- the required functions, and is parametrized on the type of the -- internal state. data Highlighter cache syntax SynHL :: cache -> (Scanner Point Char -> Point -> cache -> cache) -> (cache -> Int -> syntax) -> (Map Int Region -> cache -> cache) -> Highlighter cache syntax -- | The start state for the highlighter. hlStartState :: Highlighter cache syntax -> cache hlRun :: Highlighter cache syntax -> Scanner Point Char -> Point -> cache -> cache hlGetTree :: Highlighter cache syntax -> cache -> Int -> syntax -- | focus at a given point, and return the coresponding node. (hint -- the -- root can always be returned, at the cost of performance.) hlFocus :: Highlighter cache syntax -> Map Int Region -> cache -> cache data Cache state result data Scanner st a Scanner :: st -> (st -> Point) -> a -> (st -> [(st, a)]) -> Scanner st a -- | Initial state scanInit :: Scanner st a -> st -- | How far did the scanner look to produce this intermediate state? The -- state can be reused as long as nothing changes before that point. scanLooked :: Scanner st a -> st -> Point scanEmpty :: Scanner st a -> 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. scanRun :: Scanner st a -> st -> [(st, a)] data ExtHL syntax ExtHL :: (Highlighter cache syntax) -> ExtHL syntax noHighlighter :: Highlighter () syntax -- | 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. 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 -- | A point in a buffer newtype Point Point :: Int -> Point fromPoint :: Point -> Int -- | Size of a buffer region newtype Size Size :: Int -> Size fromSize :: Size -> Int type Length = Int type Stroke = Span StyleName data Span a Span :: !Point -> !a -> !Point -> Span a spanBegin :: Span a -> !Point spanContents :: Span a -> !a spanEnd :: Span a -> !Point instance (Show a) => Show (Span a) instance Functor (Scanner st) instance Functor Span instance Foldable Span instance Traversable Span -- | An implementation of restricted, linear undo, as described in: -- --
-- T. Berlage, "A selective undo mechanism for graphical user interfaces -- based on command objects", ACM Transactions on Computer-Human -- Interaction 1(3), pp. 269-294, 1994. ---- -- Implementation based on a proposal by sjw. -- -- From Berlage: -- --
-- All buffer-mutating commands are stored (in abstract form) in an -- Undo list. The most recent item in this list is the action that -- will be undone next. When it is undone, it is removed from the Undo -- list, and its inverse is added to the Redo list. The last command -- put into the Redo list can be redone, and again prepended to the -- Undo list. New commands are added to the Undo list without -- affecting the Redo list. ---- -- Now, the above assumes that commands can be _redone_ in a state other -- than that in which it was orginally done. This is not the case in our -- text editor: a user may delete, for example, between an undo and a -- redo. Berlage addresses this in S2.3. A Yi example: -- --
-- Delete some characters -- Undo partialy -- Move prior in the file, and delete another _chunk_ -- Redo some things == corruption. ---- -- Berlage describes the stable execution property: -- --
-- A command is always redone in the same state that it was originally -- executed in, and is always undone in the state that was reached -- after the original execution. ---- --
-- The only case where the linear undo model violates the stable -- execution property is when _a new command is submitted while the -- redo list is not empty_. The _restricted linear undo model_ ... -- clears the redo list in this case. ---- -- Also some discussion of this in: The Text Editor Sam, Rob Pike, -- pg 19. module Yi.Buffer.Undo -- | A new empty URList. Notice we must have a saved file point as -- this is when we assume we are opening the file so it is currently the -- same as the one on disk emptyU :: URList -- | Add an action to the undo list. According to the restricted, linear -- undo model, if we add a command whilst the redo list is not empty, we -- will lose our redoable changes. addChangeU :: Change -> URList -> URList -- | Add a saved file point so that we can tell that the buffer has not -- been modified since the previous saved file point. Notice that we must -- be sure to remove the previous saved file points since they are now -- worthless. setSavedFilePointU :: URList -> URList -- | undoIsAtSavedFilePoint. True if the undo list is at a -- SavedFilePoint indicating that the buffer has not been modified since -- we last saved the file. Note: that an empty undo list does NOT mean -- that the buffer is not modified since the last save. Because we may -- have saved the file and then undone actions done before the save. isAtSavedFilePointU :: URList -> Bool -- | This undoes one interaction step. undoU :: Mark -> URList -> BufferImpl syntax -> (BufferImpl syntax, (URList, [Update])) -- | This redoes one iteraction step. redoU :: Mark -> URList -> BufferImpl syntax -> (BufferImpl syntax, (URList, [Update])) -- | A URList consists of an undo and a redo list. data URList data Change InteractivePoint :: Change AtomicChange :: !Update -> Change instance Binary URList instance Show URList instance Binary Change instance Show Change -- | This is a library of interactive processes combinators, usable to -- define extensible keymaps. -- -- (Inspired by the Parsec library, written by Koen Claessen) -- -- The processes are: -- --
-- putA bufferDynamicValueA updatedvalue -- value <- getA bufferDynamicValueA --bufferDynamicValueA :: (Initializable a) => Accessor FBuffer a shortIdentString :: [a] -> FBuffer -> [Char] identString :: FBuffer -> [Char] miniIdentString :: FBuffer -> [Char] identA :: Accessor FBuffer BufferId -- | maybe a filename associated with this buffer. Filename is -- canonicalized. type BufferId = Either String FilePath file :: FBuffer -> (Maybe FilePath) lastSyncTimeA :: Accessor FBuffer UTCTime instance Typeable1 BufferM instance Typeable AnyMode instance Typeable IndentSettings instance Typeable FBuffer instance Monad BufferM instance Functor BufferM instance MonadWriter [Update] BufferM instance MonadState FBuffer BufferM instance MonadReader Window BufferM instance Eq IndentBehaviour instance Show IndentBehaviour instance Eq IndentSettings instance Show IndentSettings instance Show FBuffer instance Eq FBuffer instance Applicative BufferM instance Binary (Mode syntax) instance Binary SelectionStyle instance Binary FBuffer instance Binary UTCTime instance Binary Attributes instance Typeable Attributes instance Typeable SelectionStyle instance (Binary a_1627640263) => Binary (MarkSet a_1627640263) instance Functor MarkSet instance Foldable MarkSet instance Traversable MarkSet -- | This module defines buffer operation on regions module Yi.Buffer.Region -- | Swap the content of two Regions swapRegionsB :: Region -> Region -> BufferM () -- | Delete an arbitrary part of the buffer deleteRegionB :: Region -> BufferM () -- | Replace a region with a given string. replaceRegionB :: Region -> String -> BufferM () -- | As replaceRegionB, but do a minimal edition instead of deleting -- the whole region and inserting it back. replaceRegionClever :: Region -> String -> BufferM () -- | Read an arbitrary part of the buffer readRegionB :: Region -> BufferM String mapRegionB :: Region -> (Char -> Char) -> BufferM () -- | Modifies the given region according to the given string transformation -- function modifyRegionB :: (String -> String) -> Region -> BufferM () -- | As modifyRegionB, but do a minimal edition instead of deleting -- the whole region and inserting it back. modifyRegionClever :: (String -> String) -> Region -> BufferM () winRegionB :: BufferM Region -- | Extend the right bound of a region to include it. inclusiveRegionB :: Region -> BufferM Region -- | See a region as a block/rectangular region, since regions are -- represented by two point, this returns a list of small regions form -- this block region. blockifyRegion :: Region -> BufferM [Region] -- | A normalized API to many buffer operations. module Yi.Buffer.Normal -- | Designate a given unit of text. data TextUnit -- | a single character Character :: TextUnit -- | a line of text (between newlines) Line :: TextUnit -- | a vertical line of text (area of text between two characters at -- the same column number) VLine :: TextUnit -- | the whole document Document :: TextUnit -- | Turns a unit into its negative by inverting the boundaries. For -- example, outsideUnit unitViWord will be the unit of spaces -- between words. For units without boundaries (Character, -- Document, ...), this is the identity function. outsideUnit :: TextUnit -> TextUnit -- | Unit that have its left and right boundaries at the left boundary of -- the argument unit. leftBoundaryUnit :: TextUnit -> TextUnit -- | a word as in use in Emacs (fundamental mode) -- -- delimited on the left and right by given characters, boolean argument -- tells if whether those are included. unitWord :: TextUnit unitViWord :: TextUnit unitViWORD :: TextUnit unitViWordAnyBnd :: TextUnit unitViWORDAnyBnd :: TextUnit unitViWordOnLine :: TextUnit unitViWORDOnLine :: TextUnit unitDelimited :: Char -> Char -> Bool -> TextUnit unitSentence :: TextUnit -- | Paragraph to implement emacs-like forward-paragraph/backward-paragraph unitEmacsParagraph :: TextUnit -- | Paragraph that begins and ends in the paragraph, not the empty lines -- surrounding it. unitParagraph :: TextUnit -- | Separator characters (space, tab, unicode separators). Most of the -- units above attempt to identify words with various punctuation -- and symbols included or excluded. This set of units is a simple -- inverse: it is true for whitespace or separators and -- false for anything that is not (letters, numbers, symbols, -- punctuation, whatever). isAnySep :: Char -> Bool -- | unitSep is true for any kind of whitespace/separator unitSep :: TextUnit -- | unitSepThisLine is true for any kind of whitespace/separator on this -- line only unitSepThisLine :: TextUnit isWordChar :: Char -> Bool -- | Move to the next unit boundary moveB :: TextUnit -> Direction -> BufferM () -- | As moveB, unless the point is at a unit boundary maybeMoveB :: TextUnit -> Direction -> BufferM () transformB :: (String -> String) -> TextUnit -> Direction -> BufferM () transposeB :: TextUnit -> Direction -> BufferM () -- | Region of the whole textunit where the current point is. regionOfB :: TextUnit -> BufferM Region -- | Non empty region of the whole textunit where the current point is. regionOfNonEmptyB :: TextUnit -> BufferM Region -- | Region between the point and the next boundary. The region is empty if -- the point is at the boundary. regionOfPartB :: TextUnit -> Direction -> BufferM Region -- | Non empty region between the point and the next boundary, In fact the -- region can be empty if we are at the end of file. regionOfPartNonEmptyB :: TextUnit -> Direction -> BufferM Region -- | Non empty region at given point and the next boundary, regionOfPartNonEmptyAtB :: TextUnit -> Direction -> Point -> BufferM Region readPrevUnitB :: TextUnit -> BufferM String readUnitB :: TextUnit -> BufferM String -- | Repeat an action until the condition is fulfilled or the cursor stops -- moving. The Action may be performed zero times. untilB :: BufferM Bool -> BufferM a -> BufferM [a] doUntilB_ :: BufferM Bool -> BufferM a -> BufferM () untilB_ :: BufferM Bool -> BufferM a -> BufferM () whileB :: BufferM Bool -> BufferM a -> BufferM [a] -- | Do an action if the current buffer character passes the predicate doIfCharB :: (Char -> Bool) -> BufferM a -> BufferM () atBoundaryB :: TextUnit -> Direction -> BufferM Bool numberOfB :: TextUnit -> TextUnit -> BufferM Int -- | Delete between point and next unit boundary, return the deleted -- region. deleteB :: TextUnit -> Direction -> BufferM () -- | Generic maybe move operation. As genMoveB, but don't move if we are at -- boundary already. genMaybeMoveB :: TextUnit -> (Direction, BoundarySide) -> Direction -> BufferM () -- | Generic move operation Warning: moving To the (OutsideBound, Backward) -- bound of Document is impossible (offset -1!) genMoveB u b d: -- move in direction d until encountering boundary b or unit u. See -- genAtBoundaryB for boundary explanation. genMoveB :: TextUnit -> (Direction, BoundarySide) -> Direction -> BufferM () -- | Boundary side data BoundarySide InsideBound :: BoundarySide OutsideBound :: BoundarySide -- | genAtBoundaryB u d s returns whether the point is at a given -- boundary (d,s) . Boundary (d,s) , taking Word as -- example, means: Word ^^ ^^ 12 34 1: (Backward,OutsideBound) 2: -- (Backward,InsideBound) 3: (Forward,InsideBound) 4: -- (Forward,OutsideBound) -- -- rules: genAtBoundaryB u Backward InsideBound = atBoundaryB u Backward -- genAtBoundaryB u Forward OutsideBound = atBoundaryB u Forward genAtBoundaryB :: TextUnit -> Direction -> BoundarySide -> BufferM Bool genEnclosingUnit :: TextUnit -> TextUnit genUnitBoundary :: TextUnit -> Direction -> BufferM Bool checkPeekB :: Int -> [Char -> Bool] -> Direction -> BufferM Bool data RegionStyle LineWise :: RegionStyle Inclusive :: RegionStyle Exclusive :: RegionStyle Block :: RegionStyle mkRegionOfStyleB :: Point -> Point -> RegionStyle -> BufferM Region unitWiseRegion :: TextUnit -> Region -> BufferM Region -- | Extend the given region to boundaries of the text unit. For instance -- one can extend the selection to complete lines, or paragraphs. extendRegionToBoundaries :: TextUnit -> BoundarySide -> BoundarySide -> Region -> BufferM Region regionStyleA :: Accessor FBuffer RegionStyle instance Typeable RegionStyle instance Typeable TextUnit instance Eq RegionStyle instance Show RegionStyle instance Initializable RegionStyle module Yi.Buffer.HighLevel -- | Move point to start of line moveToSol :: BufferM () -- | Move point to end of line moveToEol :: BufferM () -- | Move cursor to origin topB :: BufferM () -- | Move cursor to end of buffer botB :: BufferM () -- | Move left if on eol, but not on blank line leftOnEol :: BufferM () -- | Move x chars back, or to the sol, whichever is less moveXorSol :: Int -> BufferM () -- | Move x chars forward, or to the eol, whichever is less moveXorEol :: Int -> BufferM () -- | Move to first char of next word forwards nextWordB :: BufferM () -- | Move to first char of next word backwards prevWordB :: BufferM () -- | Move to the next occurence of c nextCInc :: Char -> BufferM () -- | Move to the character before the next occurence of c nextCExc :: Char -> BufferM () -- | Move to the previous occurence of c prevCInc :: Char -> BufferM () -- | Move to the character after the previous occurence of c prevCExc :: Char -> BufferM () -- | Move to first non-space character in this line firstNonSpaceB :: BufferM () -- | Move to the last non-space character in this line lastNonSpaceB :: BufferM () -- | Go to the first non space character in the line; if already there, -- then go to the beginning of the line. moveNonspaceOrSol :: BufferM () -- | Move down next n paragraphs nextNParagraphs :: Int -> BufferM () -- | Move up prev n paragraphs prevNParagraphs :: Int -> BufferM () goUnmatchedB :: Direction -> Char -> Char -> BufferM () -- | Return true if the current point is the start of a line atSol :: BufferM Bool -- | Return true if the current point is the end of a line atEol :: BufferM Bool -- | True if point at start of file atSof :: BufferM Bool -- | True if point at end of file atEof :: BufferM Bool -- | Get the current line and column number getLineAndCol :: BufferM (Int, Int) -- | Read the line the point is on readLnB :: BufferM String readCharB :: BufferM (Maybe Char) -- | Read from point to end of line readRestOfLnB :: BufferM String -- | Read from point to beginning of line readPreviousOfLnB :: BufferM String hasWhiteSpaceBefore :: BufferM Bool -- | Get the previous point, unless at the beginning of the file prevPointB :: BufferM Point -- | Get the next point, unless at the end of the file nextPointB :: BufferM Point readPrevWordB :: BufferM String -- | Delete one character backward bdeleteB :: BufferM () -- | Delete forward whitespace or non-whitespace depending on the character -- under point. killWordB :: BufferM () -- | Delete backward whitespace or non-whitespace depending on the -- character before point. bkillWordB :: BufferM () -- | capitalise the word under the cursor uppercaseWordB :: BufferM () -- | lowerise word under the cursor lowercaseWordB :: BufferM () -- | capitalise the first letter of this word capitaliseWordB :: BufferM () -- | Delete to the end of line, excluding it. deleteToEol :: BufferM () -- | Delete whole line moving to the next line deleteLineForward :: BufferM () -- | Transpose two characters, (the Emacs C-t action) swapB :: BufferM () -- | Delete trailing whitespace from all lines deleteTrailingSpaceB :: BufferM () -- | Marks -- -- Set the current buffer selection mark setSelectionMarkPointB :: Point -> BufferM () -- | Get the current buffer selection mark getSelectionMarkPointB :: BufferM Point -- | Exchange point & mark. exchangePointAndMarkB :: BufferM () getBookmarkB :: String -> BufferM Mark data BufferFileInfo BufferFileInfo :: FilePath -> Int -> Int -> Int -> Point -> String -> Bool -> BufferFileInfo bufInfoFileName :: BufferFileInfo -> FilePath bufInfoSize :: BufferFileInfo -> Int bufInfoLineNo :: BufferFileInfo -> Int bufInfoColNo :: BufferFileInfo -> Int bufInfoCharNo :: BufferFileInfo -> Point bufInfoPercent :: BufferFileInfo -> String bufInfoModified :: BufferFileInfo -> Bool -- | File info, size in chars, line no, col num, char num, percent bufInfoB :: BufferM BufferFileInfo upScreensB :: Int -> BufferM () downScreensB :: Int -> BufferM () -- | Scroll up 1 screen upScreenB :: BufferM () -- | Scroll down 1 screen downScreenB :: BufferM () -- | Scroll by n screens (negative for up) scrollScreensB :: Int -> BufferM () -- | Scroll according to function passed. The function takes the | Window -- height in lines, its result is passed to scrollB | (negative for up) scrollByB :: (Int -> Int) -> Int -> BufferM () -- | Same as scrollB, but also moves the cursor vimScrollB :: Int -> BufferM () -- | Same as scrollByB, but also moves the cursor vimScrollByB :: (Int -> Int) -> Int -> BufferM () -- | Move to middle line in screen scrollToCursorB :: BufferM () -- | Move cursor to the top of the screen scrollCursorToTopB :: BufferM () -- | Move cursor to the bottom of the screen scrollCursorToBottomB :: BufferM () -- | Scroll by n lines. scrollB :: Int -> BufferM () -- | Move the point to inside the viewable region snapInsB :: BufferM () -- | return index of Sol on line n above current line indexOfSolAbove :: Int -> BufferM Point -- | Move the visible region to include the point snapScreenB :: BufferM Bool -- | Move to n lines down from top of screen downFromTosB :: Int -> BufferM () -- | Move to n lines up from the bottom of the screen upFromBosB :: Int -> BufferM () -- | Move to middle line in screen middleB :: BufferM () pointInWindowB :: Point -> BufferM Bool -- | Return the region between point and mark getRawestSelectRegionB :: BufferM Region -- | Return the empty region if the selection is not visible. getRawSelectRegionB :: BufferM Region -- | Get the current region boundaries. Extended to the current selection -- unit. getSelectRegionB :: BufferM Region -- | Select the given region: set the selection mark at the -- regionStart and the current point at the regionEnd. setSelectRegionB :: Region -> BufferM () -- | Extend the selection mark using the given region. extendSelectRegionB :: Region -> BufferM () deleteBlankLinesB :: BufferM () -- | Get a (lazy) stream of lines in the buffer, starting at the -- next line in the given direction. lineStreamB :: Direction -> BufferM [String] getMaybeNextLineB :: Direction -> BufferM (Maybe String) getNextLineB :: Direction -> BufferM String getNextLineWhichB :: Direction -> (String -> Bool) -> BufferM (Maybe String) getNextNonBlankLineB :: Direction -> BufferM String -- | Uses a string modifying function to modify the current selection -- Currently unsets the mark such that we have no selection, arguably we -- could instead work out where the new positions should be and move the -- mark and point accordingly. modifySelectionB :: (String -> String) -> BufferM () modifyExtendedSelectionB :: TextUnit -> (String -> String) -> BufferM () -- | Prefix each line in the selection using the given string. linePrefixSelectionB :: String -> BufferM () -- | Uncomments the selection using the given line comment starting string. -- This only works for the comments which begin at the start of the line. unLineCommentSelectionB :: String -> String -> BufferM () -- | Toggle line comments in the selection by adding or removing a prefix -- to each line. toggleCommentSelectionB :: String -> String -> BufferM () -- | Justifies all the lines of the selection to be the same as the top -- line. NOTE: if the selection begins part way along a line, the other -- lines will be justified only with respect to the part of the -- indentation which is selected. justifySelectionWithTopB :: BufferM () -- | Replace the contents of the buffer with some string replaceBufferContent :: String -> BufferM () -- | Fill the text in the region so it fits nicely 80 columns. fillRegion :: Region -> BufferM () fillParagraph :: BufferM () -- | Sort the lines of the region. sortLines :: BufferM () -- | Helper function: revert the buffer contents to its on-disk version revertB :: String -> UTCTime -> BufferM () module Yi.Buffer.Indent -- | Return either a t or the number of spaces specified by tabSize in the -- IndentSettings. Note that if you actually want to insert a tab -- character (for example when editing makefiles) then you should use: -- insertB '\t'. tabB :: BufferM String -- | Retrieve the current indentation settings for the buffer. indentSettingsB :: BufferM IndentSettings -- | A specialisation of autoIndentHelperB. This is the most basic -- and the user is encouraged to specialise autoIndentHelperB on -- their own. autoIndentB :: IndentBehaviour -> BufferM () -- | This takes two arguments the first is a function to obtain indentation -- hints from lines above the current one. The second is a function to -- obtain a set of indentation hints from the previous line. Both of -- these are in the BufferM monad although the second seems like -- it is unnecessary. However we must take into account the length of -- tabs which come from the the tab settings and hence we must be in the -- BufferM monad. -- -- To get the straightforward behaviour of the indents of all previous -- lines until one of them has zero indent call this with: -- autoIndentHelperB fetchPreviousIndentsB (fmap (: []) -- indentOfB) However commonly we wish to have something more -- interesting for the second argument, in particular we commonly wish to -- have the last opening bracket of the previous line as well as its -- indent. autoIndentHelperB :: BufferM [Int] -> (String -> BufferM [Int]) -> IndentBehaviour -> BufferM () -- | Cycles through the indentation hints. It does this without requiring -- to set/get any state. We just look at the current indentation of the -- current line and moving to the largest indent that is cycleIndentsB :: IndentBehaviour -> [Int] -> BufferM () -- | A function generally useful as the first argument to -- autoIndentHelperB. This searches the lines above the current -- line for the indentations of each line until we get to a line which -- has no indentation *and* is not empty. Indicating that we have reached -- the outer scope. fetchPreviousIndentsB :: BufferM [Int] -- | An application of autoIndentHelperB which adds more indentation -- hints using the given keywords. The offsets of the first set of -- keywords are used as hints. For the second set of keywords it is not -- the offsets of the keywords themselves but the offset of the first -- non-white characters after the keywords. -- -- In addition to the keyword hints we also do the same as the default -- (autoIndentB) which is to use any non-closed opening brackets -- as hints. autoIndentWithKeywordsB :: [String] -> [String] -> IndentBehaviour -> BufferM () -- | Returns the position of the last opening bracket on the line which is -- not closed on the same line. Note that if we have unmatched -- parentheses such as ( ] then we may not get the correct answer, -- but in that case then arguably we don't really care if we get the -- correct answer (at least if we get it wrong the user may notice their -- error). We return a list here as it's a convenient way of returning no -- hint in the case of there being no non-closed bracket and normally -- such a hint will be part of a list of hints anyway. NOTE: this could -- be easily modified to return the indentations of *all* the non-closed -- opening brackets. But I think this is not what you generally want. -- TODO: we also do not care whether or not the bracket is within a -- string or escaped. If someone feels up to caring about that by all -- means please fix this. lastOpenBracketHint :: String -> BufferM [Int] -- | Returns the offsets of all the given keywords within the given string. -- This is potentially useful as providing indentation hints. keywordHints :: [String] -> String -> BufferM [Int] -- | Returns the offsets of anything that isn't white space after -- a keyword on the given line. This is essentially then the same as -- keywordHints except that for each keyword on the input rather -- than return the offset at the start of the keyword we return the -- offset of the first non-white character after the keyword. keywordAfterHints :: [String] -> String -> BufferM [Int] -- | Returns the indentation of a given string. Note that this depends on -- the current indentation settings. indentOfB :: String -> BufferM Int -- | Returns the length of a given string taking into account the white -- space and the indentation settings. spacingOfB :: String -> BufferM Int -- | Indents the current line to the given indentation level. In addition -- moves the point according to where it was on the line originally. If -- we were somewhere within the indentation (ie at the start of the line -- or on an empty line) then we want to just go to the end of the (new) -- indentation. However if we are currently pointing somewhere within the -- text of the line then we wish to remain pointing to the same -- character. indentToB :: Int -> BufferM () -- | Indent as much as the previous line indentAsPreviousB :: BufferM () -- | Insert a newline at point and indent the new line as the previous one. newlineAndIndentB :: BufferM () -- | Set the padding of the string to newCount, filling in tabs if -- expandTabs is set in the buffers IndentSettings rePadString :: IndentSettings -> Int -> String -> String -- | shifts right (or left if num is negative) num times, filling in tabs -- if expandTabs is set in the buffers IndentSettings indentString :: IndentSettings -> Int -> String -> String -- | Increases the indentation on the region by the given amount of -- shiftWidth shiftIndentOfRegion :: Int -> Region -> BufferM () deleteIndentOfRegion :: Region -> BufferM () -- | Return the number of spaces at the beginning of the line, up to the -- point. indentOfCurrentPosB :: BufferM Int -- | The Buffer module defines monadic editing operations over -- one-dimensional buffers, maintaining a current point. -- -- This module acts as a Facade for the Buffer.* modules. module Yi.Buffer data UIUpdate TextUpdate :: !Update -> UIUpdate StyleUpdate :: !Point -> !Size -> UIUpdate -- | Mutation actions (also used the undo or redo list) -- -- For the undoredo, we use the partial checkpoint/ (Berlage, -- pg16) strategy to store just the components of the state that change. -- -- Note that the update direction is only a hint for moving the cursor -- (mainly for undo purposes); the insertions and deletions are always -- applied Forward. data Update Insert :: !Point -> !Direction -> !Rope -> Update updatePoint :: Update -> !Point updateDirection :: Update -> !Direction insertUpdateString :: Update -> !Rope Delete :: !Point -> !Direction -> !Rope -> Update updatePoint :: Update -> !Point updateDirection :: Update -> !Direction deleteUpdateString :: Update -> !Rope updateIsDelete :: Update -> Bool module Yi.Config data UIConfig UIConfig :: Int -> Maybe String -> Maybe Int -> Bool -> Bool -> Bool -> Bool -> Char -> Theme -> UIConfig configVtyEscDelay :: UIConfig -> Int -- | Font name, for the UI that support it. configFontName :: UIConfig -> Maybe String -- | Font size, for the UI that support it. configFontSize :: UIConfig -> Maybe Int -- | Should the scrollbar be shown on the left side? configLeftSideScrollBar :: UIConfig -> Bool -- | Hide scrollbar automatically if text fits on one page. configAutoHideScrollBar :: UIConfig -> Bool -- | Hide the tabbar automatically if only one tab is present configAutoHideTabBar :: UIConfig -> Bool -- | Wrap lines at the edge of the window if too long to display. configLineWrap :: UIConfig -> Bool -- | The char with which to fill empty window space. Usually '~' for -- vi-like editors, ' ' for everything else. configWindowFill :: UIConfig -> Char -- | UI colours configTheme :: UIConfig -> Theme configStyle :: UIConfig -> UIStyle -- | Configuration record. All Yi hooks can be set here. data Config Config :: UIBoot -> UIConfig -> [Action] -> [Action] -> KeymapSet -> P Event Event -> [AnyMode] -> Map String [Dynamic] -> Bool -> RegionStyle -> Bool -> [([Update] -> BufferM ())] -> Config -- | UI to use. startFrontEnd :: Config -> UIBoot -- | UI-specific configuration. configUI :: Config -> UIConfig -- | Actions to run when the editor is started. startActions :: Config -> [Action] -- | Actions to run after startup (after startActions) or reload. initialActions :: Config -> [Action] -- | Default keymap to use. defaultKm :: Config -> KeymapSet configInputPreprocess :: Config -> P Event Event -- | List modes by order of preference. modeTable :: Config -> [AnyMode] -- | Actions available in the interpreter (akin to M-x in emacs) publishedActions :: Config -> Map String [Dynamic] -- | Produce a .yi.dbg file with a lot of debug information. debugMode :: Config -> Bool -- | Set to Exclusive for an emacs-like behaviour. configRegionStyle :: Config -> RegionStyle -- | Set to True for an emacs-like behaviour, where all deleted text -- is accumulated in a killring. configKillringAccumulate :: Config -> Bool bufferUpdateHandler :: Config -> [([Update] -> BufferM ())] configFundamentalMode :: Config -> AnyMode configTopLevelKeymap :: Config -> Keymap type UIBoot = Config -> (Event -> IO ()) -> ([Action] -> IO ()) -> Editor -> IO UI -- | The top level editor state, and operations on it. module Yi.Editor type Status = ([String], StyleName) type Statuses = DelayList Status -- | The Editor state data Editor Editor :: ![BufferRef] -> !Map BufferRef FBuffer -> !Int -> !PointedList (PointedList Window) -> !DynamicValues -> !Statuses -> !Int -> !Killring -> !Maybe SearchExp -> !Direction -> ![Event] -> !Map BufferRef (EditorM ()) -> Editor -- | Stack of all the buffers. Invariant: never empty Invariant: first -- buffer is the current one. bufferStack :: Editor -> ![BufferRef] buffers :: Editor -> !Map BufferRef FBuffer -- | Supply for buffer and window ids. refSupply :: Editor -> !Int -- | current tab contains the visible windows pointed list. tabs_ :: Editor -> !PointedList (PointedList Window) -- | dynamic components dynamic :: Editor -> !DynamicValues statusLines :: Editor -> !Statuses maxStatusHeight :: Editor -> !Int killring :: Editor -> !Killring -- | currently highlighted regex (also most recent regex for use in vim -- bindings) currentRegex :: Editor -> !Maybe SearchExp searchDirection :: Editor -> !Direction -- | Processed events that didn't yield any action yet. pendingEvents :: Editor -> ![Event] -- | Actions to be run when the buffer is closed; should be scrapped. onCloseActions :: Editor -> !Map BufferRef (EditorM ()) newtype EditorM a EditorM :: RWS Config () Editor a -> EditorM a fromEditorM :: EditorM a -> RWS Config () Editor a class (Monad m, MonadState Editor m) => MonadEditor m askCfg :: (MonadEditor m) => m Config withEditor :: (MonadEditor m) => EditorM a -> m a liftEditor :: (MonadEditor m) => EditorM a -> m a -- | The initial state emptyEditor :: Editor runEditor :: Config -> EditorM a -> Editor -> (Editor, a) onCloseActionsA :: T Editor (Map BufferRef (EditorM ())) pendingEventsA :: T Editor ([] Event) searchDirectionA :: T Editor Direction currentRegexA :: T Editor (Maybe SearchExp) killringA :: T Editor Killring maxStatusHeightA :: T Editor Int statusLinesA :: T Editor Statuses dynamicA :: T Editor DynamicValues tabs_A :: T Editor (PointedList (PointedList Window)) refSupplyA :: T Editor Int buffersA :: T Editor (Map BufferRef FBuffer) bufferStackA :: T Editor ([] BufferRef) windows :: Editor -> PointedList Window windowsA :: Accessor Editor (PointedList Window) tabsA :: Accessor Editor (PointedList (PointedList Window)) dynA :: (Initializable a) => Accessor Editor a newRef :: EditorM Int newBufRef :: EditorM BufferRef -- | Create and fill a new buffer, using contents of string. | Does not -- focus the window, or make it the current window. | Call newWindowE or -- switchToBufferE to take care of that. stringToNewBuffer :: BufferId -> Rope -> EditorM BufferRef insertBuffer :: FBuffer -> EditorM () forceFold1 :: (Foldable t) => t a -> t a forceFold2 :: (Foldable t1, Foldable t2) => t1 (t2 a) -> t1 (t2 a) -- | Delete a buffer (and release resources associated with it). deleteBuffer :: BufferRef -> EditorM () -- | Return the buffers we have, in no particular order bufferSet :: Editor -> [FBuffer] -- | Return a prefix that can be removed from all buffer paths while -- keeping them unique. commonNamePrefix :: Editor -> [String] getBufferStack :: EditorM [FBuffer] findBuffer :: BufferRef -> EditorM (Maybe FBuffer) -- | Find buffer with this key findBufferWith :: BufferRef -> Editor -> FBuffer -- | Find buffer with this name findBufferWithName :: String -> Editor -> [BufferRef] -- | Find buffer with given name. Fail if not found. getBufferWithName :: String -> EditorM BufferRef -- | Make all buffers visible by splitting the current window list. FIXME: -- rename to displayAllBuffersE; make sure buffers are not open twice. openAllBuffersE :: EditorM () -- | Rotate the buffer stack by the given amount. shiftBuffer :: Int -> EditorM () -- | Perform action with any given buffer, using the last window that was -- used for that buffer. withGivenBuffer0 :: BufferRef -> BufferM a -> EditorM a -- | Perform action with any given buffer withGivenBufferAndWindow0 :: Window -> BufferRef -> BufferM a -> EditorM a -- | Perform action with current window's buffer withBuffer0 :: BufferM a -> EditorM a currentWindowA :: Accessor Editor Window -- | Return the current buffer currentBuffer :: Editor -> BufferRef -- | Display a transient message printMsg :: String -> EditorM () printMsgs :: [String] -> EditorM () printStatus :: Status -> EditorM () -- | Set the background status line setStatus :: Status -> EditorM () -- | Clear the status line clrStatus :: EditorM () statusLine :: Editor -> [String] statusLineInfo :: Editor -> Status setTmpStatus :: Int -> Status -> EditorM () -- | Put string into yank register setRegE :: String -> EditorM () -- | Return the contents of the yank register getRegE :: EditorM String -- | Dynamically-extensible state components. -- -- These hooks are used by keymaps to store values that result from -- Actions (i.e. that restult from IO), as opposed to the pure values -- they generate themselves, and can be stored internally. -- -- The dynamic field is a type-indexed map. -- -- Retrieve a value from the extensible state getDynamic :: (Initializable a) => EditorM a -- | Insert a value into the extensible state, keyed by its type setDynamic :: (Initializable a) => a -> EditorM () -- | Attach the next buffer in the buffer stack to the current window. nextBufW :: EditorM () -- | Attach the previous buffer in the stack list to the current window. prevBufW :: EditorM () -- | Like fnewE, create a new buffer filled with the String s, -- Switch the current window to this buffer. Doesn't associate any file -- with the buffer (unlike fnewE) and so is good for popup internal -- buffers (like scratch) newBufferE :: BufferId -> Rope -> EditorM BufferRef -- | Creates an in-memory buffer with a unique name. -- -- A hint for the buffer naming scheme can be specified in the dynamic -- variable TempBufferNameHint The new buffer always has a buffer ID that -- did not exist before newTempBufferE. TODO: this probably a lot more -- complicated than it should be: why not count from zero every time? newTempBufferE :: EditorM BufferRef -- | Specifies the hint for the next temp buffer's name. data TempBufferNameHint TempBufferNameHint :: String -> Int -> TempBufferNameHint tmp_name_base :: TempBufferNameHint -> String tmp_name_index :: TempBufferNameHint -> Int alternateBufferE :: Int -> EditorM () -- | Create a new window onto the given buffer. newWindowE :: Bool -> BufferRef -> EditorM Window -- | Attach the specified buffer to the current window switchToBufferE :: BufferRef -> EditorM () -- | Attach the specified buffer to some other window than the current one switchToBufferOtherWindowE :: BufferRef -> EditorM () -- | Switch to the buffer specified as parameter. If the buffer name is -- empty, switch to the next buffer. switchToBufferWithNameE :: String -> EditorM () -- | Close a buffer. Note: close the current buffer if the empty string is -- given closeBufferE :: String -> EditorM () getBufferWithNameOrCurrent :: String -> EditorM BufferRef -- | Close current buffer and window, unless it's the last one. closeBufferAndWindowE :: EditorM () -- | Rotate focus to the next window nextWinE :: EditorM () -- | Rotate focus to the previous window prevWinE :: EditorM () -- | A fake accessor that fixes the current buffer after a change of -- the current window. Enforces invariant that top of buffer stack is the -- buffer of the current window. fixCurrentBufferA_ :: Accessor Editor Editor -- | Counterpart of fixCurrentBufferA_: fix the current window to point to -- the right buffer. fixCurrentWindow :: EditorM () withWindowE :: Window -> BufferM a -> EditorM a findWindowWith :: WindowRef -> Editor -> Window -- | Return the windows that are currently open on the buffer whose key is -- given windowsOnBufferE :: BufferRef -> EditorM [Window] -- | bring the editor focus the window with the given key. -- -- Fails if no window with the given key is found. focusWindowE :: WindowRef -> EditorM () -- | Split the current window, opening a second window onto current buffer. -- TODO: unfold newWindowE here? splitE :: EditorM () -- | Enlarge the current window enlargeWinE :: EditorM () -- | Shrink the current window shrinkWinE :: EditorM () -- | Creates a new tab containing a window that views the current buffer. newTabE :: EditorM () -- | Moves to the next tab in the round robin set of tabs nextTabE :: EditorM () -- | Moves to the previous tab in the round robin set of tabs previousTabE :: EditorM () -- | Moves the focused tab to the given index, or to the end if the index -- is not specified. moveTab :: Maybe Int -> EditorM () -- | Deletes the current tab. If there is only one tab open then error out. -- When the last tab is focused, move focus to the left, otherwise move -- focus to the right. deleteTabE :: EditorM () -- | Close the current window. If there is only one tab open and the tab -- contains only one window then do nothing. tryCloseE :: EditorM () -- | Make the current window the only window on the screen closeOtherE :: EditorM () -- | Switch focus to some other window. If none is available, create one. shiftOtherWindow :: (MonadEditor m) => m () -- | Execute the argument in the context of an other window. Create one if -- necessary. The current window is re-focused after the argument has -- completed. withOtherWindow :: (MonadEditor m) => m a -> m a acceptedInputs :: EditorM [String] -- | Defines an action to be executed when the current buffer is closed. -- -- Used by the minibuffer to assure the focus is restored to the buffer -- that spawned the minibuffer. -- -- todo: These actions are not restored on reload. -- -- todo: These actions should probably be very careful at what they do. -- TODO: All in all, this is a very ugly way to achieve the purpose. The -- nice way to proceed is to somehow attach the miniwindow to the window -- that has spawned it. onCloseBufferE :: BufferRef -> EditorM () -> EditorM () instance Typeable TempBufferNameHint instance Show TempBufferNameHint instance Initializable TempBufferNameHint instance Typeable Editor instance Typeable1 EditorM instance Monad EditorM instance MonadState Editor EditorM instance MonadReader Config EditorM instance Functor EditorM instance MonadEditor EditorM instance Applicative EditorM instance Binary Editor module Yi.UI.Common data UI UI :: IO () -> (Bool -> IO ()) -> IO () -> (Editor -> IO ()) -> IO () -> (Editor -> IO Editor) -> (FilePath -> IO ()) -> UI -- | Main loop main :: UI -> IO () -- | Clean up, and also terminate if given true end :: UI -> Bool -> IO () -- | Suspend (or minimize) the program suspend :: UI -> IO () -- | Refresh the UI with the given state refresh :: UI -> Editor -> IO () -- | User force-refresh (in case the screen has been messed up from -- outside) userForceRefresh :: UI -> IO () -- | Set window width and height layout :: UI -> Editor -> IO Editor -- | Reload cabal project views reloadProject :: UI -> FilePath -> IO () dummyUI :: UI module Yi.UI.Batch -- | Initialise the ui start :: UIBoot -- | Utilities shared by various UIs module Yi.UI.Utils indexedAnnotatedStreamB :: Point -> BufferM [(Point, Char)] applyHeights :: (Traversable t) => [Int] -> t Window -> t Window spliceAnnots :: [(Point, Char)] -> [Span String] -> [(Point, Char)] -- | Turn a sequence of (from,style,to) strokes into a sequence of picture -- points (from,style), taking special care to ensure that the points are -- strictly increasing and introducing padding segments where neccessary. -- Precondition: Strokes are ordered and not overlapping. strokePicture :: [Span (Endo a)] -> [(Point, a -> a)] -- | Paint the given stroke-picture on top of an existing picture paintStrokes :: (a -> a) -> a -> [(Point, a -> a)] -> [(Point, a)] -> [(Point, a)] paintPicture :: a -> [[Span (Endo a)]] -> [(Point, a)] attributesPictureB :: UIStyle -> Maybe SearchExp -> Region -> [[Span StyleName]] -> BufferM [(Point, Attributes)] attributesPictureAndSelB :: UIStyle -> Maybe SearchExp -> Region -> BufferM [(Point, Attributes)] -- | Arrange a list of items in columns over maximum -- maxNumberOfLines lines arrangeItems :: [String] -> Int -> Int -> [String] -- | Arrange a list of items in columns over numberOfLines lines. arrangeItems' :: [String] -> Int -> Int -> (Int, [String]) module Yi.UI.TabBar -- | A TabDescr describes the properties of a UI tab independent of the -- particular GUI in use. data TabDescr TabDescr :: String -> Bool -> TabDescr tabText :: TabDescr -> String tabInFocus :: TabDescr -> Bool type TabBarDescr = PointedList TabDescr tabBarDescr :: Editor -> TabBarDescr tabAbbrevTitle :: String -> String module Yi.Process -- | A Posix.popen compatibility mapping. Based on PosixCompat, originally -- written by Derek Elkins for lambdabot TODO: this will probably be -- called readProcess in the new process package (2.0) popen :: FilePath -> [String] -> Maybe String -> IO (String, String, ExitCode) -- | Run a command. This looks up a program name in $PATH, but then calls -- it directly with the argument. runProgCommand :: String -> [String] -> IO (String, String, ExitCode) runShellCommand :: String -> IO (String, String, ExitCode) -- | Run a command using the system shell, returning stdout, stderr and -- exit code shellFileName :: IO String createSubprocess :: FilePath -> [String] -> BufferRef -> IO SubprocessInfo readAvailable :: Handle -> IO String data SubprocessInfo SubprocessInfo :: FilePath -> [String] -> ProcessHandle -> Handle -> Handle -> Handle -> BufferRef -> Bool -> SubprocessInfo procCmd :: SubprocessInfo -> FilePath procArgs :: SubprocessInfo -> [String] procHandle :: SubprocessInfo -> ProcessHandle hIn :: SubprocessInfo -> Handle hOut :: SubprocessInfo -> Handle hErr :: SubprocessInfo -> Handle bufRef :: SubprocessInfo -> BufferRef separateStdErr :: SubprocessInfo -> Bool type SubprocessId = Integer module Yi.Keymap data Action YiA :: (YiM a) -> Action EditorA :: (EditorM a) -> Action BufferA :: (BufferM a) -> Action TaggedA :: String -> Action -> Action emptyAction :: Action type Interact ev a = I ev Action a type KeymapM a = Interact Event a type Keymap = KeymapM () type KeymapEndo = Keymap -> Keymap type KeymapProcess = P Event Action data Yi Yi :: UI -> (Event -> IO ()) -> ([Action] -> IO ()) -> Config -> MVar YiVar -> Yi yiUi :: Yi -> UI -- | input stream input :: Yi -> Event -> IO () -- | output stream output :: Yi -> [Action] -> IO () yiConfig :: Yi -> Config -- | The only mutable state in the program yiVar :: Yi -> MVar YiVar data YiVar YiVar :: !Editor -> ![ThreadId] -> !SubprocessId -> !Map SubprocessId SubprocessInfo -> YiVar yiEditor :: YiVar -> !Editor -- | all our threads threads :: YiVar -> ![ThreadId] yiSubprocessIdSupply :: YiVar -> !SubprocessId yiSubprocesses :: YiVar -> !Map SubprocessId SubprocessInfo -- | The type of user-bindable functions newtype YiM a YiM :: ReaderT Yi IO a -> YiM a runYiM :: YiM a -> ReaderT Yi IO a -- | write a returns a keymap that just outputs the action -- a. write :: (MonadInteract m Action ev, YiAction a x, Show x) => a -> m () withUI :: (UI -> IO a) -> YiM a unsafeWithEditor :: Config -> MVar YiVar -> EditorM a -> IO a withGivenBuffer :: BufferRef -> BufferM a -> YiM a withBuffer :: BufferM a -> YiM a readEditor :: (Editor -> a) -> YiM a catchDynE :: (Typeable exception) => YiM a -> (exception -> YiM a) -> YiM a catchJustE :: (Exception -> Maybe b) -> YiM a -> (b -> YiM a) -> YiM a handleJustE :: (Exception -> Maybe b) -> (b -> YiM a) -> YiM a -> YiM a -- | Shut down all of our threads. Should free buffers etc. shutdown :: YiM () class YiAction a x | a -> x makeAction :: (YiAction a x, Show x) => a -> Action data KeymapSet KeymapSet :: Keymap -> Keymap -> Keymap -> Keymap -> KeymapSet -- | Content of the top-level loop. topKeymap :: KeymapSet -> Keymap -- | Startup when entering insert mode startInsertKeymap :: KeymapSet -> Keymap -- | For insertion-only modes insertKeymap :: KeymapSet -> Keymap -- | Startup bit, to execute only once at the beginning. startTopKeymap :: KeymapSet -> Keymap startTopKeymapA :: T KeymapSet Keymap insertKeymapA :: T KeymapSet Keymap startInsertKeymapA :: T KeymapSet Keymap topKeymapA :: T KeymapSet Keymap extractTopKeymap :: KeymapSet -> Keymap modelessKeymapSet :: Keymap -> KeymapSet instance Typeable1 YiM instance Typeable Yi instance Typeable Action instance Monad YiM instance MonadReader Yi YiM instance MonadIO YiM instance Functor YiM instance PEq Event instance YiAction Action () instance YiAction (BufferM x) x instance YiAction (EditorM x) x instance YiAction (YiM x) x instance YiAction (IO x) x instance MonadEditor YiM instance MonadState Editor YiM instance Show Action instance PEq Action -- | This module defines a user interface implemented using gtk2hs and -- pango for direct text rendering. module Yi.UI.Pango -- | Initialise the ui start :: UIBoot processEvent :: (Event -> IO ()) -> Event -> IO Bool instance Show WinInfo instance Show TabInfo -- | Templates for inserting into documents module Yi.Templates templates :: TemplateLookup templateNames :: [TemplateName] lookupTemplate :: TemplateName -> Maybe Template addTemplate :: String -> EditorM () -- | Combinators for building keymaps. module Yi.Keymap.Keys printableChar :: (MonadInteract m w Event) => m Char charOf :: (MonadInteract m w Event) => (Event -> Event) -> Char -> Char -> m Char shift :: Event -> Event meta :: Event -> Event ctrl :: Event -> Event super :: Event -> Event -- | Convert a special key into an event spec :: Key -> Event char :: Char -> Event (>>!) :: (MonadInteract m Action Event, YiAction a x, Show x) => m b -> a -> m () (>>=!) :: (MonadInteract m Action Event, YiAction a x, Show x) => m b -> (b -> a) -> m () (?>>) :: (MonadInteract m action Event) => Event -> m a -> m a (?>>!) :: (MonadInteract m Action Event, YiAction a x, Show x) => Event -> a -> m () (?*>>) :: (MonadInteract m action Event) => [Event] -> m a -> m a (?*>>!) :: (MonadInteract m Action Event, YiAction a x, Show x) => [Event] -> a -> m () ctrlCh :: Char -> Event metaCh :: Char -> Event -- | optMod f ev produces a MonadInteract that consumes -- ev or f ev optMod :: (MonadInteract m w Event) => (Event -> Event) -> Event -> m Event pString :: (MonadInteract m w Event) => String -> m [Event] -- | The core actions of yi. This module is the link between the editor and -- the UI. Key bindings, and libraries should manipulate Yi through the -- interface defined here. module Yi.Core -- | Start up the editor, setting any state with the user preferences and -- file names passed in, and turning on the UI startEditor :: Config -> Maybe Editor -> IO () -- | Quit. quitEditor :: YiM () -- | Redraw refreshEditor :: YiM () -- | Suspend the program suspendEditor :: YiM () userForceRefresh :: YiM () msgEditor :: String -> YiM () -- | Show an error on the status line and log it. errorEditor :: String -> YiM () -- | Close the current window. If this is the last window open, quit the -- program. CONSIDER: call quitEditor when there are no other window in -- the interactive function. (Not possible since the windowset -- type disallows it -- should it be relaxed?) closeWindow :: YiM () -- | Pipe a string through an external command, returning the stdout chomp -- any trailing newline (is this desirable?) -- -- Todo: varients with marks? runProcessWithInput :: String -> String -> YiM String -- | Start a subprocess with the given command and arguments. startSubprocess :: FilePath -> [String] -> (Either Exception ExitCode -> YiM x) -> YiM BufferRef sendToProcess :: BufferRef -> String -> YiM () runAction :: Action -> YiM () withSyntax :: (Show x, YiAction a x) => (forall syntax. Mode syntax -> syntax -> a) -> YiM () focusAllSyntax :: Editor -> Editor module Yi.UI.Pango.Control data Control Control :: Yi -> IORef [TabInfo] -> IORef (Map WindowRef View) -> Control controlYi :: Control -> Yi tabCache :: Control -> IORef [TabInfo] views :: Control -> IORef (Map WindowRef View) newtype ControlM a ControlM :: ReaderT Control IO a -> ControlM a runControl'' :: ControlM a -> ReaderT Control IO a data Buffer Buffer :: BufferRef -> Buffer fBufRef :: Buffer -> BufferRef data View View :: BufferRef -> WindowRef -> DrawingArea -> PangoLayout -> Language -> FontMetrics -> ScrolledWindow -> IORef Point -> IORef (Maybe (ConnectId DrawingArea)) -> View viewFBufRef :: View -> BufferRef windowRef :: View -> WindowRef drawArea :: View -> DrawingArea layout :: View -> PangoLayout language :: View -> Language metrics :: View -> FontMetrics scrollWin :: View -> ScrolledWindow shownTos :: View -> IORef Point winMotionSignal :: View -> IORef (Maybe (ConnectId DrawingArea)) data Iter Iter :: BufferRef -> Point -> Iter iterFBufRef :: Iter -> BufferRef point :: Iter -> Point startControl :: Config -> ControlM () -> IO () runControl :: ControlM a -> Control -> IO a controlIO :: IO a -> ControlM a liftYi :: YiM a -> ControlM a getControl :: ControlM Control newBuffer :: BufferId -> String -> ControlM Buffer newView :: Buffer -> FontDescription -> ControlM View getBuffer :: View -> Buffer setBufferMode :: FilePath -> Buffer -> ControlM () withBuffer :: Buffer -> BufferM a -> ControlM a setText :: Buffer -> String -> ControlM () getText :: Buffer -> Iter -> Iter -> ControlM String instance Typeable1 ControlM instance Monad ControlM instance MonadIO ControlM instance MonadReader Control ControlM instance Functor ControlM instance Applicative ControlM instance Show TabInfo module Yi.File -- | Try to write a file in the manner of vi/vim Need to catch any -- exception to avoid losing bindings viWrite :: YiM () -- | Try to write to a named file in the manner of vi/vim viWriteTo :: String -> YiM () -- | Try to write to a named file if it doesn't exist. Error out if it -- does. viSafeWriteTo :: String -> YiM () -- | Write current buffer to disk, if this buffer is associated with a file fwriteE :: YiM () -- | Write a given buffer to disk if it is associated with a file. fwriteBufferE :: BufferRef -> YiM () -- | Write all open buffers fwriteAllE :: YiM () -- | Write current buffer to disk as f. The file is also set to -- f fwriteToE :: String -> YiM () -- | Make a backup copy of file backupE :: FilePath -> YiM () -- | Revert to the contents of the file on disk revertE :: YiM () -- | Associate buffer with file; canonicalize the given path name. setFileName :: BufferRef -> FilePath -> YiM () -- | Provides functions for calling Hoogle on the commandline, and -- processing results into a form useful for completion or insertion. module Yi.Hoogle -- | Remove anything starting with uppercase letter. These denote either -- module names or types. caseSensitize :: [String] -> [String] -- | Hoogle's output includes a sort of type keyword, telling whether a hit -- is a package name, syntax, a module name, etc. But we care primarily -- about the function names, so we filter out anything containing the -- keywords. gv :: [String] -> [String] -- | Query Hoogle, with given search and options. This errors out on no -- results or if the hoogle command is not on path. hoogleRaw :: String -> String -> IO [String] -- | Filter the output of hoogleRaw to leave just functions. hoogleFunctions :: String -> IO [String] -- | Return module-function pairs. hoogleFunModule :: String -> IO [(String, String)] -- | Call out to hoogleFunModule, and overwrite the word at point -- with the first returned function. hoogle :: YiM String -- | Call out to hoogleRaw, and print inside the Minibuffer the -- results of searching Hoogle with the word at point. hoogleSearch :: YiM () module Yi.Mode.Buffers listBuffers :: YiM () module Yi.Completion -- | Complete a string given a user input string, a matching function and a -- list of possibilites. Matching function should return the part of the -- string that matches the user string. completeInList :: String -> (String -> Maybe String) -> [String] -> EditorM String completeInList' :: String -> (String -> Maybe String) -> [String] -> EditorM String -- | Return the longest common prefix of a set of lists. -- --
-- P(xs) === all (isPrefixOf (commonPrefix xs)) xs -- length s > length (commonPrefix xs) --> not (all (isPrefixOf s) xs) --commonPrefix :: (Eq a) => [[a]] -> [a] -- | Prefix matching function, for use with completeInList prefixMatch :: String -> String -> Maybe String -- | Infix matching function, for use with completeInList infixMatch :: String -> String -> Maybe String containsMatch' :: Bool -> String -> String -> Maybe String containsMatch :: String -> String -> Maybe String containsMatchCaseInsensitive :: String -> String -> Maybe String mkIsPrefixOf :: Bool -> String -> String -> Bool module Yi.TextCompletion wordComplete :: YiM () wordComplete' :: Bool -> YiM () wordCompleteString :: YiM String wordCompleteString' :: Bool -> YiM String -- | Try to complete the current word with occurences found elsewhere in -- the editor. Further calls try other options. mkWordComplete :: YiM String -> (String -> YiM [String]) -> ([String] -> YiM ()) -> (String -> String -> Bool) -> YiM String -- | Switch out of completion mode. resetComplete :: EditorM () completeWordB :: EditorM () instance Typeable Completion instance Initializable Completion -- | This module defines a list type and operations on it; it further -- provides functions which write in and out the list. The goal is to -- make it easy for the user to store a large number of text buffers and -- cycle among them, making edits as she goes. The idea is inspired by -- "incremental reading", see -- http://en.wikipedia.org/wiki/Incremental_reading. module Yi.IReader type Article = ByteString type ArticleDB = Seq Article -- | Take an ArticleDB, and return the first Article and an -- ArticleDB - *without* that article. split :: ArticleDB -> (Article, ArticleDB) -- | Get the first article in the list. We use the list to express relative -- priority; the first is the most, the last least. We then just cycle -- through - every article gets equal time. getLatestArticle :: ArticleDB -> Article -- | We remove the old first article, and we stick it on the end of the -- list using the presumably modified version. removeSetLast :: ArticleDB -> Article -> ArticleDB shift :: Int -> ArticleDB -> ArticleDB -- | Insert a new article with top priority (that is, at the front of the -- list). insertArticle :: ArticleDB -> Article -> ArticleDB -- | In the background, serialize given ArticleDB out. writeDB :: ArticleDB -> YiM () -- | Read in database from dbLocation and then parse it into an -- ArticleDB. readDB :: YiM ArticleDB -- | The canonical location. We assume ~/.yi has been set up already. dbLocation :: IO FilePath -- | Returns the database as it exists on the disk, and the current Yi -- buffer contents. Note that the Initializable typeclass gives us an -- empty Seq. So first we try the buffer state in the hope we can avoid a -- very expensive read from disk, and if we find nothing (that is, if we -- get an empty Seq), only then do we call readDB. oldDbNewArticle :: YiM (ArticleDB, Article) getBufferContents :: BufferM String -- | Given an ArticleDB, dump the scheduled article into the buffer -- (replacing previous contents). setDisplayedArticle :: ArticleDB -> YiM () -- | Go to next one. This ignores the buffer, but it doesn't remove -- anything from the database. However, the ordering does change. nextArticle :: YiM () -- | Delete current article (the article as in the database), and go to -- next one. deleteAndNextArticle :: YiM () -- | The main action. We fetch the old database, we fetch the modified -- article from the buffer, then we call the function -- updateSetLast which removes the first article and pushes our -- modified article to the end of the list. saveAndNextArticle :: Int -> YiM () -- | Assume the buffer is an entirely new article just imported this -- second, and save it. We don't want to use updateSetLast since -- that will erase an article. saveAsNewArticle :: YiM () instance (Typeable a) => Initializable (Seq a) module Yi.History type Histories = Map String History data History History :: Int -> [String] -> String -> History _historyCurrent :: History -> Int _historyContents :: History -> [String] _historyPrefix :: History -> String dynKeyA :: (Initializable v, Ord k) => k -> Accessor (Map k v) v miniBuffer :: String historyUp :: EditorM () historyDown :: EditorM () historyStart :: EditorM () -- | Start an input session with History historyStartGen :: String -> EditorM () historyFinish :: EditorM () -- | Finish the current input session with history. historyFinishGen :: String -> EditorM String -> EditorM () debugHist :: EditorM () historyFind :: [String] -> Int -> Int -> Int -> String -> Int historyMove :: String -> Int -> EditorM () historyMoveGen :: String -> Int -> EditorM String -> EditorM String historyPrefixSet :: String -> EditorM () historyPrefixSet' :: String -> String -> EditorM () instance Typeable History instance Show History instance Initializable History instance (Typeable k, Typeable v) => Initializable (Map k v) -- | Search/Replace functions module Yi.Search -- | Put regex into regex register setRegexE :: SearchExp -> EditorM () -- | Clear the regex register resetRegexE :: EditorM () -- | Return contents of regex register getRegexE :: EditorM (Maybe SearchExp) -- | Global searching. Search for regex and move point to that position. -- Nothing means reuse the last regular expression. Just -- s means use s as the new regular expression. Direction -- of search can be specified as either Backward or -- Forward (forwards in the buffer). Arguments to modify the -- compiled regular expression can be supplied as well. type SearchMatch = Region data SearchResult PatternFound :: SearchResult PatternNotFound :: SearchResult SearchWrapped :: SearchResult data SearchOption -- | Compile for matching that ignores char case IgnoreCase :: SearchOption -- | Compile for newline-insensitive matching NoNewLine :: SearchOption -- | Treat the input not as a regex but as a literal string to search for. QuoteRegex :: SearchOption doSearch :: Maybe String -> [SearchOption] -> Direction -> EditorM SearchResult -- | Set up a search. searchInit :: String -> Direction -> [SearchOption] -> EditorM (SearchExp, Direction) -- | Do a search, placing cursor at first char of pattern, if found. -- Keymaps may implement their own regex language. How do we provide for -- this? Also, what's happening with ^ not matching sol? continueSearch :: (SearchExp, Direction) -> BufferM SearchResult -- | Search and Replace all within the current region. Note the region is -- the final argument since we might perform the same search and replace -- over multiple regions however we are unlikely to perform several -- search and replaces over the same region since the first such may -- change the bounds of the region. searchReplaceRegionB :: String -> String -> Region -> BufferM Int -- | Peform a search and replace on the selection searchReplaceSelectionB :: String -> String -> BufferM Int -- | Replace a string by another everywhere in the document replaceString :: String -> String -> BufferM Int searchAndRepRegion :: String -> String -> Bool -> Region -> EditorM Bool -- | Search and replace in the region defined by the given unit. The rest -- is as in searchAndRepRegion. searchAndRepUnit :: String -> String -> Bool -> TextUnit -> EditorM Bool isearchInitE :: Direction -> EditorM () isearchIsEmpty :: EditorM Bool isearchAddE :: String -> EditorM () isearchPrevE :: EditorM () isearchNextE :: EditorM () isearchWordE :: EditorM () isearchHistory :: Int -> EditorM () isearchDelE :: EditorM () isearchCancelE :: EditorM () isearchFinishE :: EditorM () -- | Find the next match and select it. Point is end, mark is beginning. qrNext :: Window -> BufferRef -> SearchExp -> EditorM () -- | Replace all the remaining occurrences. qrReplaceAll :: Window -> BufferRef -> SearchExp -> String -> EditorM () qrReplaceOne :: Window -> BufferRef -> SearchExp -> String -> EditorM () -- | Exit from query/replace. qrFinish :: EditorM () instance Typeable Isearch instance Initializable Isearch module Yi.MiniBuffer -- | Open a minibuffer window with the given prompt and keymap The third -- argument is an action to perform after the minibuffer is opened such -- as move to the first occurence of a searched for string. If you don't -- need this just supply return () spawnMinibufferE :: String -> KeymapEndo -> EditorM BufferRef withMinibufferFree :: String -> (String -> YiM ()) -> YiM () -- | withMinibuffer prompt completer act: open a minibuffer with -- prompt. Once a string s is obtained, run act -- s. completer can be used to complete functions: it -- returns a list of possible matches. withMinibuffer :: String -> (String -> YiM [String]) -> (String -> YiM ()) -> YiM () -- | withMinibufferGen proposal getHint prompt completer act: open -- a minibuffer with prompt, and initial content -- proposal. Once a string s is obtained, run act -- s. completer can be used to complete inputs by returning -- an incrementally better match, and getHint can give an immediate -- feedback to the user on the current input. withMinibufferGen :: String -> (String -> YiM [String]) -> String -> (String -> YiM String) -> (String -> YiM ()) -> YiM () -- | Open a minibuffer, given a finite number of suggestions. withMinibufferFin :: String -> [String] -> (String -> YiM ()) -> YiM () noHint :: String -> YiM [String] noPossibilities :: String -> YiM [String] mkCompleteFn :: (String -> (String -> Maybe String) -> [String] -> EditorM String) -> (String -> String -> Maybe String) -> (String -> YiM [String]) -> String -> YiM String simpleComplete :: (String -> YiM [String]) -> String -> YiM String infixComplete :: (String -> YiM [String]) -> String -> YiM String infixComplete' :: Bool -> (String -> YiM [String]) -> String -> YiM String anyModeByName :: String -> YiM AnyMode getAllModeNames :: YiM [String] -- | Returns all the buffer names. matchingBufferNames :: String -> YiM [String] anyModeByNameM :: String -> YiM (Maybe AnyMode) anyModeName :: AnyMode -> String -- | Tag a type with a documentation newtype (:::) t doc Doc :: t -> ::: t doc fromDoc :: ::: t doc -> t data LineNumber data RegexTag data FilePatternTag data ToKill newtype CommandArguments CommandArguments :: [String] -> CommandArguments instance Typeable CommandArguments instance Typeable FilePatternTag instance Typeable RegexTag instance Typeable2 ::: instance (Eq t) => Eq (t ::: doc) instance (Num t) => Num (t ::: doc) instance (IsString t) => IsString (t ::: doc) instance Promptable CommandArguments instance DocType FilePatternTag instance DocType RegexTag instance DocType ToKill instance DocType LineNumber instance (DocType doc, Promptable t) => Promptable (t ::: doc) instance (Show x) => Show (x ::: t) instance (YiAction a x, Promptable r) => YiAction (r -> a) x instance Promptable BufferRef instance Promptable AnyMode instance Promptable Int instance Promptable Char instance Promptable String -- | Various high-level functions to further classify. module Yi.Misc -- | Given a possible starting path (which if not given defaults to the -- current directory) and a fragment of a path we find all files within -- the given (or current) directory which can complete the given path -- fragment. We return a pair of both directory plus the filenames on -- their own that is without their directories. The reason for this is -- that if we return all of the filenames then we get a hint -- which is way too long to be particularly useful. getAppropriateFiles :: Maybe String -> String -> YiM (String, [String]) -- | Given a path, trim the file name bit if it exists. If no path given, -- return current directory. getFolder :: Maybe String -> IO String -- | Given a possible path and a prefix, return matching file names. matchingFileNames :: Maybe String -> String -> YiM [String] adjBlock :: Int -> BufferM () -- | A simple wrapper to adjust the current indentation using the mode -- specific indentation function but according to the given indent -- behaviour. adjIndent :: IndentBehaviour -> BufferM () -- | Generic emacs style prompt file action. Takes a prompt and a -- continuation act and prompts the user with file hints promptFile :: String -> (String -> YiM ()) -> YiM () -- | For use as the hint when opening a file using the minibuffer. We -- essentially return all the files in the given directory which have the -- given prefix. findFileHint :: String -> String -> YiM [String] -- | A Simple Dired Implementation for Yi module Yi.Dired dired :: YiM () diredDir :: FilePath -> YiM () diredDirBuffer :: FilePath -> YiM BufferRef -- | If file exists, read contents of file into a new buffer, otherwise -- creating a new empty buffer. Replace the current window with a new -- window onto the new buffer. -- -- If the file is already open, just switch to the corresponding buffer. -- -- Need to clean up semantics for when buffers exist, and how to attach -- windows to buffers. fnewE :: FilePath -> YiM () instance Typeable DiredOpState instance Typeable DiredState instance Typeable DiredEntry instance Typeable DiredFileInfo instance Show DiredOpState instance Eq DiredOpState instance Show DiredState instance Eq DiredState instance Show DiredEntry instance Eq DiredEntry instance Show DiredFileInfo instance Eq DiredFileInfo instance Initializable DiredOpState instance Initializable DiredState module Yi.Eval jumpToErrorE :: YiM () jumpToE :: String -> Int -> Int -> YiM () consoleKeymap :: Keymap -- | Returns an Interpreter action that loads the desired modules and -- interprets the expression. execEditorAction :: String -> YiM () getAllNamesInScope :: YiM [String] instance Typeable NamesCache instance Initializable NamesCache -- | Utilities to turn a lexer generated by Alex into a scanner that can be -- used by Yi. module Yi.Lexer.Alex type AlexInput = (Char, IndexedStr) alexGetChar :: AlexInput -> Maybe (Char, AlexInput) alexInputPrevChar :: AlexInput -> Char -- | Lexer state data AlexState lexerState AlexState :: lexerState -> !Point -> !Posn -> AlexState lexerState stLexer :: AlexState lexerState -> lexerState lookedOffset :: AlexState lexerState -> !Point stPosn :: AlexState lexerState -> !Posn -- | unfold lexer function into a function that returns a stream of (state -- x token) unfoldLexer :: ((AlexState lexState, input) -> Maybe (token, (AlexState lexState, input))) -> (AlexState lexState, input) -> [(AlexState lexState, token)] -- | Combine a character scanner with a lexer to produce a token scanner. -- May be used together with mkHighlighter to produce a -- Highlighter, or with linearSyntaxMode to produce a -- Mode. lexScanner :: ((AlexState lexerState, AlexInput) -> Maybe (token, (AlexState lexerState, AlexInput))) -> lexerState -> Scanner Point Char -> Scanner (AlexState lexerState) token alexCollectChar :: AlexInput -> [Char] -- | Return a constant token actionConst :: token -> Action lexState token -- | Return a constant token, and modify the lexer state actionAndModify :: (lexState -> lexState) -> token -> Action lexState token -- | Convert the parsed string into a token, and also modify the lexer -- state actionStringAndModify :: (lexState -> lexState) -> (String -> token) -> Action lexState token -- | Convert the parsed string into a token actionStringConst :: (String -> token) -> Action lexState token data Tok t Tok :: t -> Size -> Posn -> Tok t tokT :: Tok t -> t tokLen :: Tok t -> Size tokPosn :: Tok t -> Posn tokBegin :: Tok t -> Point tokEnd :: Tok t -> Point tokFromT :: t -> Tok t tokRegion :: Tok t -> Region data Posn Posn :: !Point -> !Int -> !Int -> Posn posnOfs :: Posn -> !Point posnLine :: Posn -> !Int posnCol :: Posn -> !Int startPosn :: Posn moveStr :: Posn -> IndexedStr -> Posn type ASI s = (AlexState s, AlexInput) (+~) :: (SemiNum absolute relative) => absolute -> relative -> absolute (~-) :: (SemiNum absolute relative) => absolute -> absolute -> relative -- | Size of a buffer region newtype Size Size :: Int -> Size fromSize :: Size -> Int type Stroke = Span StyleName tokToSpan :: Tok t -> Span t instance Eq Posn instance Ix Posn instance (Show lexerState) => Show (AlexState lexerState) instance Show Posn instance Ord Posn instance (Show t) => Show (Tok t) instance Functor Tok module Yi.IncrementalParse -- | Parse the same thing as the argument, but will be used only as backup. -- ie, it will be used only if disjuncted with a failing parser. recoverWith :: Parser s a -> Parser s a symbol :: (s -> Bool) -> Parser s s eof :: Parser s () lookNext :: Parser s (Maybe s) testNext :: (Maybe s -> Bool) -> Parser s () type State st token result = (st, Process token result) type P s a = Parser s a -- | Parser specification data Parser s a Look :: Parser s a -> (s -> Parser s a) -> Parser s a Yuck :: Parser s a -> Parser s a Enter :: String -> Parser s a -> Parser s a -- | Lexer state data AlexState lexerState AlexState :: lexerState -> !Point -> !Posn -> AlexState lexerState stLexer :: AlexState lexerState -> lexerState lookedOffset :: AlexState lexerState -> !Point stPosn :: AlexState lexerState -> !Posn scanner :: Parser token result -> Scanner st token -> Scanner (State st token result) result module Yi.Lexer.Abella initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) tokenToStyle :: Token -> StyleName tokenToText :: Token -> Maybe String type TT = Tok Token isComment :: Token -> Bool data Token Number :: Token VarIdent :: Token ConsIdent :: Token Reserved :: !Reserved -> Token ReservedOp :: !ReservedOp -> Token CommentLine :: Token Skip :: Token Unrecognized :: Token type HlState = Int data Reserved Forall :: Reserved Exists :: Reserved Other :: Reserved data ReservedOp Or :: ReservedOp And :: ReservedOp BackSlash :: ReservedOp RightArrow :: ReservedOp DoubleRightArrow :: ReservedOp Dot :: ReservedOp OtherOp :: ReservedOp instance Eq Token instance Show Token instance Eq ReservedOp instance Show ReservedOp instance Eq Reserved instance Show Reserved module Yi.Lexer.Cabal initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) module Yi.Lexer.Compilation initState :: () -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) data Token Report :: String -> Int -> Int -> String -> Token Text :: String -> Token instance Show Token module Yi.Lexer.C initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) module Yi.Lexer.ObjectiveC initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) module Yi.Lexer.Cplusplus initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) module Yi.Lexer.Haskell initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) tokenToStyle :: Token -> StyleName tokenToText :: Token -> Maybe String type TT = Tok Token isErrorTok :: Token -> Bool isSpecial :: String -> Token -> Bool startsLayout :: Token -> Bool isComment :: Token -> Bool data Token Number :: Token CharTok :: Token StringTok :: Token VarIdent :: Token ConsIdent :: Token Reserved :: !ReservedType -> Token ReservedOp :: !OpType -> Token Special :: Char -> Token ConsOperator :: String -> Token Operator :: String -> Token Comment :: !CommentType -> Token THQuote :: Token CppDirective :: Token Unrecognized :: Token type HlState = Int data CommentType Open :: CommentType Close :: CommentType Text :: CommentType Line :: CommentType data ReservedType Hiding :: ReservedType Qualified :: ReservedType As :: ReservedType Import :: ReservedType Data :: ReservedType NewType :: ReservedType Type :: ReservedType Where :: ReservedType Let :: ReservedType In :: ReservedType Do :: ReservedType Of :: ReservedType OtherLayout :: ReservedType Deriving :: ReservedType Module :: ReservedType Forall :: ReservedType Other :: ReservedType Class :: ReservedType Instance :: ReservedType data OpType Pipe :: OpType Equal :: OpType BackSlash :: OpType LeftArrow :: OpType RightArrow :: OpType DoubleRightArrow :: OpType DoubleColon :: OpType DoubleDot :: OpType Arobase :: OpType Tilda :: OpType instance Eq Token instance Show Token instance Eq OpType instance Show OpType instance Eq ReservedType instance Show ReservedType instance Eq CommentType instance Show CommentType module Yi.Lexer.JavaScript initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) tokenToStyle :: Token -> UIStyle -> Style type TT = Tok Token -- | The different tokens. data Token Unknown :: Token Res :: !Reserved -> Token Str :: !String -> Token Rex :: !String -> Token Op :: !Operator -> Token Special :: !Char -> Token Number :: !String -> Token ValidName :: !String -> Token Comment :: !CommentType -> Token Const :: !String -> Token -- | The constructors for Reserved have an apostrophe as a suffix -- because Default is already used. Also note that -- Undefined' is not intended as some sort of backup -- reserved word for things we don't care about -- it really means the -- undefined built-in in JavaScript. data Reserved Break' :: Reserved Case' :: Reserved Catch' :: Reserved Continue' :: Reserved Default' :: Reserved Delete' :: Reserved Do' :: Reserved Else' :: Reserved Finally' :: Reserved For' :: Reserved Function' :: Reserved If' :: Reserved In' :: Reserved InstanceOf' :: Reserved New' :: Reserved Return' :: Reserved Switch' :: Reserved This' :: Reserved Throw' :: Reserved Try' :: Reserved TypeOf' :: Reserved Var' :: Reserved Void' :: Reserved While' :: Reserved With' :: Reserved True' :: Reserved False' :: Reserved Null' :: Reserved Undefined' :: Reserved -- | The constructors for Operator have an apostrophe as a suffix -- because e.g. LT is already used by Prelude. data Operator Add' :: Operator Subtract' :: Operator Multiply' :: Operator Divide' :: Operator Modulo' :: Operator Increment' :: Operator Decrement' :: Operator Assign' :: Operator AddAssign' :: Operator SubtractAssign' :: Operator MultiplyAssign' :: Operator DivideAssign' :: Operator ModuloAssign' :: Operator Equals' :: Operator NotEquals' :: Operator GT' :: Operator GTE' :: Operator LT' :: Operator LTE' :: Operator EqualsType' :: Operator NotEqualsType' :: Operator And' :: Operator Or' :: Operator Not' :: Operator BitAnd' :: Operator BitOr' :: Operator BitXor' :: Operator LeftShift' :: Operator RightShift' :: Operator RightShiftZ' :: Operator BitNot' :: Operator Qualify' :: Operator -- | Prefix operators. NOTE: Add' is also a valid prefix operator, but -- since it's completely useless in the real world, we don't care about -- it here. Doing this makes parsing much, much easier. -- -- Postfix operators. -- -- Infix operators. -- -- HlState is 0 when outside of a multi-line comment and -1 when -- inside one. type HlState = Int prefixOperators :: [Operator] infixOperators :: [Operator] postfixOperators :: [Operator] instance Show Token instance Eq Token instance Show Operator instance Eq Operator instance Show Reserved instance Eq Reserved instance Show CommentType instance Eq CommentType module Yi.Lexer.Latex initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) data Token Comment :: Token Text :: Token Special :: !Char -> Token Command :: !String -> Token Begin :: !String -> Token End :: !String -> Token NewCommand :: Token type HlState = Int tokenToText :: Token -> Maybe [Char] instance Eq Token instance Show Token instance Ord Token module Yi.Lexer.LiterateHaskell initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) data HlState instance Eq HlState instance Show HlState module Yi.Lexer.GNUMake initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) instance Show HlState module Yi.Lexer.OCaml initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) tokenToStyle :: Token -> StyleName data Token Number :: Token CharTok :: Token StringTok :: Token VarIdent :: Token ConsIdent :: Token IndentReserved :: Token Reserved :: Token ReservedOp :: Token Special :: Char -> Token ConsOperator :: Token Operator :: Token Comment :: Token instance Eq Token instance Show Token module Yi.Lexer.Ott initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) module Yi.Lexer.Perl initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) instance Show HlState module Yi.Lexer.Python initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) module Yi.Lexer.Srmc initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) module Yi.Lexer.SVNCommit initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) instance Show HlState module Yi.Lexer.Whitespace initState :: HlState -- | Scan one token. Return (maybe) a token and a new state. alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) -- | emacs-style rectangle manipulation functions. module Yi.Rectangle alignRegion :: String -> BufferM () -- | Align each line of the region on the given regex. Fails if it is not -- found in any line. alignRegionOn :: String -> BufferM () -- | Get the selected region as a rectangle. Returns the region extended to -- lines, plus the start and end columns of the rectangle. getRectangle :: BufferM (Region, Int, Int) -- | Split a list at the boundaries given multiSplit :: [Int] -> [a] -> [[a]] onRectangle :: (Int -> Int -> String -> String) -> BufferM () openRectangle :: BufferM () stringRectangle :: String -> BufferM () killRectangle :: EditorM () yankRectangle :: EditorM () module Yi.Keymap.Emacs.KillRing -- | C-w killRegion :: BufferM () -- | C-k killLineE :: Maybe Int -> YiM () killringPut :: Direction -> String -> EditorM () -- | Kill the rest of line killRestOfLine :: BufferM () -- | C-y yankE :: EditorM () -- | M-w killRingSaveE :: EditorM () -- | M-y yankPopE :: EditorM () -- | C-M-w appendNextKillE :: EditorM () -- | A module for CTags integration module Yi.Tag -- | Find the location of a tag using the tag table. Returns a full path -- and line number lookupTag :: Tag -> TagTable -> Maybe (FilePath, Int) -- | Read in a tag file from the system importTagTable :: FilePath -> IO TagTable -- | Gives all the possible expanded tags that could match a given -- prefix hintTags :: TagTable -> String -> [String] -- | Extends the string to the longest certain length completeTag :: TagTable -> String -> String type Tag = String data TagTable TagTable :: FilePath -> FilePath -> Map Tag (FilePath, Int) -> Trie -> TagTable -- | local name of the tag file TODO: reload if this file is changed tagFileName :: TagTable -> FilePath -- | path to the tag file directory tags are relative to this path tagBaseDir :: TagTable -> FilePath -- | map from tags to files tagFileMap :: TagTable -> Map Tag (FilePath, Int) -- | trie to speed up tag hinting tagTrie :: TagTable -> Trie -- | Get the currently registered tag table getTags :: EditorM (Maybe TagTable) -- | Set a new TagTable setTags :: TagTable -> EditorM () -- | Reset the TagTable resetTags :: EditorM () getTagsFileList :: EditorM [FilePath] setTagsFileList :: String -> EditorM () instance Typeable TagTable instance Typeable TagsFileList instance Typeable Tags instance Initializable TagsFileList instance Initializable Tags -- | Generic syntax tree handling functions module Yi.Syntax.Tree class (Foldable tree) => IsTree tree subtrees :: (IsTree tree) => tree t -> [tree t] uniplate :: (IsTree tree) => tree t -> ([tree t], [tree t] -> tree t) emptyNode :: (IsTree tree) => tree t toksAfter :: (Foldable t1) => t -> t1 a -> [a] allToks :: (Foldable t) => t a -> [a] tokAtOrBefore :: (Foldable t) => Point -> t (Tok t1) -> Maybe (Tok t1) toksInRegion :: (Foldable t1) => Region -> t1 (Tok t) -> [Tok t] sepBy :: (Alternative f) => f a -> f v -> f [a] sepBy1 :: (Alternative f) => f a -> f v -> f [a] getLastOffset :: (Foldable t) => t (Tok t1) -> Point getFirstOffset :: (Foldable t) => t (Tok t1) -> Point -- | Return the 1st token of a subtree. getFirstElement :: (Foldable t) => t a -> Maybe a -- | Return the last token of a subtree. getLastElement :: (Foldable t) => t a -> Maybe a -- | Search the given list, and return the last tree before the given -- point; with path to the root. (Root is at the start of the path) getLastPath :: (IsTree tree) => [tree (Tok t)] -> Point -> Maybe [tree (Tok t)] -- | Return all subtrees in a tree, in preorder. getAllSubTrees :: (IsTree tree) => tree t -> [tree t] tokenBasedAnnots :: (Foldable t1) => (a1 -> Maybe a) -> t1 a1 -> t -> [a] tokenBasedStrokes :: (Foldable t3) => (a -> b) -> t3 a -> t -> t2 -> t1 -> [b] subtreeRegion :: (Foldable t) => t (Tok t1) -> Region -- | Search the tree in pre-order starting at a given node, until finding a -- leaf which is at or after the given point. An effort is also made to -- return a leaf as close as possible to p. TODO: rename to -- fromLeafToLeafAt fromLeafToLeafAfter :: (IsTree tree) => Point -> Node (tree (Tok a)) -> Node (tree (Tok a)) -- | Given an approximate path to a leaf at the end of the region, return: -- (path to leaf at the end of the region,path from focused node to the -- leaf, small node encompassing the region) fromNodeToFinal :: (IsTree tree) => Region -> Node (tree (Tok a)) -> Node (tree (Tok a)) module Yi.Syntax.OnlineTree data Tree a Bin :: (Tree a) -> (Tree a) -> Tree a Leaf :: a -> Tree a Tip :: Tree a manyToks :: P (Tok t) (Tree (Tok t)) tokAtOrBefore :: (Foldable t) => Point -> t (Tok t1) -> Maybe (Tok t1) instance (Show a) => Show (Tree a) instance (Show x, Show (f x)) => Show (MaybeOneMore f x) instance Functor Tree instance Foldable Tree instance Traversable Tree instance IsTree Tree -- | This module defines implementations of syntax-awareness drivers. module Yi.Syntax.Driver type Path = [Int] data Cache state tree tt Cache :: Map Int Path -> [state] -> tree (Tok tt) -> !Map Int (tree (Tok tt)) -> Cache state tree tt path :: Cache state tree tt -> Map Int Path cachedStates :: Cache state tree tt -> [state] root :: Cache state tree tt -> tree (Tok tt) focused :: Cache state tree tt -> !Map Int (tree (Tok tt)) mkHighlighter :: (IsTree tree, Show state) => (Scanner Point Char -> Scanner state (tree (Tok tt))) -> Highlighter (Cache state tree tt) (tree (Tok tt)) unzipFM :: (Ord k) => [(k, (u, v))] -> (Map k u, Map k v) zipWithFM :: (Ord k) => (u -> v -> w) -> v -> Map k u -> Map k v -> [(k, w)] module Yi.Modes type TokenBasedMode tok = Mode (Tree (Tok tok)) fundamentalMode :: Mode syntax cMode :: StyleBasedMode objectiveCMode :: StyleBasedMode cppMode :: StyleBasedMode cabalMode :: StyleBasedMode srmcMode :: StyleBasedMode ocamlMode :: TokenBasedMode (Token) ottMode :: StyleBasedMode gnuMakeMode :: StyleBasedMode perlMode :: StyleBasedMode pythonMode :: StyleBasedMode -- | When applied to an extensions list, creates a -- Mode.modeApplies function. anyExtension :: [String] -> FilePath -> String -> Bool -- | When applied to an extensions list and regular expression pattern, -- creates a Mode.modeApplies function. extensionOrContentsMatch :: [String] -> String -> FilePath -> String -> Bool linearSyntaxMode :: (Show lexerState) => lexerState -> ((AlexState lexerState, AlexInput) -> Maybe (Tok t, (AlexState lexerState, AlexInput))) -> (t -> StyleName) -> Mode (Tree (Tok t)) svnCommitMode :: StyleBasedMode -- | Adds a hook to all matching hooks in a list hookModes :: (AnyMode -> Bool) -> BufferM () -> [AnyMode] -> [AnyMode] -- | Apply a list of mode hooks to a list of AnyModes applyModeHooks :: [(AnyMode -> Bool, BufferM ())] -> [AnyMode] -> [AnyMode] -- | Check whether a mode of the same name is already in modeTable and -- returns the original mode, if it isn't the case. lookupMode :: AnyMode -> YiM AnyMode whitespaceMode :: TokenBasedMode StyleName removeAnnots :: Mode a -> Mode a module Yi.Mode.Compilation mode :: Mode (Tree (Tok Token)) module Yi.Mode.Interactive atLastLine :: BufferM Bool mode :: Mode (Tree (Tok Token)) -- | The GHCi prompt always begins with >; this goes to just -- before it, or if one is already at the start of the prompt, goes to -- the beginning of the line. (If at the beginning of the line, this -- pushes you forward to it.) ghciHome :: BufferM () interactId :: String interactHistoryMove :: Int -> EditorM () interactHistoryFinish :: EditorM () interactHistoryStart :: EditorM () getInputRegion :: BufferM Region getInput :: BufferM String setInput :: String -> BufferM () -- | Open a new buffer for interaction with a process. interactive :: String -> [String] -> YiM BufferRef -- | Send the type command to the process feedCommand :: YiM () -- | Send command, recieve reply queryReply :: BufferRef -> String -> YiM String -- | Various high-level functions to further classify. module Yi.Command -- | Changing the buffer name quite useful if you have several the same. -- This also breaks the relation with the file. changeBufferNameE :: YiM () -- | shell-command with argument prompt shellCommandE :: YiM () -- | shell-command with a known argument shellCommandV :: String -> YiM () newtype CabalBuffer CabalBuffer :: Maybe BufferRef -> CabalBuffer cabalBuffer :: CabalBuffer -> Maybe BufferRef -- | cabal-configure cabalConfigureE :: CommandArguments -> YiM () configureExit :: Either Exception ExitCode -> YiM () reloadProjectE :: String -> YiM () -- | Run the given commands with args and pipe the ouput into the build -- buffer, which is shown in an other window. buildRun :: String -> [String] -> (Either Exception ExitCode -> YiM x) -> YiM () makeBuild :: CommandArguments -> YiM () cabalRun :: String -> (Either Exception ExitCode -> YiM x) -> CommandArguments -> YiM () -- | cabal-build cabalBuildE :: CommandArguments -> YiM () shell :: YiM BufferRef -- | Search the source files in the project. searchSources :: String ::: RegexTag -> YiM () -- | Perform a find+grep operation grepFind :: String ::: FilePatternTag -> String ::: RegexTag -> YiM () -- | Inserting a template from the templates defined in Yi.Templates insertTemplate :: YiM () instance Typeable CabalBuffer instance Initializable CabalBuffer instance Binary CabalBuffer -- | Vim keymap for Yi. Emulates vim :set nocompatible module Yi.Keymap.Vim keymapSet :: KeymapSet -- | Try to write a file in the manner of vi/vim Need to catch any -- exception to avoid losing bindings viWrite :: YiM () defKeymap :: Proto ModeMap leaveInsRep :: VimMode -- | Leave a mode. This always has priority over catch-all actions inside -- the mode. leave :: VimMode -- | The Vim keymap is divided into several parts, roughly corresponding to -- the different modes of vi. Each mode is in turn broken up into -- separate VimProcs for each phase of key input in that mode. data ModeMap ModeMap :: VimMode -> VimMode -> VimOpts -> VimExCmdMap -> ModeMap -- | Top level mode v_top_level :: ModeMap -> VimMode -- | vim insert mode v_ins_char :: ModeMap -> VimMode v_opts :: ModeMap -> VimOpts v_ex_cmds :: ModeMap -> VimExCmdMap data VimOpts VimOpts :: Bool -> Bool -> Bool -> VimOpts tildeop :: VimOpts -> Bool completeCaseSensitive :: VimOpts -> Bool enableTagStack :: VimOpts -> Bool data VimExCmd VimExCmd :: [String] -> (String -> YiM ()) -> Maybe (String -> YiM ()) -> VimExCmd cmdNames :: VimExCmd -> [String] cmdFn :: VimExCmd -> String -> YiM () completeFn :: VimExCmd -> Maybe (String -> YiM ()) nilCmd :: VimExCmd exCmd :: String -> (String -> YiM ()) -> Maybe (String -> YiM ()) -> VimExCmd exCmds :: [(String, String -> YiM (), Maybe (String -> YiM ()))] -> VimExCmdMap exSimpleComplete :: (String -> YiM [String]) -> String -> YiM () exInfixComplete' :: Bool -> (String -> YiM [String]) -> String -> YiM () exInfixComplete :: (String -> YiM [String]) -> String -> YiM () mkExHistComplete :: (String -> String -> Bool) -> (String -> YiM [String]) -> String -> YiM () exHistComplete' :: Bool -> (String -> YiM [String]) -> String -> YiM () exHistComplete :: (String -> YiM [String]) -> String -> YiM () exHistInfixComplete' :: Bool -> (String -> YiM [String]) -> String -> YiM () exHistInfixComplete :: (String -> YiM [String]) -> String -> YiM () -- | The given buffer action should be an insertion action. savingInsertB :: BufferM () -> BufferM () savingInsertCharB :: Char -> BufferM () savingInsertStringB :: String -> BufferM () -- | The given action should be a deletion action. The only well tested -- buffer actions are deleting one character, or one word, forward or -- backward. savingDeleteB :: BufferM () -> BufferM () savingDeleteCharB :: Direction -> BufferM () savingDeleteWordB :: Direction -> BufferM () savingCommandY :: (Int -> YiM ()) -> Int -> YiM () savingCommandE :: (Int -> EditorM ()) -> Int -> EditorM () mkKeymap :: Proto ModeMap -> KeymapSet beginIns :: (Show x, YiAction a x) => ModeMap -> a -> I Event Action () beginInsE :: ModeMap -> EditorM () -> I Event Action () beginInsB :: ModeMap -> BufferM () -> I Event Action () listTagStack :: EditorM [(FilePath, Point)] pushTagStack :: FilePath -> Point -> EditorM () popTagStack :: Int -> EditorM (Maybe (FilePath, Point)) peekTagStack :: EditorM (Maybe (FilePath, Point)) instance Typeable VimTagStack instance Initializable VimTagStack instance Typeable ViInsertion instance Typeable ViCmd instance Typeable ViMove instance Initializable ViCmd module Yi.Keymap.Emacs.Utils type UnivArgument = Maybe Int -- | Convert the universal argument to a number of repetitions argToInt :: UnivArgument -> Int askQuitEditor :: YiM () -- | Quits the editor if there are no unmodified buffers if there are -- unmodified buffers then we ask individually for each modified buffer -- whether or not the user wishes to save it or not. If we get to the end -- of this list and there are still some modified buffers then we ask -- again if the user wishes to quit, but this is then a simple yes or no. askSaveEditor :: YiM () -- | Quits the editor if there are no unmodified buffers if there are then -- simply confirms with the user that they with to quit. modifiedQuitEditor :: YiM () -- | withMinibuffer prompt completer act: open a minibuffer with -- prompt. Once a string s is obtained, run act -- s. completer can be used to complete functions: it -- returns a list of possible matches. withMinibuffer :: String -> (String -> YiM [String]) -> (String -> YiM ()) -> YiM () queryReplaceE :: YiM () isearchKeymap :: Direction -> Keymap -- | cabal-configure cabalConfigureE :: CommandArguments -> YiM () -- | cabal-build cabalBuildE :: CommandArguments -> YiM () reloadProjectE :: String -> YiM () executeExtendedCommandE :: YiM () evalRegionE :: YiM () readUniversalArg :: KeymapM (Maybe Int) scrollDownE :: UnivArgument -> BufferM () scrollUpE :: UnivArgument -> BufferM () switchBufferE :: YiM () killBufferE :: BufferRef ::: ToKill -> YiM () -- | Insert next character, raw insertNextC :: UnivArgument -> KeymapM () -- | Open a file using the minibuffer. We have to set up some stuff to -- allow hints and auto-completion. findFile :: YiM () -- | Open a file in a new tab using the minibuffer. findFileNewTab :: YiM () -- | Generic emacs style prompt file action. Takes a prompt and a -- continuation act and prompts the user with file hints promptFile :: String -> (String -> YiM ()) -> YiM () -- | Prompt the user to give a tag and then jump to that tag promptTag :: YiM () -- | If on separators (space, tab, unicode seps), reduce multiple -- separators to just a single separator. justOneSep :: BufferM () -- | Join this line to previous (or next N if universal) joinLinesE :: UnivArgument -> BufferM () module Yi.Keymap.Cua keymap :: KeymapSet -- | Introduce a keymap that is compatible with both windows and osx, by -- parameterising the event modifier required for commands portableKeymap :: (Event -> Event) -> KeymapSet cut :: EditorM () paste :: EditorM () copy :: EditorM () del :: EditorM () -- | This module aims at a mode that should be (mostly) intuitive to emacs -- users, but mapping things into the Yi world when convenient. Hence, do -- not go into the trouble of trying 100% emulation. For example, M-x -- gives access to Yi (Haskell) functions, with their native names. module Yi.Keymap.Emacs keymap :: KeymapSet mkKeymap :: Proto ModeMap -> KeymapSet defKeymap :: Proto ModeMap data ModeMap ModeMap :: Keymap -> Bool -> ModeMap eKeymap :: ModeMap -> Keymap completionCaseSensitive :: ModeMap -> Bool -- | A simple text mode; it does very little besides define a comment -- syntax. We have it as a separate mode so users can bind the commands -- to this mode specifically. module Yi.Mode.IReader abstract :: Mode syntax ireaderMode :: Mode syntax ireadMode :: YiM () module Yi.Mode.Abella abellaModeVim :: TokenBasedMode Token abellaModeEmacs :: TokenBasedMode Token -- | Start Abella in a buffer abella :: CommandArguments -> YiM BufferRef abellaEval :: YiM () abellaEvalFromProofPoint :: YiM () abellaUndo :: YiM () -- | Return Abella's buffer; create it if necessary. Show it in another -- window. abellaGet :: YiM BufferRef -- | Send a command to Abella abellaSend :: String -> YiM () instance Typeable AbellaBuffer instance Initializable AbellaBuffer instance Binary AbellaBuffer module Yi.Syntax.JavaScript -- | Instances of Strokable are datatypes which can be syntax -- highlighted. class Strokable a toStrokes :: (Strokable a) => a -> Endo [Stroke] -- | Instances of Failable can represent failure. This is a useful -- class for future work, since then we can make stroking much easier. class Failable f stupid :: (Failable f) => t -> f t hasFailed :: (Failable f) => f t -> Bool type BList a = [a] type Tree t = BList (Statement t) type Semicolon t = Maybe t data Statement t FunDecl :: t -> t -> (Parameters t) -> (Block t) -> Statement t VarDecl :: t -> (BList (VarDecAss t)) -> (Semicolon t) -> Statement t Return :: t -> (Maybe (Expr t)) -> (Semicolon t) -> Statement t While :: t -> (ParExpr t) -> (Block t) -> Statement t DoWhile :: t -> (Block t) -> t -> (ParExpr t) -> (Semicolon t) -> Statement t For :: t -> t -> (Expr t) -> (ForContent t) -> t -> (Block t) -> Statement t If :: t -> (ParExpr t) -> (Block t) -> (Maybe (Statement t)) -> Statement t Else :: t -> (Block t) -> Statement t With :: t -> (ParExpr t) -> (Block t) -> Statement t Comm :: t -> Statement t Expr :: (Expr t) -> (Semicolon t) -> Statement t data Parameters t Parameters :: t -> (BList t) -> t -> Parameters t ParErr :: t -> Parameters t data ParExpr t ParExpr :: t -> (BList (Expr t)) -> t -> ParExpr t ParExprErr :: t -> ParExpr t data ForContent t ForNormal :: t -> (Expr t) -> t -> (Expr t) -> ForContent t ForIn :: t -> (Expr t) -> ForContent t ForErr :: t -> ForContent t data Block t Block :: t -> (BList (Statement t)) -> t -> Block t BlockOne :: (Statement t) -> Block t BlockErr :: t -> Block t -- | Represents either a variable name or a variable name assigned to an -- expression. AssBeg is a variable name maybe followed -- by an assignment. AssRst is an equals sign and an expression. -- (AssBeg x (Just (AssRst '=' '5'))) means x = -- 5. data VarDecAss t AssBeg :: t -> (Maybe (VarDecAss t)) -> VarDecAss t AssRst :: t -> (Expr t) -> VarDecAss t AssErr :: t -> VarDecAss t data Expr t ExprObj :: t -> (BList (KeyValue t)) -> t -> Expr t ExprPrefix :: t -> (Expr t) -> Expr t ExprNew :: t -> (Expr t) -> Expr t ExprSimple :: t -> (Maybe (Expr t)) -> Expr t ExprParen :: t -> (Expr t) -> t -> (Maybe (Expr t)) -> Expr t ExprAnonFun :: t -> (Parameters t) -> (Block t) -> Expr t ExprTypeOf :: t -> (Expr t) -> Expr t ExprFunCall :: t -> (ParExpr t) -> (Maybe (Expr t)) -> Expr t OpExpr :: t -> (Expr t) -> Expr t ExprCond :: t -> (Expr t) -> t -> (Expr t) -> Expr t ExprArr :: t -> (Maybe (Array t)) -> t -> (Maybe (Expr t)) -> Expr t PostExpr :: t -> Expr t ExprErr :: t -> Expr t data Array t ArrCont :: (Expr t) -> (Maybe (Array t)) -> Array t ArrRest :: t -> (Array t) -> (Maybe (Array t)) -> Array t ArrErr :: t -> Array t data KeyValue t KeyValue :: t -> t -> (Expr t) -> KeyValue t KeyValueErr :: t -> KeyValue t -- | Normal stroker. normal :: TT -> Endo [Stroke] -- | Error stroker. error :: TT -> Endo [Stroke] one :: (t -> a) -> t -> Endo [a] -- | Given a new style and a stroke, return a stroke with the new style -- appended to the old one. modStroke :: StyleName -> Stroke -> Stroke -- | Given a list of tokens to check for errors (xs) and a list of -- tokens to stroke (xs'), returns normal strokes for -- xs' if there were no errors. Otherwise returns error strokes -- for xs'. nError :: [TT] -> [TT] -> Endo [Stroke] -- | Given a list of TT, if any of them is an error, returns an -- error stroker, otherwise a normal stroker. Using e.g. existentials, we -- could make this more general and have support for heterogeneous lists -- of elements which implement Failable, but I haven't had the time to -- fix this. failStroker :: [TT] -> TT -> Endo [Stroke] -- | Given a TT, return a Stroke for it. tokenToStroke :: TT -> Stroke -- | The main stroking function. getStrokes :: Tree TT -> Point -> Point -> Point -> [Stroke] -- | Main parser. parse :: P TT (Tree TT) -- | Parser for statements such as return, while, -- do-while, for, etc. statement :: P TT (Statement TT) -- | Parser for blocks, i.e. a bunch of statements wrapped in curly -- brackets or just a single statement. -- -- Note that this works for JavaScript 1.8 lambda style function -- bodies as well, e.g. function hello() 5, since expressions are -- also statements and we don't require a trailing semi-colon. -- -- TODO: function hello() var x; is not a valid program. block :: P TT (Block TT) -- | Parser for expressions which may be statements. In reality, any -- expression is also a valid statement, but this is a slight compromise -- to get rid of the massive performance loss which is introduced when -- allowing JavaScript objects to be valid statements. stmtExpr :: P TT (Expr TT) -- | The basic idea here is to parse the rest of expressions, e.g. -- + 3 in x + 3 or [i] in x[i]. -- Anything which is useful in such a scenario goes here. TODO: This -- accepts [], but shouldn't, since x[] is invalid. opExpr :: P TT (Expr TT) -- | Parser for expressions. expression :: P TT (Expr TT) -- | Parses both empty and non-empty arrays. Should probably be split up -- into further parts to allow for the separation of [] and -- [1, 2, 3]. array :: P TT (Expr TT) -- | Parses a semicolon if it's there. semicolon :: P TT (Maybe TT) -- | Parses a comma-separated list of valid identifiers. parameters :: P TT (Parameters TT) parExpr :: P TT (ParExpr TT) -- | Parses a comment. comment :: P TT TT -- | Parses a prefix operator. preOp :: P TT TT -- | Parses a infix operator. inOp :: P TT TT -- | Parses a postfix operator. postOp :: P TT TT -- | Parses any literal. opTok :: P TT TT -- | Parses any literal. simpleTok :: P TT TT -- | Parses any string. strTok :: P TT TT -- | Parses any valid number. numTok :: P TT TT -- | Parses any valid identifier. name :: P TT TT -- | Parses any boolean. boolean :: P TT TT -- | Parses a reserved word. res :: Reserved -> P TT TT -- | Parses a special token. spc :: Char -> P TT TT -- | Parses an operator. oper :: Operator -> P TT TT -- | Expects a token x, recovers with errorToken. plzTok :: P TT TT -> P TT TT -- | Expects a special token. plzSpc :: Char -> P TT TT -- | Expects an expression. plzExpr :: P TT (Expr TT) plz :: (Failable f) => P TT (f TT) -> P TT (f TT) -- | General recovery parser, inserts an error token. anything :: P s TT -- | Weighted recovery. hate :: Int -> P s a -> P s a fromBlock :: Block t -> [Statement t] firstTok :: (Foldable f) => f t -> t errorToken :: TT isError :: TT -> Bool -- | Better name for tokFromT. toTT :: t -> Tok t -- | Better name for tokT. fromTT :: Tok t -> t instance Strokable (Array TT) instance Strokable (Tok Token) instance Strokable (KeyValue TT) instance Strokable (ParExpr TT) instance Strokable (Parameters TT) instance Strokable (Expr TT) instance Strokable (VarDecAss TT) instance Strokable (Block TT) instance Strokable (ForContent TT) instance Strokable (Statement TT) instance Failable KeyValue instance Failable Expr instance Failable ParExpr instance Failable Parameters instance Failable VarDecAss instance Failable Block instance Failable ForContent instance IsTree Statement instance Foldable KeyValue instance Foldable Array instance Foldable Expr instance Foldable VarDecAss instance Foldable Block instance Foldable ForContent instance Foldable ParExpr instance Foldable Parameters instance Foldable Statement instance Typeable1 KeyValue instance Typeable1 Array instance Typeable1 Expr instance Typeable1 VarDecAss instance Typeable1 Block instance Typeable1 ForContent instance Typeable1 ParExpr instance Typeable1 Parameters instance Typeable1 Statement instance (Show t) => Show (KeyValue t) instance (Data t) => Data (KeyValue t) instance (Show t) => Show (Array t) instance (Data t) => Data (Array t) instance (Show t) => Show (Expr t) instance (Data t) => Data (Expr t) instance (Show t) => Show (VarDecAss t) instance (Data t) => Data (VarDecAss t) instance (Show t) => Show (Block t) instance (Data t) => Data (Block t) instance (Show t) => Show (ForContent t) instance (Data t) => Data (ForContent t) instance (Show t) => Show (ParExpr t) instance (Data t) => Data (ParExpr t) instance (Show t) => Show (Parameters t) instance (Data t) => Data (Parameters t) instance (Show t) => Show (Statement t) instance (Data t) => Data (Statement t) module Yi.Verifier.JavaScript data Error MultipleFunctionDeclaration :: String -> [Posn] -> Error data Warning UnreachableCode :: Posn -> Warning data Report Err :: Error -> Report Warn :: Warning -> Report -- | The main verifier which calls the sub-verifiers. verify :: Tree TT -> Writer (DList Report) () -- | Given a list of function declarations, checks for multiple function -- declarations, including the functions' subfunctions. checkMultipleFuns :: [Statement TT] -> Writer (DList Report) () checkUnreachable :: [Statement TT] -> Writer (DList Report) () -- | Given two Tok t, compares the ts. ttEq :: (Eq t) => Tok t -> Tok t -> Bool say :: (MonadWriter (DList a) m) => a -> m () isReturn :: Statement t -> Bool -- | Returns a list of the functions in the given block. findFunctions :: [Statement t] -> [Statement t] -- | Given a FunDecl, returns the token representing the name. funName :: Statement t -> t -- | Given a FunDecl, returns its inner body as a list. funBody :: Statement t -> [Statement t] -- | Given a ValidName returns the string representing the name. nameOf :: Token -> String -- | Like dropWhile but drops the first element in the result. dropWhile' :: (a -> Bool) -> [a] -> [a] dupsBy :: (a -> a -> Bool) -> [a] -> [a] instance Eq Report instance Eq Warning instance Eq Error instance Show Report instance Show Warning instance Show Error module Yi.Mode.JavaScript javaScriptMode :: Mode (Tree TT) -- | Hooks for the JavaScript mode. hooks :: Mode (Tree TT) -> Mode (Tree TT) instance Typeable JSBuffer instance Initializable JSBuffer module Yi.Syntax.Latex isNoise :: Token -> Bool type TT = Tok Token type Expr t = [Tree t] data Tree t Paren :: t -> (Tree t) -> t -> Tree t Atom :: t -> Tree t Error :: t -> Tree t Expr :: (Expr t) -> Tree t parse :: P TT (Tree TT) getStrokes :: Point -> Point -> Point -> Tree TT -> [Stroke] modStroke :: StyleName -> Stroke -> Stroke tokenToStroke :: TT -> Stroke tokenToAnnot :: TT -> Maybe (Span String) tokenToStyle :: Token -> StyleName isSpecial :: [Char] -> Token -> Bool isEnd :: Token -> Bool isBegin :: Token -> Bool isErrorTok :: Token -> Bool instance (Show t) => Show (Tree t) instance IsTree Tree instance Foldable Tree module Yi.Mode.Latex -- | syntax-based latex mode latexMode3 :: Mode (Tree TT) -- | syntax-based latex mode latexMode2 :: Mode (Tree TT) fastMode :: Mode (Tree TT) module Yi.Snippets type SnippetCmd = RWST (Int, Int) [MarkInfo] () BufferM data SnippetMark SimpleMark :: !Int -> SnippetMark ValuedMark :: !Int -> String -> SnippetMark DependentMark :: !Int -> SnippetMark data MarkInfo SimpleMarkInfo :: !Int -> !Mark -> MarkInfo userIndex :: MarkInfo -> !Int startMark :: MarkInfo -> !Mark ValuedMarkInfo :: !Int -> !Mark -> !Mark -> MarkInfo userIndex :: MarkInfo -> !Int startMark :: MarkInfo -> !Mark endMark :: MarkInfo -> !Mark DependentMarkInfo :: !Int -> !Mark -> !Mark -> MarkInfo userIndex :: MarkInfo -> !Int startMark :: MarkInfo -> !Mark endMark :: MarkInfo -> !Mark newtype BufferMarks BufferMarks :: [MarkInfo] -> BufferMarks bufferMarks :: BufferMarks -> [MarkInfo] newtype DependentMarks DependentMarks :: [[MarkInfo]] -> DependentMarks marks :: DependentMarks -> [[MarkInfo]] class MkSnippetCmd a b | a -> b mkSnippetCmd :: (MkSnippetCmd a b) => a -> SnippetCmd b text :: String -> SnippetCmd () (&) :: (MkSnippetCmd a any, MkSnippetCmd b c) => a -> b -> SnippetCmd c (&>) :: (MkSnippetCmd a b, MkSnippetCmd c d) => a -> (b -> c) -> SnippetCmd d runSnippet :: Bool -> SnippetCmd a -> BufferM a updateUpdatedMarks :: [Update] -> BufferM () findEditedMarks :: [Update] -> BufferM [MarkInfo] dependentSiblings :: MarkInfo -> [[MarkInfo]] -> [MarkInfo] updateDependents :: MarkInfo -> BufferM () updateDependents' :: MarkInfo -> [[MarkInfo]] -> BufferM () markText :: MarkInfo -> BufferM String setMarkText :: String -> MarkInfo -> BufferM () findOverlappingMarksWith :: (MarkInfo -> BufferM Region) -> ([[MarkInfo]] -> [MarkInfo]) -> Bool -> Region -> MarkInfo -> BufferM [MarkInfo] findOverlappingMarks :: ([[MarkInfo]] -> [MarkInfo]) -> Bool -> Region -> MarkInfo -> BufferM [MarkInfo] regionsOverlappingMarks :: Bool -> Region -> MarkInfo -> BufferM [MarkInfo] overlappingMarks :: Bool -> Bool -> MarkInfo -> BufferM [MarkInfo] allOverlappingMarks :: Bool -> MarkInfo -> BufferM [MarkInfo] dependentOverlappingMarks :: Bool -> MarkInfo -> BufferM [MarkInfo] nextBufferMark :: Bool -> BufferM (Maybe MarkInfo) moveToNextBufferMark :: Bool -> BufferM () newtype SupertabExt Supertab :: (String -> Maybe (BufferM ())) -> SupertabExt superTab :: (MonadInteract m Action Event) => Bool -> SupertabExt -> m () -- | Convert snippet description list into a SuperTab extension fromSnippets :: Bool -> [(String, SnippetCmd ())] -> SupertabExt instance Typeable DependentMarks instance Typeable BufferMarks instance Eq DependentMarks instance Show DependentMarks instance Monoid DependentMarks instance Eq BufferMarks instance Show BufferMarks instance Monoid BufferMarks instance Eq MarkInfo instance Show MarkInfo instance Monoid SupertabExt instance MkSnippetCmd SnippetMark () instance MkSnippetCmd (SnippetCmd a) a instance MkSnippetCmd String () instance Ord MarkInfo instance Initializable DependentMarks instance Initializable BufferMarks module Yi.Snippets.Haskell hsFunction :: SnippetCmd () hsClass :: SnippetCmd () module Yi.Syntax.Layout -- | Transform a scanner into a scanner that also adds opening, closing and -- next tokens to indicate layout. layoutHandler :: (Show t, Eq t) => (t -> Bool) -> [(t, t)] -> (Tok t -> Bool) -> [t] -> (Tok t -> Bool) -> Scanner (AlexState lexState) (Tok t) -> Scanner (State t lexState) (Tok t) type State t lexState = (IState t, AlexState lexState) instance (Show t) => Show (IState t) instance (Show t) => Show (BlockOpen t) module Yi.Syntax.Haskell type PModule = Exp type PModuleDecl = Exp type PImport = Exp -- | Exp can be expression or declaration data Exp t PModule :: [t] -> (Maybe (PModule t)) -> Exp t comments :: Exp t -> [t] progMod :: Exp t -> (Maybe (PModule t)) ProgMod :: (PModuleDecl t) -> (PModule t) -> Exp t modDecl :: Exp t -> (PModuleDecl t) -- | The module declaration part body :: Exp t -> (PModule t) Body :: Exp t -> (Block t) -> (Block t) -> Exp t imports :: Exp t -> Exp t content :: Exp t -> (Block t) -- | The body of the module extraContent :: Exp t -> (Block t) PModuleDecl :: (PAtom t) -> (PAtom t) -> (Exp t) -> (Exp t) -> Exp t moduleKeyword :: Exp t -> (PAtom t) name :: Exp t -> (PAtom t) exports :: Exp t -> (Exp t) whereKeyword :: Exp t -> (Exp t) PImport :: (PAtom t) -> (Exp t) -> (PAtom t) -> (Exp t) -> (Exp t) -> Exp t importKeyword :: Exp t -> (PAtom t) qual :: Exp t -> (Exp t) name' :: Exp t -> (PAtom t) as :: Exp t -> (Exp t) specification :: Exp t -> (Exp t) -- | Type signature TS :: t -> [Exp t] -> Exp t -- | Type declaration PType :: (PAtom t) -> (Exp t) -> (PAtom t) -> (Exp t) -> Exp t typeKeyword :: Exp t -> (PAtom t) typeCons :: Exp t -> (Exp t) equal :: Exp t -> (PAtom t) btype :: Exp t -> (Exp t) -- | Data declaration PData :: (PAtom t) -> (Exp t) -> (Exp t) -> (Exp t) -> Exp t dataKeyword :: Exp t -> (PAtom t) dtypeCons :: Exp t -> (Exp t) dEqual :: Exp t -> (Exp t) dataRhs :: Exp t -> (Exp t) PData' :: (PAtom t) -> (Exp t) -> Exp t dEqual :: Exp t -> (PAtom t) -- | Data declaration RHS dataCons :: Exp t -> (Exp t) PClass :: (PAtom t) -> (Exp t) -> (Exp t) -> Exp t cKeyword :: Exp t -> (PAtom t) cHead :: Exp t -> (Exp t) -- | Class declaration cwhere :: Exp t -> (Exp t) -- | A parenthesized, bracked or braced Paren :: (PAtom t) -> [Exp t] -> (PAtom t) -> Exp t -- | A block of things separated by layout Block :: [Exp t] -> Exp t -- | An atom is a token followed by many comments PAtom :: t -> [t] -> Exp t Expr :: [Exp t] -> Exp t -- | Where clause PWhere :: (PAtom t) -> (Exp t) -> (Exp t) -> Exp t Bin :: (Exp t) -> (Exp t) -> Exp t PError :: t -> t -> [t] -> Exp t errorTok :: Exp t -> t marker :: Exp t -> t -- | An wrapper for errors commentList :: Exp t -> [t] -- | Righthandside of functions with = RHS :: (PAtom t) -> (Exp t) -> Exp t -- | An optional Opt :: (Maybe (Exp t)) -> Exp t -- | Module identifier Modid :: t -> [t] -> Exp t Context :: (Exp t) -> (Exp t) -> (PAtom t) -> Exp t -- | Righthandside of functions with | the PAtom in PGuard' does not -- contain any comments PGuard :: [PGuard t] -> Exp t PGuard' :: (PAtom t) -> (Exp t) -> (PAtom t) -> Exp t -- | Type constructor data constructor same as with the TC constructor TC :: (Exp t) -> Exp t -- | Data constructor DC :: (Exp t) -> Exp t -- | let expression PLet :: (PAtom t) -> (Exp t) -> (Exp t) -> Exp t PIn :: t -> [Exp t] -> Exp t type Tree = PModule -- | The parser parse :: P TT (Tree TT) indentScanner :: Scanner (AlexState lexState) (TT) -> Scanner (State Token lexState) (TT) instance IsTree Exp instance Foldable Exp instance (Show t) => Show (Exp t) module Yi.Syntax.Strokes.Haskell getStrokes :: Point -> Point -> Point -> Tree TT -> [Stroke] tokenToAnnot :: TT -> Maybe (Span String) -- | Parser for haskell that takes in account only parenthesis and layout module Yi.Syntax.Paren indentScanner :: Scanner (AlexState lexState) (TT) -> Scanner (State Token lexState) (TT) isBrace :: TT -> Bool ignoredToken :: TT -> Bool isNoise :: Token -> Bool type Expr t = [Tree t] data Tree t Paren :: t -> (Expr t) -> t -> Tree t Block :: ([Tree t]) -> Tree t Atom :: t -> Tree t Error :: t -> Tree t Expr :: [Tree t] -> Tree t -- | Search the given list, and return the 1st tree after the given point -- on the given line. This is the tree that will be moved if something is -- inserted at the point. Precondition: point is in the given line. getIndentingSubtree :: Tree TT -> Point -> Int -> Maybe (Tree TT) -- | Given a tree, return (first offset, number of lines). getSubtreeSpan :: Tree TT -> (Point, Int) parse :: P TT (Tree TT) parse' :: (TT -> Token) -> (Token -> TT) -> P TT [Tree TT] getStrokes :: Point -> Point -> Point -> Tree TT -> [Stroke] tokenToStroke :: TT -> Stroke modStroke :: StyleName -> Stroke -> Stroke tokenToAnnot :: TT -> Maybe (Span String) instance IsTree Tree instance Foldable Tree instance (Show t) => Show (Tree t) -- | Haskell-specific modes and commands. module Yi.Mode.Haskell -- | Clever haskell mode, using the paren-matching syntax. cleverMode :: Mode (Tree (Tok Token)) -- | Experimental Haskell mode, using a rather precise parser for the -- syntax. preciseMode :: Mode (Tree TT) literateMode :: Mode (Tree TT) fastMode :: Mode (Tree TT) -- | Return GHCi's buffer; create it if necessary. Show it in another -- window. ghciGet :: YiM BufferRef -- | Send a command to GHCi ghciSend :: String -> YiM () -- | Load current buffer in GHCi ghciLoadBuffer :: YiM () ghciInferType :: YiM () instance Typeable GhciBuffer instance Initializable GhciBuffer instance Binary GhciBuffer module Yi.Mode.Haskell.Dollarify dollarify :: Tree TT -> BufferM () dollarifyWithin :: Tree TT -> BufferM () data QueuedUpdate QueuedUpdate :: Point -> String -> Int -> QueuedUpdate qUpdatePoint :: QueuedUpdate -> Point qInsert :: QueuedUpdate -> String qDelete :: QueuedUpdate -> Int runQ :: [QueuedUpdate] -> BufferM () closeParen :: Token openParen :: Token isNormalParen :: Tree TT -> Bool isTuple :: Tree TT -> Bool queueDelete :: TT -> QueuedUpdate queueReplaceWith :: String -> TT -> QueuedUpdate stripComments :: Expr TT -> Expr TT dollarifyTop :: Tree TT -> [QueuedUpdate] dollarifyExpr :: Expr TT -> [QueuedUpdate] isSimple :: Tree TT -> Bool isCollapsible :: Expr TT -> Bool selectedTree :: Expr TT -> Region -> Maybe (Tree TT) findLargestWithin :: Region -> [Tree TT] -> Tree TT within :: Region -> Tree TT -> Bool safeLast :: [a] -> Maybe a dollarifyP :: Tree TT -> BufferM () dollarifyWithinP :: Exp TT -> BufferM () isNormalParenP :: Exp TT -> Bool isTupleP :: Exp TT -> Bool stripCommentsP :: [Exp TT] -> [Exp TT] dollarifyTopP :: Exp TT -> [QueuedUpdate] dollarifyExprP :: [Exp TT] -> [QueuedUpdate] isSimpleP :: Exp TT -> Bool isCollapsibleP :: [Exp TT] -> Bool selectedTreeP :: [Exp TT] -> Region -> Maybe (Exp TT) findLargestWithinP :: Region -> [Exp TT] -> Exp TT withinP :: Region -> Exp TT -> Bool safeLastP :: [a] -> Maybe a instance Eq QueuedUpdate instance Ord QueuedUpdate instance Show QueuedUpdate -- | This module defines a user interface implemented using vty. module Yi.UI.Vty -- | Initialise the ui start :: UIBoot module Yi.Config.Default defaultConfig :: Config availableFrontends :: [(String, UIBoot)] defaultEmacsConfig :: Config defaultVimConfig :: Config defaultCuaConfig :: Config toVimStyleConfig :: Config -> Config toEmacsStyleConfig :: Config -> Config toCuaStyleConfig :: Config -> Config -- | This is the main module of Yi, called with configuration from the -- user. Here we mainly process command line arguments. module Yi.Main -- | Static main. This is the front end to the statically linked -- application, and the real front end, in a sense. dynamic_main -- calls this after setting preferences passed from the boot loader. main :: Config -> Maybe Editor -> IO () instance Error Err -- | Boot process of Yi, as an instanciation of Dyre module Yi.Boot yi :: Config -> IO () yiDriver :: Config -> IO () reload :: YiM () -- | Facade of the Yi library, for use by confguration file. Just -- re-exports a bunch of modules. -- -- You should therefore: import Yi in your ~.yi scripts module Yi -- | A prototype. Typically the parameter will be a record type. Fields can -- be defined in terms of others fields, with the idea that some of these -- definitons can be overridden. -- -- Example: -- --
-- data O = O {f1, f2, f3 :: Int}
-- deriving Show
-- o1 = Proto $ \self -> O
-- {
-- f1 = 1,
-- f2 = f1 self + 1, -- 'f1 self' refers to the overriden definition of f1.
-- f3 = f1 self + 2
-- }
--
newtype Proto a
Proto :: (a -> a) -> Proto a
fromProto :: Proto a -> a -> a
-- | Get the value of a prototype. This can return bottom in case some
-- fields are recursively defined in terms of each other.
extractValue :: Proto t -> t
-- | Override a prototype. Fields can be defined in terms of their
-- definition in the base prototype.
--
-- Example:
--
--
-- o2 = o1 `override` \super self -> super
-- {
-- f1 = f1 super + 10,
-- f3 = f3 super + 1
-- }
--
override :: Proto a -> (a -> a -> a) -> Proto a
-- | Field access
(.->) :: Proto t -> (t -> a) -> a