Skip to content

Commit

Permalink
Clarify optmization parameter and pretty-print order
Browse files Browse the repository at this point in the history
  • Loading branch information
satabin committed Sep 26, 2023
1 parent cfc412c commit 70e623f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion finite-state/shared/src/main/scala/fs2/data/esp/Tag.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ object Tag {
case Value(v) => show"$v"
}

implicit def order[T: Order]: Order[Tag[T]] = Order.from {
// this is an arbitrary order used for pretty printing only for now
private[esp] implicit def order[T: Order]: Order[Tag[T]] = Order.from {
case (Name(n1), Name(n2)) => Order[T].compare(n1, n2)
case (Name(_), _) => -1
case (Open, Name(_)) => 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ private[fs2] abstract class QueryCompiler[Tag, Path] {
/** Return the constructor tag of this pattern, or `None` if it is a wildcard. */
def tagOf(pattern: Pattern): Option[Tag]

/** Compiles the `query` into an [[MFT Macro Forest Transducer]].
* The `credit` parameter defines the maximum number of optimization passes that
* are performed on the resulting MFT.
* Optimization passes allow to reduce the size of the generated MFT
* and used parameters, which improve the runtime characteristics of the
* results.
*
* If you do not want to perform any optimization, you can set this value to `0`.
*/
def compile(query: Query[Tag, Path], credit: Int = 50): MFT[NonEmptyList[Guard], Tag, Tag] = {
val mft = dsl[NonEmptyList[Guard], Tag, Tag] { implicit builder =>
val q0 = state(args = 0, initial = true)
Expand Down

0 comments on commit 70e623f

Please sign in to comment.