<commit_before>//  Copyright (c) 2014 <NAME>. All rights reserved.

/// Combinator conforms to Printable.
extension Combinator : Printable {
	var description: String {
		return describe(self)
	}
}


/// Pretty-prints the language represented by a combinator.
func describe<Alphabet : protocol<Hashable, Printable>>(combinator: Combinator<Alphabet>) -> String {
	let describe: Combinator<Alphabet> -> String = fixpoint("S") { recur, combinator in
		switch combinator.language {
		case .Empty:
			return "∅"
			
		case let .Null(parses):
			let joined = join(" ", map(parses) { return $0.description })
			return "ε↓{\(joined)}"
			
			
		case let .Literal(c):
			return "'\(c)'"
			
			
		case let .Alternation(left, right):
			return "(\(recur(left)) ∪ \(recur(right)))"
			
//		case let .Concatenation(first, .Repeat(second)) where first == second:
//			return "\(recur(first))+"
			
		case let .Concatenation(first, second):
			return "(\(recur(first)) ✕ \(recur(second)))"

//		case let .Intersection(left, right):
//			return "(\(recur(left)) ∩ \(recur(right)))"
			
			
		case let .Repetition(language):<commit_msg>Ostensibly print one-or-more repetitions as such.<commit_after>//  Copyright (c) 2014 <NAME>. All rights reserved.

/// Combinator conforms to Printable.
extension Combinator : Printable {
	var description: String {
		return describe(self)
	}
}


/// Pretty-prints the language represented by a combinator.
func describe<Alphabet : protocol<Hashable, Printable>>(combinator: Combinator<Alphabet>) -> String {
	let describe: Combinator<Alphabet> -> String = fixpoint("S") { recur, combinator in
		switch combinator.language {
		case .Empty:
			return "∅"
			
		case let .Null(parses):
			let joined = join(" ", map(parses) { return $0.description })
			return "ε↓{\(joined)}"
			
			
		case let .Literal(c):
			return "'\(c)'"
			
			
		case let .Alternation(left, right):
			return "(\(recur(left)) ∪ \(recur(right)))"
			
		case let .Concatenation(first, second) where first == second:
			return "\(recur(first))+"
			
		case let .Concatenation(first, second):
			return "(\(recur(first)) ✕ \(recur(second)))"

//		case let .Intersection(left, right):
//			return "(\(recur(left)) ∩ \(recur(right)))"
			
			
		case let .Repetition(language):
{'fraction_non_alphanumeric': 0.16261599646486966, 'fraction_numerical': 0.004418912947414936, 'mean_word_length': 3.528, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, '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': '3354030', 'n_tokens_mistral': 876, 'n_tokens_neox': 745, 'n_words': 202}