rasa-0.1.10: A modular text editor

Safe HaskellNone
LanguageHaskell2010

Rasa.Internal.Extensions

Synopsis

Documentation

data Ext Source #

A wrapper around an extension of any type so it can be stored in an ExtMap

Constructors

Show a => Ext a 

Instances

Show Ext Source # 

Methods

showsPrec :: Int -> Ext -> ShowS #

show :: Ext -> String #

showList :: [Ext] -> ShowS #

type ExtMap = Map TypeRep Ext Source #

A map of extension types to their current value.

class HasExts s where Source #

Members of this class have access to editor extensions.

Minimal complete definition

exts

Methods

exts :: Lens' s (Map TypeRep Ext) Source #

This lens focuses the Extensions States

class (Typeable m, Monad m) => HasExtMonad m where Source #

Minimal complete definition

getExt, setExt

Methods

getExt :: (Typeable ext, Show ext, Default ext) => m ext Source #

Retrieve some extension state

setExt :: (Typeable ext, Show ext, Default ext) => ext -> m () Source #

Set some extension state

overExt :: (Typeable ext, Show ext, Default ext) => (ext -> ext) -> m () Source #

Set some extension state

Instances

HasExtMonad BufAction Source # 

Methods

getExt :: (Typeable * ext, Show ext, Default ext) => BufAction ext Source #

setExt :: (Typeable * ext, Show ext, Default ext) => ext -> BufAction () Source #

overExt :: (Typeable * ext, Show ext, Default ext) => (ext -> ext) -> BufAction () Source #

HasExtMonad Action Source # 

Methods

getExt :: (Typeable * ext, Show ext, Default ext) => Action ext Source #

setExt :: (Typeable * ext, Show ext, Default ext) => ext -> Action () Source #

overExt :: (Typeable * ext, Show ext, Default ext) => (ext -> ext) -> Action () Source #

ext :: forall a e. (Show a, Typeable a, Default a, HasExts e) => Lens' e a Source #

This is a lens which will focus the extension state that matches the type inferred as the focal point. It's a little bit of magic, if you treat the focus as a member of your extension state it should just work out.

This lens falls back on the extension's Default instance (when getting) if nothing has yet been stored.