<commit_before>public struct Template<State> {
  let initial: Node
  let process: (State, Node) -> Node?

  public func step<S>(_ path: KeyPath<State, S>, fn: @escaping (S, Node) -> Node?) -> Template<State> {
    return Template<State>(initial: initial) { state, node in
      guard let update = self.process(state, node) else { return nil }
      return fn(state[keyPath: path], update)
    }
  }

  public func step(fn: @escaping (State, Node) -> Node?) -> Template<State> {
    return Template<State>(initial: initial) { state, node in
      guard let update = self.process(state, node) else { return nil }
      return fn(state, update)
    }
  }

  public func render(state: State) throws -> String {
    guard let node = process(state, initial) else { throw EmptyTemplateError() }
    let renderer = Renderer(.HTML5)
    return try renderer.render(node)
  }
}

extension Template {
  init(_ initial: Node) {
    self.initial = initial
    self.process = { _, node in return node }
  }
}<commit_msg>Allow template steps to be single arity<commit_after>public struct Template<State> {
  let initial: Node
  let process: (State, Node) -> Node?

  public func step<S>(_ path: KeyPath<State, S>, _ fn: @escaping (S, Node) -> Node?) -> Template<State> {
    return Template<State>(initial: initial) { state, node in
      guard let update = self.process(state, node) else { return nil }
      return fn(state[keyPath: path], update)
    }
  }

  public func step(_ fn: @escaping (State, Node) -> Node?) -> Template<State> {
    return Template<State>(initial: initial) { state, node in
      guard let update = self.process(state, node) else { return nil }
      return fn(state, update)
    }
  }

  public func step(_ fn: @escaping (Node) -> Node?) -> Template<State> {
    return Template<State>(initial: initial) { state, node in
      guard let update = self.process(state, node) else { return nil }
      return fn(update)
    }
  }

  public func render(state: State) throws -> String {
    guard let node = process(state, initial) else { throw EmptyTemplateError() }
    let renderer = Renderer(.HTML5)
    return try renderer.render(node)
  }
}

extension Template {
  init(_ initial: Node) {
    self.initial = initial
    self.process = { _, node in return node }
  }
}
{'fraction_non_alphanumeric': 0.12713722051731696, 'fraction_numerical': 0.0008768084173608067, 'mean_word_length': 3.3056603773584907, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 33, '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': '5287007', 'n_tokens_mistral': 700, 'n_tokens_neox': 682, 'n_words': 227}