 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Compilable
 
-(defn compile-expr [argmap expr cb]
-  (cb argmap [:compiled expr]))
+(defn expr-access [i]
+  (access/vector-accessor i {:default-parent [nil nil]}))
+(def expr-type (expr-access 0))
+(def expr-value (expr-access 1))
+
+(defmultiple compile-expr (fn [argmap expr cb]
+                            (access/getx expr-type expr))
+  (:default 
+   [argmap expr cb]
+   (cb argmap {:type (spec/conform ::type (access/getx expr-value expr))
+               :repr expr})))
 
 (def empty-argmap {})
+
+
+(defn value? [x]
+  (and (map? x)
+       (contains? x :type)
+       (contains? x :repr)))
+
+(defn check-is-value [x]
+  (if (not (value? x))
+    (throw (RuntimeException. 
+            (str "Invalid value: " x)))))
 
 (defn compile-exprs [argmap exprs cb]
   (cond

              (str "Failed to parsed typed: " 
                   (spec/explain-str ::exprs args))))
      (compile-exprs empty-argmap parsed (fn [final-argmap final-value]
                                           [:final final-value])))))
  
  
(macroexpand '(with-typed 9 (+ 4 5)))

            [epicea.utils.access :as access] :reload-all))

(spec/def ::unspecified nil?)

(spec/def ::bool boolean?)
(spec/def ::float float?)
(spec/def ::double double?)
(spec/def ::long #(instance? java.lang.Long %))
(spec/def ::int #(or (instance? java.lang.Integer %)
                     (int? %)))

(spec/def ::primitive-value 
  (spec/or
   :bool ::bool
   :float ::float
   :double ::double
   :long ::long
   :int ::int))

(spec/def ::primitive (spec/or
                       :bool (partial = :bool)
                       :float (partial = :float)
                       :long (partial = :long)
                       :double (partial = :double)
                       :int (partial = :int)))

(spec/def ::dynamic (partial = :dynamic))

(spec/def ::number (spec/or :type #(or (= % :number)
                                       (= % :double))
                            :value number?))
(spec/def ::count number?)
(spec/def ::key keyword?)

