
Data.Generics.Strafunski.StrategyLib.KeyholeTheme  Portability  portable  Stability  experimental  Maintainer  Ralf Laemmel, Joost Visser 





Description 
This module is part of StrategyLib, a library of functional strategy
combinators, including combinators for generic traversal. This module
defines a number combinators for keyhole operations, i.e. for operations
that have ordinary parametric or adhoc polymorhpic types, but employ
strategies inside.


Synopsis 

selectFocus :: (Term f, Term t) => (f > Maybe f) > t > Maybe f   replaceFocus :: (Term t, Term t') => (t > Maybe t) > t' > Maybe t'   deleteFocus :: (Term f, Term [f], Term t) => (f > Maybe f) > t > Maybe t   selectHost :: (Term f, Term h, Term t) => (f > Maybe f) > (h > Maybe h) > t > Maybe h   markHost :: (Term f, Term h, Term t) => (f > Bool) > (h > h) > t > Maybe t   listify :: (Term x, Term y) => x > [y]   strings :: Term x => x > [String]   inj :: (MonadPlus m, Term x, Term c) => (c > m c) > x > m x 



Focus


selectFocus 
:: (Term f, Term t)   => (f > Maybe f)  Identify focus
 > t  Input term
 > Maybe f  Focused term
 Select the identified focus.
Fails if no subterm can be selected.



replaceFocus :: (Term t, Term t') => (t > Maybe t) > t' > Maybe t' 
Replace the identified focus.
Fails if no subterm can be replaced.


deleteFocus 
:: (Term f, Term [f], Term t)   => (f > Maybe f)  Identify focus
 > t  Input term
 > Maybe t  Output term without focused entity
 Delete the focus assuming it is an element in a list.
Fails if no deletion can be performed.



selectHost 
:: (Term f, Term h, Term t)   => (f > Maybe f)  Get focus
 > (h > Maybe h)  Get host
 > t  Input term
 > Maybe h  Located host
 Find the host of the focused entity, i.e. a superterm of the
focussed subterm.



markHost 
:: (Term f, Term h, Term t)   => (f > Bool)  Test focus
 > (h > h)  Wrap host
 > t  Input term
 > Maybe t  Output term



Listification


listify :: (Term x, Term y) => x > [y] 
Put all nodes of a certain type into a list.


strings :: Term x => x > [String] 
Put all nodes of type String into a list. This is a typespecialization
of listify.


Keyhole versions of basic strategy combinators.


inj :: (MonadPlus m, Term x, Term c) => (c > m c) > x > m x 
Apply the argument function to the unique subterm of the input term.
Fail if the input term has more subterms or if the subterm is not of
the appropriate type. This is a keyhole version of the traversal
combinator injTP


Produced by Haddock version 0.8 