{- |
/DEPRECATED/: Use "Data.Generics.Uniplate.Operations" instead.
This module retained Haskell 98 compatability, but users who are happy with
multi-parameter type classes should look towards "Data.Generics.Biplate".
The only function missing from "Data.Generics.Uniplate" is 'fold', as it can be
constructed from 'children' and has little meaning in a multi-typed setting.
All operations, apart from 'childrenOn', 'descendOn' and 'holesOn' should perform
identically to their non @On@ counterparts.
-}moduleData.Generics.UniplateStrOn{- DEPRECATED "Use Data.Generics.Uniplate.Operations instead" -}(moduleData.Generics.UniplateStr,moduleData.Generics.UniplateStrOn)whereimportControl.Monad(liftM)importData.TraversableimportPreludehiding(mapM)importData.Generics.Uniplate.Internal.UtilsimportData.Generics.StrimportData.Generics.UniplateStr-- * Types-- | Return all the top most children of type @to@ within @from@.---- If @from == to@ then this function should return the root as the single-- child.typeBiplateTypefromto=from->(Strto,Strto->from)-- * Operations-- ** QueriesuniverseOn::Uniplateto=>BiplateTypefromto->from->[to]universeOnbiplatex=builderfwherefconsnil=gconsnil(fst$biplatex)nilgconsnilZerores=resgconsnil(Onex)res=x`cons`gconsnil(fst$uniplatex)resgconsnil(Twoxy)res=gconsnilx(gconsnilyres)-- | Return the children of a type. If @to == from@ then it returns the-- original element (in contrast to 'children')childrenOn::Uniplateto=>BiplateTypefromto->from->[to]childrenOnbiplatex=builderfwherefconsnil=gconsnil(fst$biplatex)nilgconsnilZerores=resgconsnil(Onex)res=x`cons`resgconsnil(Twoxy)res=gconsnilx(gconsnilyres)-- ** TransformationstransformOn::Uniplateto=>BiplateTypefromto->(to->to)->from->fromtransformOnbiplatefx=generate$fmap(transformf)currentwhere(current,generate)=biplatextransformOnM::(Monadm,Uniplateto)=>BiplateTypefromto->(to->mto)->from->mfromtransformOnMbiplatefx=liftMgenerate$mapM(transformMf)currentwhere(current,generate)=biplatexrewriteOn::Uniplateto=>BiplateTypefromto->(to->Maybeto)->from->fromrewriteOnbiplatefx=generate$fmap(rewritef)currentwhere(current,generate)=biplatexrewriteOnM::(Monadm,Uniplateto)=>BiplateTypefromto->(to->m(Maybeto))->from->mfromrewriteOnMbiplatefx=liftMgenerate$mapM(rewriteMf)currentwhere(current,generate)=biplatexdescendOn::Uniplateto=>BiplateTypefromto->(to->to)->from->fromdescendOnbiplatefx=generate$fmapfcurrentwhere(current,generate)=biplatexdescendOnM::(Monadm,Uniplateto)=>BiplateTypefromto->(to->mto)->from->mfromdescendOnMbiplatefx=liftMgenerate$mapMfcurrentwhere(current,generate)=biplatex-- ** OtherholesOn::Uniplateto=>BiplateTypefromto->from->[(to,to->from)]holesOnbiplatex=uncurryf(biplatex)wherefZero_=[]f(Onei)generate=[(i,generate.One)]f(Twolr)gen=fl(gen.(\i->Twoir))++fr(gen.(\i->Twoli))contextsOn::Uniplateto=>BiplateTypefromto->from->[(to,to->from)]contextsOnbiplatex=f(holesOnbiplatex)wherefxs=[(y,ctx.context)|(child,ctx)<-xs,(y,context)<-contextschild]-- * Helper for writing instances-- | Used for defining instances @UniplateFoo a => UniplateFoo [a]@uniplateOnList::BiplateTypeab->BiplateType[a]buniplateOnListf[]=(Zero,\_->[])uniplateOnListf(x:xs)=(Twoaas,\(Twonns)->bn:bsns)where(a,b)=fx(as,bs)=uniplateOnListfxs