             :say "Now use `ls` again to list the files in the `bin` directory."
             :then {:allow ["ls"]
                    :wait-event {:type :new-line
-                                :then (eq {:type :new-line :line "ls"} {})}
+                                :then (if-line "ls" {})}
                    :then {:allow []
                           :say "Hey look! The `ls` and `cd` commands are actually just files in `bin`!"
                           :then {:allow ["clear"]
                                  :say "Do you see the `clear` command? What do you think it does?"
                                  :wait-event {:type :new-line
-                                              :then (eq {:type :new-line :line "clear"} {})}
+                                              :then (if-line "clear" {})}
                                  :then {:goto :page-6}}}}}
    :page-6 {:say "Cool. That's all for now. I'm still a work in progress!"
             :wait-event {:type :key-down

(ns mash-commander.nix.story)

(defn- eq [want then]
  (fn [got _] (when (= want got) then)))

(def pages
  {;; Debugging
   :page-0 {:when-events [{:type :new-line
                           :then (eq {:type :new-line :line "ls"}
                                     {:say "saw `ls` command"})
                           :recur true}]}
   ;; Learning `ls` and typing commands.
   :page-1 {:allow []
            :say "Hi, I'm Nix."

                   :then {
                          :allow ["ls"]
                          :wait-event {:type :new-line
                                       :then (if-line "ls" {:goto :page-2})}}}}
   :page-2 {:allow []
            :say "Good job! The results of your command are shown underneath in the grey box."
            :goto :page-3}
