cursor-0.3.2.0: Purely Functional Cursors
Safe HaskellNone
LanguageHaskell2010

Cursor.Tree.Demote

Synopsis

Documentation

treeCursorDemoteElem :: (a -> b) -> (b -> a) -> TreeCursor a b -> DemoteResult (TreeCursor a b) Source #

Demotes the current node to the level of its children.

Example:

Before:

 p
 |- a
 |  |- b
 |- c <--
 |  |- d
 |- e

After:

 p
 |- a
 |  |- b
 |  |- c <--
 |  |- d
 |- e

treeCursorDemoteSubTree :: (a -> b) -> (b -> a) -> TreeCursor a b -> DemoteResult (TreeCursor a b) Source #

Demotes the current subtree to the level of its children.

Example:

Before:

 p
 |- a
 |  |- b
 |- c <--
 |  |- d
 |- e

After:

 p
 |- a
 |  |- b
 |  |- c <--
 |     |- d
 |- e

data DemoteResult a Source #

Instances

Instances details
Functor DemoteResult Source # 
Instance details

Defined in Cursor.Tree.Demote

Methods

fmap :: (a -> b) -> DemoteResult a -> DemoteResult b #

(<$) :: a -> DemoteResult b -> DemoteResult a #

Eq a => Eq (DemoteResult a) Source # 
Instance details

Defined in Cursor.Tree.Demote

Show a => Show (DemoteResult a) Source # 
Instance details

Defined in Cursor.Tree.Demote

Generic (DemoteResult a) Source # 
Instance details

Defined in Cursor.Tree.Demote

Associated Types

type Rep (DemoteResult a) :: Type -> Type #

Methods

from :: DemoteResult a -> Rep (DemoteResult a) x #

to :: Rep (DemoteResult a) x -> DemoteResult a #

NFData a => NFData (DemoteResult a) Source # 
Instance details

Defined in Cursor.Tree.Demote

Methods

rnf :: DemoteResult a -> () #

Validity a => Validity (DemoteResult a) Source # 
Instance details

Defined in Cursor.Tree.Demote

type Rep (DemoteResult a) Source # 
Instance details

Defined in Cursor.Tree.Demote

type Rep (DemoteResult a) = D1 ('MetaData "DemoteResult" "Cursor.Tree.Demote" "cursor-0.3.2.0-Ch3lJwc3yY89mrJgbt03T" 'False) (C1 ('MetaCons "CannotDemoteTopNode" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "NoSiblingsToDemoteUnder" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Demoted" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))))

treeCursorDemoteElemUnder :: b -> b -> TreeCursor a b -> Maybe (TreeCursor a b) Source #

Demotes the current node to the level of its children, by adding two roots. One for the current node and one for its children that are left behind.

Example:

Before:

 p
 |- a <--
    |- b

After:

 p
 |- <given element 1>
 |  |- a <--
 |- <given element 2>
 |  |- b

treeCursorDemoteSubTreeUnder :: b -> TreeCursor a b -> TreeCursor a b Source #

Demotes the current subtree to the level of its children, by adding a root.

Example:

Before:

 a <--
 |- b

After:

 <given element>
 |- a <--
    |- b