Part of the 'transform' infrastructure.
Part of the 'transform' infrastructure. transform ca take either a T only or a (T, A). (t, a) is bit cumbersome to write and that is why CTWithResult exists. This allows to write t andCollect a instead of (t, List(a))
This is solely use to write collect as def collect[C[_] ] = new CollectInType[C] {..} instead of def collect[C[_] ] = new {} and so to not use reflective calls.
This is solely use to write collect as def collect[C[_] ] = new CollectInType[C] {..} instead of def collect[C[_] ] = new {} and so to not use reflective calls. This as not been benchmarked so I don't really know if it has a real performance impact
This trait allows to easily write simple traversals.
This trait allows to easily write simple traversals. Instead of writing: t : T val x = topDown(collect{...}) val result = x(t).result We can wirte instead t.collect{...}
topDownBreak(focus{..} ~> topDown{transform{...}}) (t) becomes t.topDownBreak.focus{..}.topDown.transform{..} Which is essentially easier to read and to write
The drawbacks:
/!\ Beware: this code contains a lot of implcit magic tricks
This trait is part of the infrastructure required to make the collect combinator have a default parameter to List[_].
This trait is part of the infrastructure required to make the collect combinator have a default parameter to List[_]. C is the type of the collection (ex: List[Int]) given by the User (or inferred to Nothing by the compiler) A is the element inside the collection (in List[Int] it would be Int) R is the 'real' collection that will be used i.e if C = Nothing => R = List[A] else R = C
Note: maybe it would be interesting to generate such boilerplaite with a macro annotation. Something like that:
This trait contains the base combinators which can be used to write powerful traversers.
Abstract class used to delay delay the time when the type parameter of a meta combinator is decided.
Abstract class used to delay delay the time when the type parameter of a meta combinator is decided. Anonymous functions can't take type parameter, so this ugly stuff is required
Allows to call 'combinators' directly on T For documentation see Combinators.scala
Allows to call 'combinators' directly on T For documentation see Combinators.scala
Evaluator at which will be applied m andThen the traversal strategy defined in 'meta'
Evaluator at which will be applied m andThen the traversal strategy defined in 'meta'
Evaluator at which will be applied the traversal strategy defined in 'meta'
Evaluator at which will be applied the traversal strategy defined in 'meta'
This has to be outside of EvaluatorAndThen because of covarience stuff it is not possible to write def force(implicit x: Monoid[A]) = ...inside EvaluatorAndThen[A] We should write def force[B >: A](implicit x: Monoid[B]) but Monoid should be made contravarient in A, which is not possible (in part because it is not logical and because contravarient stuff does not work well with implicits)
This has to be outside of EvaluatorAndThen because of covarience stuff it is not possible to write def force(implicit x: Monoid[A]) = ...inside EvaluatorAndThen[A] We should write def force[B >: A](implicit x: Monoid[B]) but Monoid should be made contravarient in A, which is not possible (in part because it is not logical and because contravarient stuff does not work well with implicits)
A Matcher is a function or 'combinator' which takes a T and return an Option of tuple of - a transformed T (or the same) - a result of type A s.t Exists Monoid[A] so that results can be combined during the traversal A transformation/traversal has succeeded if the result of the application on the Matcher is not a None
A Matcher is a function or 'combinator' which takes a T and return an Option of tuple of - a transformed T (or the same) - a result of type A s.t Exists Monoid[A] so that results can be combined during the traversal A transformation/traversal has succeeded if the result of the application on the Matcher is not a None
Make it possible to use the collection like ui api inside different structures A := Result of the Matcher R := Some anonymous type which represents the result of a transformation on each MatchResult V := T | Option[T] | Seq[T] L := R | Option[R] | Seq[R]
Make it possible to use the collection like ui api inside different structures A := Result of the Matcher R := Some anonymous type which represents the result of a transformation on each MatchResult V := T | Option[T] | Seq[T] L := R | Option[R] | Seq[R]
Convention : Operators ending with : are right assosiative Moreover a \: b is desugared to b.\:(a)
Convention : Operators ending with : are right assosiative Moreover a \: b is desugared to b.\:(a)
https://en.wikipedia.org/wiki/Monoid
System needed to recover the correct type from a 'transfrom' call.
System needed to recover the correct type from a 'transfrom' call. 1) x.transform{case x: T => x} : T 2) x.transform{case x: T => (x, List(1))} : (T, List[Int])
Alias for select
Alias for select
Different base implementation of several instances of Monoids
Same as bottomUpBreak, but does not sop when a transformation/traversal has succeeded
Same as bottomUpBreak, but does not sop when a transformation/traversal has succeeded
Traverse the tree in a BottomUp manner, stop when a transformation/traversal has succeeded
Traverse the tree in a BottomUp manner, stop when a transformation/traversal has succeeded
Traverse the direct children of the tree and apply f to them.
Traverse the direct children of the tree and apply f to them.
Same as visit but puts the results into a collection (List by default)
Same as visit but puts the results into a collection (List by default)
same as collect but put the results into a collection of 2 type parameter e.g a Map[K, V]
same as collect but put the results into a collection of 2 type parameter e.g a Map[K, V]
The infamous fix point combinator
The infamous fix point combinator
Syntactic sugar for guard combinator so that one doesn't need to type the type parameter
Syntactic sugar for guard combinator so that one doesn't need to type the type parameter
Succeed if the partial function f applied on the tree is defined and return true
Succeed if the partial function f applied on the tree is defined and return true
Simple Identity combinator.
Simple Identity combinator. a identity = a
Alias for focus{case t: U => some((t,t)}
Alias for focus{case t: U => some((t,t)}
Same as TopDown, but does not sop when a transformation/traversal has succeeded
Same as TopDown, but does not sop when a transformation/traversal has succeeded
Traverse the tree in a TopDown manner, stop when a transformation/traversal has succeeded
Traverse the tree in a TopDown manner, stop when a transformation/traversal has succeeded
Syntactic sugar for transform combinator so that one doesn't need to type the type parameter
Syntactic sugar for transform combinator so that one doesn't need to type the type parameter
Transform a I into a T where both I and O are subtypes of T and where a transformation from I to O is authorized
Transform a I into a T where both I and O are subtypes of T and where a transformation from I to O is authorized
Traverse the data structure and return a result
Traverse the data structure and return a result