<commit_before>module Propr

  class State
    attr_reader :state
    attr_reader :value

    def initialize(state, value)
      @state, @value = state, value
    end
  end

  class << State

    # Evaluators
    #############################################

    def run(computation, state)
      computation.call(state)
    end

    def eval(computation, state)
      computation.call(state).value
    end

    def exec(computation, state)
      computation.call(state).state
    end

    # Combinators
    #############################################

    def unit(value)
      lambda do |state|
        new(state, value)
      end
    end

    def bind(f, &g)
      lambda do |state|
        wrapper = f.call(state)
        g.call(wrapper.value).call(wrapper.state)
      end
    end

    # Actions
    #############################################

    def put(n)
      lambda do |state|
        new(n, nil)
      end
    end

    def get
      lambda do |state|
        new(state, state)
      end
    end

  end
end
<commit_msg>Remove ambiguity about 'state' name<commit_after>module Propr

  class State
  end

  class << State

    # Evaluators
    #############################################

    def run(computation, state)
      computation.call(state)
    end

    def eval(computation, state)
      computation.call(state)[:value]
    end

    def exec(computation, state)
      computation.call(state)[:state]
    end

    # Combinators
    #############################################

    def unit(value)
      lambda do |state|
        Hash[state: state, value: value]
      end
    end

    def bind(f, &g)
      lambda do |state|
        result = f.call(state)
        g.call(result[:value]).call(result[:state])
      end
    end

    # Actions
    #############################################

    def put(n)
      lambda do |state|
        Hash[state: n, value: nil]
      end
    end

    def get
      lambda do |state|
        Hash[state: state, value: state]
      end
    end

  end
end

{'fraction_non_alphanumeric': 0.21089108910891088, 'fraction_numerical': 0.0, 'mean_word_length': 2.243980738362761, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '3594070', 'n_tokens_mistral': 612, 'n_tokens_neox': 575, 'n_words': 152}