<commit_before>public enum Decoded<T> {
  case Success(T)
  case Failure(DecodeError)

  public var value: T? {
    switch self {
    case let .Success(value): return value
    default: return .None
    }
  }
  
  public var error: DecodeError? {
    switch self {
    case let .Failure(error): return error
    default: return .None
    }
  }
}

public extension Decoded {
  static func optional<T>(x: Decoded<T>) -> Decoded<T?> {
    switch x {
    case let .Success(value): return .Success(.Some(value))
    case .Failure(.MissingKey): return .Success(.None)
    case let .Failure(.TypeMismatch(x)): return .Failure(.TypeMismatch(x))
    case let .Failure(.Custom(x)): return .Failure(.Custom(x))
    }
  }

  static func fromOptional<T>(x: T?) -> Decoded<T> {
    switch x {
    case let .Some(value): return .Success(value)
    case .None: return .typeMismatch(".Some(\(T.self))", actual: ".None")
    }
  }
}

public extension Decoded {
  static func typeMismatch<T, U: CustomStringConvertible>(expected: String, actual: U) -> Decoded<T> {
    return .typeMismatch(expected, actual: "\(actual)")
  }

  static func typeMismatch<T>(expected: String, actual: String) -> Decoded<T> {
    return .Failure(.TypeMismatch(expected: expected, actual: actual))
  }

  static func missingKey<T>(name: String) -> Decoded<T> {
    return .Failure(.MissingKey(name))
  }

  static func customError<T>(message: String) -> Decoded<T> {
    return .Failure(.Custom(message))
  }
}<commit_msg>Remove `CustomStringConvertible` constraint on `typeMismatch` function<commit_after>public enum Decoded<T> {
  case Success(T)
  case Failure(DecodeError)

  public var value: T? {
    switch self {
    case let .Success(value): return value
    case .Failure: return .None
    }
  }
  
  public var error: DecodeError? {
    switch self {
    case .Success: return .None
    case let .Failure(error): return error
    }
  }
}

public extension Decoded {
  static func optional<T>(x: Decoded<T>) -> Decoded<T?> {
    switch x {
    case let .Success(value): return .Success(.Some(value))
    case .Failure(.MissingKey): return .Success(.None)
    case let .Failure(.TypeMismatch(x)): return .Failure(.TypeMismatch(x))
    case let .Failure(.Custom(x)): return .Failure(.Custom(x))
    }
  }

  static func fromOptional<T>(x: T?) -> Decoded<T> {
    switch x {
    case let .Some(value): return .Success(value)
    case .None: return .typeMismatch(".Some(\(T.self))", actual: ".None")
    }
  }
}

public extension Decoded {
  static func typeMismatch<T, U>(expected: String, actual: U) -> Decoded<T> {
    return .Failure(.TypeMismatch(expected: expected, actual: String(actual)))
  }

  static func missingKey<T>(name: String) -> Decoded<T> {
    return .Failure(.MissingKey(name))
  }

  static func customError<T>(message: String) -> Decoded<T> {
    return .Failure(.Custom(message))
  }
}
{'fraction_non_alphanumeric': 0.14817391304347827, 'fraction_numerical': 0.0, 'mean_word_length': 3.4178187403993854, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 40, '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': '5877573', 'n_tokens_mistral': 963, 'n_tokens_neox': 930, 'n_words': 243}