<commit_before>import React from 'react'
import {
  createTypes,
  createUpdate,
  component,
  caseOf,
  compose,
} from '../src/index'

import OrdinaryCounter from './OrdinaryCounter'
import CycleCounter from './CycleCounter'
import Counter, * as CM from './Counter'
// CM stand for Counter module

const Msg = createTypes('TOP', 'MIDDLE', 'BOTTOM')

export const init = (top, middle, bottom) => ({
  topCounter: CM.init(top),
  middleCounter: CM.init(middle),
  bottomCounter: CM.init(bottom)
})

// TODO consider use immutable js?
export const update = createUpdate({
  [Msg.TOP]: (msg, model) => ({
    ...model, topCounter: CM.update(msg, model.topCounter)
  }),
  [Msg.MIDDLE]: (msg, model) => ({
    ...model, middleCounter: CM.update(msg, model.middleCounter)
  }),
  [Msg.BOTTOM]: (msg, model) => ({
    ...model, bottomCounter: CM.update(msg, model.bottomCounter)
  })
})

export default component('App', ({link, event}, props) => {
  return props.get('model').map(({topCounter, middleCounter, bottomCounter}) => (
    <div>
      <div>
        {link.map(Msg.TOP, <Counter count={topCounter} />)}
      </div>
      <div>
        {link.map(evt => {
          return caseOf({
            onIncClick: compose(Msg.MIDDLE, CM.Msg.INC),
            _otherwise: Msg.MIDDLE
          })(evt)
        }, <CycleCounter count={middleCounter} />)}
      </div>
      <div>
        <OrdinaryCounter
          count={bottomCounter}
          onIncClick={event(compose(Msg.BOTTOM, CM.Msg.INC))}
          onDecClick={event(compose(Msg.BOTTOM, CM.Msg.DEC))}
        />
      </div>
    </div>
  ))
})
<commit_msg>update example<commit_after>import React from 'react'
import {
  createTypes,
  createUpdate,
  component,
  caseOf,
  compose,
} from '../src/index'

import OrdinaryCounter from './OrdinaryCounter'
import CycleCounter from './CycleCounter'
import Counter, * as CM from './Counter'
// CM stand for Counter module

const Msg = createTypes('TOP', 'MIDDLE', 'BOTTOM')

export const init = (top, middle, bottom) => ({
  topCounter: CM.init(top),
  middleCounter: CM.init(middle),
  bottomCounter: CM.init(bottom)
})

// TODO consider use immutable js?
export const update = createUpdate({
  [Msg.TOP]: (msg, model) => ({
    ...model, topCounter: CM.update(msg, model.topCounter)
  }),
  [Msg.MIDDLE]: (msg, model) => ({
    ...model, middleCounter: CM.update(msg, model.middleCounter)
  }),
  [Msg.BOTTOM]: (msg, model) => ({
    ...model, bottomCounter: CM.update(msg, model.bottomCounter)
  })
})

export default component('App', ({link, event}, props) => {
  return props.get('model').map(({topCounter, middleCounter, bottomCounter}) => (
    <div>
      <div>
        {link.map(Msg.TOP, <Counter count={topCounter} />)}
      </div>
      <div>
        {link.map(caseOf({
          onIncClick: compose(Msg.MIDDLE, CM.Msg.INC),
          _otherwise: Msg.MIDDLE
        }), <CycleCounter count={middleCounter} />)}
      </div>
      <div>
        <OrdinaryCounter
          count={bottomCounter}
          onIncClick={event(compose(Msg.BOTTOM, CM.Msg.INC))}
          onDecClick={event(compose(Msg.BOTTOM, CM.Msg.DEC))}
        />
      </div>
    </div>
  ))
})

{'fraction_non_alphanumeric': 0.17150063051702397, 'fraction_numerical': 0.0, 'mean_word_length': 2.9712140175219024, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 38, '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': '1290136', 'n_tokens_mistral': 1074, 'n_tokens_neox': 1056, 'n_words': 230}