{-# 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 :: forall from to. Biplate from to => from -> ([to], [to] -> from)
biplateList from
x = ([to]
c, Str to -> from
b forall b c a. (b -> c) -> (a -> b) -> a -> c
. [to] -> Str to
d)
    where
        (Str to
a,Str to -> from
b) = forall from to. Biplate from to => BiplateType from to
biplate from
x
        ([to]
c,[to] -> Str to
d) = forall a. Str a -> ([a], [a] -> Str a)
strStructure Str to
a



-- * The Operations

-- ** Queries

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


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


-- ** Transformations

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


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


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


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


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


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


-- ** Others

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


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