<commit_before>import Foundation

/**
 Semigroup
 */
extension Array : Semigroup {
  func op (xs: Array<T>) -> Array<T> {
    return self + xs
  }
}

/**
 Monoid
 */
extension Array : Monoid {
  static func mzero() -> Array<T> {
    return []
  }
}

/**
 Partial application of +
 */
prefix operator + {}
prefix func + <A> (xs: [A]) -> [A] -> [A] {
  return {$0 + xs}
}

postfix operator + {}
postfix func + <A> (xs: [A]) -> [A] -> [A] {
  return {xs + $0}
}

/**
 Concat list of lists
 */
func concat <A> (xss: [[A]]) -> [A] {
  return mconcat(xss)
}

func flatten <A> (xss: [[A]]) -> [A] {
  return concat(xss)
}

/**
 Functor
 */
func fmap <A, B> (f: A -> B) -> [A] -> [B] {
  return {xs in
    return xs.map(f)
  }
}

/**
 Monad
 */

func bind <A, B> (xs: [A], f: A -> [B]) -> [B] {
  return (concat * fmap(f))(xs)
}

infix operator >>= {associativity left}
func >>= <A, B> (xs: [A], f: A -> [B]) -> [B] {
  return bind(xs, f)
}

postfix operator >>= {}
postfix func >>= <A, B> (xs: [A]) -> (A -> [B]) -> [B] {
  return {f in
    return bind(xs, f)
  }
}

prefix operator >>= {}
prefix func >>= <A, B> (f: A -> [B]) -> [A] -> [B] {
  return {xs in
    return bind(xs, f)<commit_msg>Added the infix version of fmap to array. wish we could do <$>.<commit_after>import Foundation

/**
 Semigroup
 */
extension Array : Semigroup {
  func op (xs: Array<T>) -> Array<T> {
    return self + xs
  }
}

/**
 Monoid
 */
extension Array : Monoid {
  static func mzero() -> Array<T> {
    return []
  }
}

/**
 Partial application of +
 */
prefix operator + {}
prefix func + <A> (xs: [A]) -> [A] -> [A] {
  return {$0 + xs}
}

postfix operator + {}
postfix func + <A> (xs: [A]) -> [A] -> [A] {
  return {xs + $0}
}

/**
 Concat list of lists
 */
func concat <A> (xss: [[A]]) -> [A] {
  return mconcat(xss)
}

func flatten <A> (xss: [[A]]) -> [A] {
  return concat(xss)
}

/**
 Functor
 */
func fmap <A, B> (f: A -> B) -> [A] -> [B] {
  return {xs in
    return xs.map(f)
  }
}

infix operator <^> {associativity left}
func <^> <A, B> (f: A -> B, xs: [A]) -> [B] {
  return fmap(f)(xs)
}

/**
 Monad
 */

func bind <A, B> (xs: [A], f: A -> [B]) -> [B] {
  return (concat * fmap(f))(xs)
}

infix operator >>= {associativity left}
func >>= <A, B> (xs: [A], f: A -> [B]) -> [B] {
  return bind(xs, f)
}

postfix operator >>= {}
postfix func >>= <A, B> (xs: [A]) -> (A -> [B]) -> [B] {
  return {f in
    return bind(xs, f)
  }
}

prefix operator >>= {}
prefix func >>= <A, B> (f: A -> [B]) -> [A] -> [B] {
  return {xs in
    return bind(xs, f)
{'fraction_non_alphanumeric': 0.245260663507109, 'fraction_numerical': 0.001579778830963665, 'mean_word_length': 2.5327754532775453, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 99, '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': '3266247', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1092, 'n_words': 324}