 
 
 
+(defn expr-to-typed-value [expr]
+  (spec/conform ::type expr))
+
 ;;; OBS: Vi måste räkna referenserna till varje uttryck som vi kompilerar.
 ;;; Kanske i argmap? Om antalet referenser överskriver 1 binder vi uttrycket
 ;;; till en variabel.

                   :header (spec/? ::sized-type)
                   :data ::sized-type))

(spec/def ::type (spec/or :primitive ::primitive
                          :primitive-value ::primitive-value
                          :sized-type ::sized-type
                          :array ::array
                          :dynamic ::dynamic))



;;;; Compute the size of a ::sized-type
(defmultiple compute-size get-pair-tag
  (:default [x] 1)
  (:vec [x] (let [value (get-pair-value x)]
              (size-mul (:count value) (compute-size (:type value)))))
  (:tagged [x] (compute-size (:data (get-pair-value x))))
  (:union [x] (reduce size-max (map compute-size (-> x get-pair-value :alts))))
  (:record [x] (reduce size-add (map (comp compute-size :value) 
