The standard Uniplate class, all operations require this. All definitions must define uniplate, while descend and descendM are optional.
Methods
uniplate :: on -> (Str on, Str on -> on)The underlying method in the class. Taking a value, the function should return all the immediate children of the same type, and a function to replace them.
Given
uniplate x = (cs, gen)csshould be aStr on, constructed ofZero,OneandTwo, containing allx's direct children of the same type asx.genshould take aStr onwith exactly the same structure ascs, and generate a new element with the children replaced.Example instance:
instance Uniplate Expr where uniplate (Val i ) = (Zero , \Zero -> Val i ) uniplate (Neg a ) = (One a , \(One a) -> Neg a ) uniplate (Add a b) = (Two (One a) (One b), \(Two (One a) (One b)) -> Add a b)descend :: (on -> on) -> on -> onPerform a transformation on all the immediate children, then combine them back. This operation allows additional information to be passed downwards, and can be used to provide a top-down transformation. This function can be defined explicitly, or can be provided by automatically in terms of uniplate.
For example, on the sample type, we could write:
descend f (Val i ) = Val i descend f (Neg a ) = Neg (f a) descend f (Add a b) = Add (f a) (f b)descendM :: Applicative m => (on -> m on) -> on -> m onApplicative variant of descend
Instances11Uniplate, …
Data a => Uniplate aDefined in uniplate-1.6.13 · Data.Generics.Uniplate.Data · orphanUniplate IntegerDefined in uniplate-1.6.13 · Data.Generics.Uniplate.Direct · orphanUniplate BoolDefined in uniplate-1.6.13 · Data.Generics.Uniplate.Direct · orphanUniplate CharDefined in uniplate-1.6.13 · Data.Generics.Uniplate.Direct · orphanUniplate DoubleDefined in uniplate-1.6.13 · Data.Generics.Uniplate.Direct · orphanUniplate FloatDefined in uniplate-1.6.13 · Data.Generics.Uniplate.Direct · orphanUniplate IntDefined in uniplate-1.6.13 · Data.Generics.Uniplate.Direct · orphanUniplate ()Defined in uniplate-1.6.13 · Data.Generics.Uniplate.Direct · orphanPlateAll a a => Uniplate aDefined in uniplate-1.6.13 · Data.Generics.Uniplate.Typeable · orphanUniplate (Ratio Integer)Defined in uniplate-1.6.13 · Data.Generics.Uniplate.Direct · orphanUniplate [Char]Defined in uniplate-1.6.13 · Data.Generics.Uniplate.Direct · orphan