<commit_before>// Copyright   :  (C) 2012 <NAME>, <NAME>,
//                         <NAME>, <NAME>
// License     :  BSD-style (see the file LICENSE)

package com.clarifi.machines

import scalaz._

/**
 * You can construct a `Plan` and then `compile` it to a `Machine`.
 * A `Plan[K, O, A]` is a specification for a pure `Machine` that reads
 * inputs selected by `K` and writes values of type `O`. The `Plan` has
 * intermediate results of type `A` which are placeholders for further plans.
 */
sealed trait Plan[K, +O, +A] {

  /**
   * Substitute into the variables in this `Plan`.
   */
  def flatMap[L >: K, P >: O, B](f: A => Plan[L, P, B]): Plan[L, P, B]

  /**
   * If the current `Plan` fails, try the plan `p`.
   */
  def orElse[L >: K, P >: O, B >: A](p: => Plan[L, P, B]): Plan[L, P, B]

  /**
   * Reassign the variables in this `Plan`.
   */
  def map[B](f: A => B): Plan[K, O, B] = flatMap { x => Return(f(x)) }

  /** Transform the inputs of the resulting machine. */
  def inmap[L](p: K => L): Plan[L, O, A] = this match {
    case r@Return(_)    => r
    case Stop           => Stop<commit_msg>Made Plan covariant in K again<commit_after>// Copyright   :  (C) 2012 <NAME>, <NAME>,
//                         <NAME>, <NAME>
// License     :  BSD-style (see the file LICENSE)

package com.clarifi.machines

import scalaz._

/**
 * You can construct a `Plan` and then `compile` it to a `Machine`.
 * A `Plan[K, O, A]` is a specification for a pure `Machine` that reads
 * inputs selected by `K` and writes values of type `O`. The `Plan` has
 * intermediate results of type `A` which are placeholders for further plans.
 */
sealed trait Plan[+K, +O, +A] {

  /**
   * Substitute into the variables in this `Plan`.
   */
  def flatMap[L >: K, P >: O, B](f: A => Plan[L, P, B]): Plan[L, P, B]

  /**
   * If the current `Plan` fails, try the plan `p`.
   */
  def orElse[L >: K, P >: O, B >: A](p: => Plan[L, P, B]): Plan[L, P, B]

  /**
   * Reassign the variables in this `Plan`.
   */
  def map[B](f: A => B): Plan[K, O, B] = flatMap { x => Return(f(x)) }

  /** Transform the inputs of the resulting machine. */
  def inmap[L](p: K => L): Plan[L, O, A] = this match {
    case r@Return(_)    => r
    case Stop           => Stop
{'fraction_non_alphanumeric': 0.1740872662511131, 'fraction_numerical': 0.003561887800534283, 'mean_word_length': 2.5219435736677114, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4661322', 'n_tokens_mistral': 830, 'n_tokens_neox': 794, 'n_words': 308}