<commit_before>(ns active.clojure.monad-test
  #?(:cljs (:require-macros [active.clojure.monad :refer (monadic)]
                            [cljs.test :refer (is deftest run-tests testing)]))
  (:require #?(:clj [active.clojure.monad :refer :all])
            #?(:cljs [active.clojure.monad :refer (return
                                                   free-return free-return? 
                                                   free-bind free-bind?
                                                   call-cc call-cc?
                                                   with-handler free-throw
                                                   get-state put-state!
                                                   get-env get-env-component with-env-component with-env
                                                   and-finally bind-except sequ sequ_
                                                   make-exception-value exception-value?
                                                   unknown-command unknown-command?
                                                   make-monad-command-config
                                                   combine-monad-command-configs
                                                   null-monad-command-config
                                                   run-free-reader-state-exception execute-free-reader-state-exception
                                                   run-monadic-swiss-army execute-monadic-swiss-army
                                                   monad-command-config-run-command
                                                   reify-command reify-as
                                                   put-state-component!)])
            [active.clojure.condition :as c]
            #?(:clj [clojure.test :refer :all])
            #?(:cljs [cljs.test])))

(defrecord Ask [prompt])
(defn ask [prompt] (Ask. prompt))
(defn ask? [x] (instance? Ask x))

(defrecord Tell [msg])
(defn tell [msg] (Tell. msg))
(defn tell? [x] (instance? Tell x))

(defn run
  [m mp]
  (loop [m m
         msgs []]
    (cond
     (free-return? m) [(:val m) msgs]

     (free-bind? m)
     (let [m1 (:monad m)
           cont (:cont m)]
       (cond
        (free-return? m1) (recur (cont (:val m1)) msgs)

        (free-bind? m1) (c/assertion-violation `run "nested bind; should not happen" m m1)

        (ask? m1)
        (if-let [ans (get mp (:prompt m1))]
          (recur (cont ans) msgs)<commit_msg>Unbreak tests.<commit_after>(ns active.clojure.monad-test
  #?(:cljs (:require-macros [active.clojure.monad :refer (monadic)]
                            [cljs.test :refer (is deftest run-tests testing)]))
  (:require #?(:clj [active.clojure.monad :refer :all])
            #?(:cljs [active.clojure.monad :refer (return
                                                   free-return free-return? 
                                                   free-bind free-bind?
                                                   call-cc call-cc?
                                                   with-handler free-throw
                                                   get-state put-state!
                                                   get-env get-env-component with-env-component with-env
                                                   and-finally bind-except sequ sequ_
                                                   make-exception-value exception-value?
                                                   unknown-command unknown-command?
                                                   make-monad-command-config
                                                   combine-monad-command-configs
                                                   null-monad-command-config
                                                   run-free-reader-state-exception execute-free-reader-state-exception
                                                   run-monadic-swiss-army execute-monadic-swiss-army
                                                   monad-command-config-run-command
                                                   reify-command reify-as
                                                   put-state-component!
                                                   update-state-component!)])
            [active.clojure.condition :as c]
            #?(:clj [clojure.test :refer :all])
            #?(:cljs [cljs.test])))

(defrecord Ask [prompt])
(defn ask [prompt] (Ask. prompt))
(defn ask? [x] (instance? Ask x))

(defrecord Tell [msg])
(defn tell [msg] (Tell. msg))
(defn tell? [x] (instance? Tell x))

(defn run
  [m mp]
  (loop [m m
         msgs []]
    (cond
     (free-return? m) [(:val m) msgs]

     (free-bind? m)
     (let [m1 (:monad m)
           cont (:cont m)]
       (cond
        (free-return? m1) (recur (cont (:val m1)) msgs)

        (free-bind? m1) (c/assertion-violation `run "nested bind; should not happen" m m1)

        (ask? m1)
        (if-let [ans (get mp (:prompt m1))]
          (recur (cont ans) msgs)
{'fraction_non_alphanumeric': 0.10019880715705766, 'fraction_numerical': 0.002783300198807157, 'mean_word_length': 0.93574451712197, 'pattern_counts': {'":': 0, '<': 3, '<?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': 70, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1991647', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1180, 'n_words': 293}