
(deftype Error [val state]
  Stringable
  (string-list [_] 
    (list "(Error " (str val) ")")))

(deftype new-se [invoke-fn]
  (assert (instance? Fn invoke-fn))

  Stringable
  (string-list [x]
    (comp (list "<new-se ")
          (string-list (.invoke-fn x))
          (list ">")))

  Function
  (invoke [ev s]
    (invoke-fn s))

  Container
  (map [ev f]
    (new-se (fn [s]
              (let [x (invoke-fn s)]
                (either (instance? Error x)
                        (let [[v new-s] x]
                          (either (= (symbol "v") 'v)
                                  (abort))
                          [(f v) new-s]))))))

  (wrap [_ v]
    (new-se (fn [s]
              [v s])))
 
  (flat-map [ev f]
    (new-se (fn [s]
              (let [x (invoke-fn s)]
                (either (instance? Error x)
                        (let [[v new-s] x]
                          ((f v) new-s))))))))

(main [_]
  (print-err ((map (new-se (fn [s]
                              [99 s]))
                    (fn [y]
                      'x
                      ))
              'state)))

Add test for inline symbol literals
Add test for inline symbol literals
