; Iter 14b design exhibit — Decision 6 form (A).
; This file is NOT yet parseable by `ail`. The parser lands in
; Iter 14c. Hash-equivalence with `box.ail.json` is the round-trip
; test that gates that iter.

(module box

  (data Box (vars a)
    (doc "A unary box around a polymorphic value.")
    (ctor MkBox a))

  (fn unbox
    (doc "Polymorphic projection out of a Box.")
    (type
      (forall (vars a)
        (fn-type
          (params (own (con Box a)))
          (ret (own a)))))
    (params b)
    (body
      (match b
        (case (pat-ctor MkBox x)
          x))))

  (fn main
    (doc "Round-trip 42 through MkBox + unbox.")
    (type
      (fn-type
        (params)
        (ret (own (con Unit)))
        (effects IO)))
    (params)
    (body
      (app print
        (app unbox
          (term-ctor Box MkBox 42))))))
