<commit_before>// Copyright (c) 2012, Google Inc. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

// Author: <NAME> (<EMAIL>)

part of persistent;

class Option<T> {
  static final _none = new Option._internal(false, null);

  final T _value;
  final bool isDefined;

  Option._internal(this.isDefined, this._value);

  factory Option.none() => _none;

  factory Option.some(T value) => new Option._internal(true, value);

  factory Option.fromNullable(T nullableValue) =>
      nullableValue == null ? _none : new Option.some(nullableValue);

  T get value {
    if (isDefined) return _value;
    throw new StateError('Option.none() has no value');
  }

  T get asNullable => isDefined ? _value : null;

  T orElse(T defaultValue) => isDefined ? _value : defaultValue;

  T orElseCompute(T defaultValue()) => isDefined ? _value : defaultValue();

  /// forall U, Option<U> map(U f(T value))
  Option map(f(T value)) =>
      isDefined ? new Option.some(f(_value)) : this;

  /// forall U, Option<U> map(Option<U> f(T value))
  Option expand(Option f(T value)) =>
      isDefined ? f(_value) : this;

  /// Precondition: this is Option<Option>
  Option get flattened {
    assert(isDefined ? _value is Option : true);
    return orElse(_none);
  }

  bool operator ==(Option<T> other) =>
      (isDefined && other.isDefined && _value == other._value)
   || (!isDefined && !other.isDefined);

  int get hashCode => asNullable.hashCode;

  String toString() =>
      isDefined ? "Option.some($_value)" : "Option.none()";
}<commit_msg>better dartdoc<commit_after>// Copyright (c) 2012, Google Inc. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

// Author: <NAME> (<EMAIL>)

part of persistent;

class Option<T> {
  static final _none = new Option._internal(false, null);

  final T _value;
  final bool isDefined;

  Option._internal(this.isDefined, this._value);

  factory Option.none() => _none;

  factory Option.some(T value) => new Option._internal(true, value);

  factory Option.fromNullable(T nullableValue) =>
      nullableValue == null ? _none : new Option.some(nullableValue);

  T get value {
    if (isDefined) return _value;
    throw new StateError('Option.none() has no value');
  }

  T get asNullable => isDefined ? _value : null;

  T orElse(T defaultValue) => isDefined ? _value : defaultValue;

  T orElseCompute(T defaultValue()) => isDefined ? _value : defaultValue();

  /// [:forall U, Option<U> map(U f(T value)):]
  Option map(f(T value)) =>
      isDefined ? new Option.some(f(_value)) : this;

  /// [:forall U, Option<U> map(Option<U> f(T value)):]
  Option expand(Option f(T value)) =>
      isDefined ? f(_value) : this;

  /// Precondition: [:this is Option<Option>:]
  Option get flattened {
    assert(isDefined ? _value is Option : true);
    return orElse(_none);
  }

  bool operator ==(Option<T> other) =>
      (isDefined && other.isDefined && _value == other._value)
   || (!isDefined && !other.isDefined);

  int get hashCode => asNullable.hashCode;

  String toString() =>
      isDefined ? "Option.some($_value)" : "Option.none()";
}
{'fraction_non_alphanumeric': 0.14068794546017974, 'fraction_numerical': 0.002479082739386427, 'mean_word_length': 3.6246418338108883, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 41, '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': '5282533', 'n_tokens_mistral': 1074, 'n_tokens_neox': 1026, 'n_words': 315}