<commit_before>import * as R from 'ramda'
import fl from 'fantasy-land'

const isNotSameLength = (types, tuple) => types.length !== tuple.length
const commaSeperate = R.join(', ')
const typeNamesString = R.compose(commaSeperate, R.pluck('name'))
const tupleToString = R.compose(commaSeperate, R.map(R.toString))

const tupleTypeValueString = (types, tuple) => {
  return `\nTypes: (${typeNamesString(types)})\nValues: (${tupleToString(tuple)})`
}

const throwTupleNilError = (types, tuple) => {
  throw new ReferenceError(`Cannot have null or undefined values${tupleTypeValueString(types, tuple)}`)
}

const throwTupleArityError = (length, tuple) => {
  throw new TypeError(`Tuple arg doesn\'t match prototype length of ${length}`)
}

const throwTupleTypeError = (types, tuple) => {
  throw new TypeError(`Tuple types do not match${tupleTypeValueString(types, tuple)}`)
}

const tupleTypesMatch = (types, tuple) => types.every(((type, i) => R.is(type, tuple[i])))

const Tuple = function(...types) {
  const createTuple = function (...tuple) {
    const map = R.compose(R.apply(createTuple), R.map(R.__, tuple))
    const reduce = R.reduce(R.__, R.__, tuple)
    const equals = (compTuple) => {
      const [...thisTupleItems] = tuple,
            [...compareItems] = compTuple

      return R.equals(thisTupleItems, compareItems)
    }

    if (R.any(R.isNil, tuple))
      throwTupleNilError(tuple)

    if (isNotSameLength(types, tuple))
      throwTupleArityError(types.length)

    if (!tupleTypesMatch(types, tuple))
      throwTupleTypeError(types, tuple)

    return Object.freeze({
      [Symbol.iterator]() {
        const iterator = {
          index: 0,
          next() {
            const value = tuple[iterator.index]

            return {value, done: iterator.index++ === tuple.length}
          }
        }

        return iterator
      },

      map,
      [fl.map]: map,

      reduce,
      [fl.reduce]: reduce,

      get length() {
        return tuple.length
      },

      equals,
      [fl.equals]: equals,


      toString() {
        return `(${tupleToString(tuple)})`
      }
    })
  }

  return createTuple
}

<commit_msg>Fix export<commit_after>import * as R from 'ramda'
import fl from 'fantasy-land'

const isNotSameLength = (types, tuple) => types.length !== tuple.length
const commaSeperate = R.join(', ')
const typeNamesString = R.compose(commaSeperate, R.pluck('name'))
const tupleToString = R.compose(commaSeperate, R.map(R.toString))

const tupleTypeValueString = (types, tuple) => {
  return `\nTypes: (${typeNamesString(types)})\nValues: (${tupleToString(tuple)})`
}

const throwTupleNilError = (types, tuple) => {
  throw new ReferenceError(`Cannot have null or undefined values${tupleTypeValueString(types, tuple)}`)
}

const throwTupleArityError = (length, tuple) => {
  throw new TypeError(`Tuple arg doesn\'t match prototype length of ${length}`)
}

const throwTupleTypeError = (types, tuple) => {
  throw new TypeError(`Tuple types do not match${tupleTypeValueString(types, tuple)}`)
}

const tupleTypesMatch = (types, tuple) => types.every(((type, i) => R.is(type, tuple[i])))

export const Tuple = function(...types) {
  const createTuple = function (...tuple) {
    const map = R.compose(R.apply(createTuple), R.map(R.__, tuple))
    const reduce = R.reduce(R.__, R.__, tuple)
    const equals = (compTuple) => {
      const [...thisTupleItems] = tuple,
            [...compareItems] = compTuple

      return R.equals(thisTupleItems, compareItems)
    }

    if (R.any(R.isNil, tuple))
      throwTupleNilError(tuple)

    if (isNotSameLength(types, tuple))
      throwTupleArityError(types.length)

    if (!tupleTypesMatch(types, tuple))
      throwTupleTypeError(types, tuple)

    return Object.freeze({
      [Symbol.iterator]() {
        const iterator = {
          index: 0,
          next() {
            const value = tuple[iterator.index]

            return {value, done: iterator.index++ === tuple.length}
          }
        }

        return iterator
      },

      map,
      [fl.map]: map,

      reduce,
      [fl.reduce]: reduce,

      get length() {
        return tuple.length
      },

      equals,
      [fl.equals]: equals,


      toString() {
        return `(${tupleToString(tuple)})`
      }
    })
  }

  return createTuple
}


{'fraction_non_alphanumeric': 0.1437847866419295, 'fraction_numerical': 0.00046382189239332097, 'mean_word_length': 2.9898242368177614, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '597825', 'n_tokens_mistral': 1355, 'n_tokens_neox': 1313, 'n_words': 318}