{-# LANGUAGE MultiParamTypeClasses #-}

{- |
    /DEPRECATED/: Use "Data.Generics.Uniplate.Operations" instead.

    Requires multi-parameter type classes, so is no longer Haskell 98. These operations
    are easier to use and construct than the equivalent "Data.Generics.UniplateStrOn" methods,
    but perform the same operation.

    It is recommended that instead of importing this module, you import one of the following
    modules, to construct instances:

    * "Data.Generics.PlateDirect" - does not require overlapping instances, highest performance
    but requires /O(n^2)/ instances in the worst case.

    * "Data.Generics.PlateTypeable" - requires the "Data.Typeable" class for all data structures.

    * "Data.Generics.PlateData" - requires "Data.Generics" and the 'Data' class, which is only
    available on GHC, but automatically infers instances.
-}

module Data.Generics.Biplate
    {- DEPRECATED "Use Data.Generics.Uniplate.Operations instead" -}
    (
    module Data.Generics.UniplateStrOn,
    module Data.Generics.Biplate
    ) where

import Data.Generics.UniplateStrOn


-- * The Class

-- | Children are defined as the top-most items of type to
--   /starting at the root/.
class Uniplate to => Biplate from to where
    biplate :: BiplateType from to


-- | Compatibility method, for direct users of the 'biplate' function
biplateList :: Biplate from to => from -> ([to], [to] -> from)
biplateList :: from -> ([to], [to] -> from)
biplateList from
x = ([to]
c, Str to -> from
b (Str to -> from) -> ([to] -> Str to) -> [to] -> from
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [to] -> Str to
d)
    where
        (Str to
a,Str to -> from
b) = BiplateType from to
forall from to. Biplate from to => BiplateType from to
biplate from
x
        ([to]
c,[to] -> Str to
d) = Str to -> ([to], [to] -> Str to)
forall a. Str a -> ([a], [a] -> Str a)
strStructure Str to
a



-- * The Operations

-- ** Queries

universeBi :: Biplate from to => from -> [to]
universeBi :: from -> [to]
universeBi = BiplateType from to -> from -> [to]
forall to from. Uniplate to => BiplateType from to -> from -> [to]
universeOn BiplateType from to
forall from to. Biplate from to => BiplateType from to
biplate


childrenBi :: Biplate from to => from -> [to]
childrenBi :: from -> [to]
childrenBi = BiplateType from to -> from -> [to]
forall to from. Uniplate to => BiplateType from to -> from -> [to]
childrenOn BiplateType from to
forall from to. Biplate from to => BiplateType from to
biplate


-- ** Transformations

transformBi :: Biplate from to => (to -> to) -> from -> from
transformBi :: (to -> to) -> from -> from
transformBi = BiplateType from to -> (to -> to) -> from -> from
forall to from.
Uniplate to =>
BiplateType from to -> (to -> to) -> from -> from
transformOn BiplateType from to
forall from to. Biplate from to => BiplateType from to
biplate


transformBiM :: (Monad m, Biplate from to) => (to -> m to) -> from -> m from
transformBiM :: (to -> m to) -> from -> m from
transformBiM = BiplateType from to -> (to -> m to) -> from -> m from
forall (m :: * -> *) to from.
(Monad m, Uniplate to) =>
BiplateType from to -> (to -> m to) -> from -> m from
transformOnM BiplateType from to
forall from to. Biplate from to => BiplateType from to
biplate


rewriteBi :: Biplate from to => (to -> Maybe to) -> from -> from
rewriteBi :: (to -> Maybe to) -> from -> from
rewriteBi = BiplateType from to -> (to -> Maybe to) -> from -> from
forall to from.
Uniplate to =>
BiplateType from to -> (to -> Maybe to) -> from -> from
rewriteOn BiplateType from to
forall from to. Biplate from to => BiplateType from to
biplate


rewriteBiM :: (Monad m, Biplate from to) => (to -> m (Maybe to)) -> from -> m from
rewriteBiM :: (to -> m (Maybe to)) -> from -> m from
rewriteBiM = BiplateType from to -> (to -> m (Maybe to)) -> from -> m from
forall (m :: * -> *) to from.
(Monad m, Uniplate to) =>
BiplateType from to -> (to -> m (Maybe to)) -> from -> m from
rewriteOnM BiplateType from to
forall from to. Biplate from to => BiplateType from to
biplate


descendBi :: Biplate from to => (to -> to) -> from -> from
descendBi :: (to -> to) -> from -> from
descendBi = BiplateType from to -> (to -> to) -> from -> from
forall to from.
Uniplate to =>
BiplateType from to -> (to -> to) -> from -> from
descendOn BiplateType from to
forall from to. Biplate from to => BiplateType from to
biplate


descendBiM :: (Monad m, Biplate from to) => (to -> m to) -> from -> m from
descendBiM :: (to -> m to) -> from -> m from
descendBiM = BiplateType from to -> (to -> m to) -> from -> m from
forall (m :: * -> *) to from.
(Monad m, Uniplate to) =>
BiplateType from to -> (to -> m to) -> from -> m from
descendOnM BiplateType from to
forall from to. Biplate from to => BiplateType from to
biplate


-- ** Others

contextsBi:: Biplate from to => from -> [(to, to -> from)]
contextsBi :: from -> [(to, to -> from)]
contextsBi = BiplateType from to -> from -> [(to, to -> from)]
forall to from.
Uniplate to =>
BiplateType from to -> from -> [(to, to -> from)]
contextsOn BiplateType from to
forall from to. Biplate from to => BiplateType from to
biplate


holesBi:: Biplate from to => from -> [(to, to -> from)]
holesBi :: from -> [(to, to -> from)]
holesBi = BiplateType from to -> from -> [(to, to -> from)]
forall to from.
Uniplate to =>
BiplateType from to -> from -> [(to, to -> from)]
holesOn BiplateType from to
forall from to. Biplate from to => BiplateType from to
biplate