<commit_before>part of dartz;

enum Ordering {
  LT,
  EQ,
  GT
}

abstract class Order<A> extends Eq<A> {
  Ordering order(A a1, A a2);

  bool eq(A a1, A a2) => order(a1, a2) == Ordering.EQ;

  bool lt(A a1, A a2) => order(a1, a2) == Ordering.LT;

  bool lte(A a1, A a2) => order(a1, a2) != Ordering.GT;

  bool gt(A a1, A a2) => order(a1, a2) == Ordering.GT;

  bool gte(A a1, A a2) => order(a1, a2) != Ordering.LT;

  A min(A a1, A a2) => lt(a1, a2) ? a1 : a2;

  Semigroup<A> minSi() => new MinSemigroup(this);

  A max(A a1, A a2) => gte(a1, a2) ? a1 : a2;

  Semigroup<A> maxSi() => new MaxSemigroup(this);

  Tuple2<A, A> sort(A a1, A a2) => lte(a1, a2) ? tuple2(a1, a2) : tuple2(a2, a1);

  Order<A> reverse() => new _AnonymousOrder(flip(order));

  Order<A> andThen(Order<A> secondary) => new _AnonymousOrder((a1, a2) {
    final Ordering primary = order(a1, a2);
    return (primary == Ordering.EQ) ? secondary.order(a1, a2) : primary;
  });
}

typedef Ordering OrderF<A>(A a1, A a2);
class _AnonymousOrder<A> extends Order<A> {
  final OrderF<A> _f;
  _AnonymousOrder(this._f);
  @override Ordering order(A a1, A a2) => _f(a1, a2);
}

Order<A> order<A>(OrderF<A> f) => new _AnonymousOrder(f);
Order<A> orderBy<A, B>(Order<B> o, B by(A a)) => new _AnonymousOrder((A a1, A a2) => o.order(by(a1), by(a2)));

class ComparableOrder<A extends Comparable> extends Order<A> {
  @override Ordering order(A a1, A a2) {
    final c = a1.compareTo(a2);
    return c < 0 ? Ordering.LT : (c > 0 ? Ordering.GT : Ordering.EQ);
  }
}

final Order _comparableOrder = new ComparableOrder();
Order<A> comparableOrder<A extends Comparable>() => new ComparableOrder();
<commit_msg>ComparableOrder<A> instances are equal for equal A (https://github.com/spebbe/dartz/issues/6)<commit_after>part of dartz;

enum Ordering {
  LT,
  EQ,
  GT
}

abstract class Order<A> extends Eq<A> {
  Ordering order(A a1, A a2);

  bool eq(A a1, A a2) => order(a1, a2) == Ordering.EQ;

  bool lt(A a1, A a2) => order(a1, a2) == Ordering.LT;

  bool lte(A a1, A a2) => order(a1, a2) != Ordering.GT;

  bool gt(A a1, A a2) => order(a1, a2) == Ordering.GT;

  bool gte(A a1, A a2) => order(a1, a2) != Ordering.LT;

  A min(A a1, A a2) => lt(a1, a2) ? a1 : a2;

  Semigroup<A> minSi() => new MinSemigroup(this);

  A max(A a1, A a2) => gte(a1, a2) ? a1 : a2;

  Semigroup<A> maxSi() => new MaxSemigroup(this);

  Tuple2<A, A> sort(A a1, A a2) => lte(a1, a2) ? tuple2(a1, a2) : tuple2(a2, a1);

  Order<A> reverse() => new _AnonymousOrder(flip(order));

  Order<A> andThen(Order<A> secondary) => new _AnonymousOrder((a1, a2) {
    final Ordering primary = order(a1, a2);
    return (primary == Ordering.EQ) ? secondary.order(a1, a2) : primary;
  });
}

typedef Ordering OrderF<A>(A a1, A a2);
class _AnonymousOrder<A> extends Order<A> {
  final OrderF<A> _f;
  _AnonymousOrder(this._f);
  @override Ordering order(A a1, A a2) => _f(a1, a2);
}

Order<A> order<A>(OrderF<A> f) => new _AnonymousOrder(f);
Order<A> orderBy<A, B>(Order<B> o, B by(A a)) => new _AnonymousOrder((A a1, A a2) => o.order(by(a1), by(a2)));

class ComparableOrder<A extends Comparable> extends Order<A> {
  @override Ordering order(A a1, A a2) {
    final c = a1.compareTo(a2);
    return c < 0 ? Ordering.LT : (c > 0 ? Ordering.GT : Ordering.EQ);
  }

  @override bool operator ==(Object other) => identical(this, other) || other is ComparableOrder && runtimeType == other.runtimeType;

  @override int get hashCode => 0;
}

final Order _comparableOrder = new ComparableOrder();
Order<A> comparableOrder<A extends Comparable>() => new ComparableOrder();

{'fraction_non_alphanumeric': 0.1753409407180629, 'fraction_numerical': 0.03785137767881993, 'mean_word_length': 4.033613445378151, 'pattern_counts': {'":': 0, '<': 50, '<?xml version=': 0, '>': 86, 'https://': 1, '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': '5130051', 'n_tokens_mistral': 1568, 'n_tokens_neox': 1496, 'n_words': 408}