{-# LANGUAGE MultiParamTypeClasses #-}
module Data.Generics.PlateDirect
{-# DEPRECATED "Use Data.Generics.Uniplate.Direct instead" #-}
(
module Data.Generics.Biplate,
plate, plateSelf,
(|+), (|-), (|*), (||+), (||*)
) where
import Data.Generics.Biplate
type Type from to = (Str to, Str to -> from)
plate :: from -> Type from to
plate f = (Zero, \_ -> f)
(|*) :: Type (to -> from) to -> to -> Type from to
(|*) (xs,x_) y = (Two xs (One y),\(Two xs (One y)) -> x_ xs y)
(|+) :: Biplate item to => Type (item -> from) to -> item -> Type from to
(|+) (xs,x_) y = case biplate y of
(ys,y_) -> (Two xs ys, \(Two xs ys) -> x_ xs (y_ ys))
(|-) :: Type (item -> from) to -> item -> Type from to
(|-) (xs,x_) y = (xs,\xs -> x_ xs y)
(||*) :: Type ([to] -> from) to -> [to] -> Type from to
(||*) (xs,x_) y = (Two xs (listStr y), \(Two xs ys) -> x_ xs (strList ys))
(||+) :: Biplate item to => Type ([item] -> from) to -> [item] -> Type from to
(||+) (xs,x_) y = case plateListDiff y of
(ys,y_) -> (Two xs ys, \(Two xs ys) -> x_ xs (y_ ys))
where
plateListDiff [] = plate []
plateListDiff (x:xs) = plate (:) |+ x ||+ xs
plateSelf :: to -> Type to to
plateSelf x = (One x, \(One x) -> x)