pact
pact copied to clipboard
Inability to take first-class table value as argument
@slpopejoy
With the following setup, and the module typechecking:
(begin-tx)
(env-data { "kadmin": { "keys": ["admin"], "pred": "=" } })
(env-keys ["admin"])
(define-keyset 'kadmin)
(module m1 'kadmin
(defschema s i:integer)
(deftable tab:{s})
(defun consume (t:table)
t)
(defun produce:table ()
tab)
)
(create-table tab)
(commit-tx)
(use m1)
(typecheck 'm1)
;"Typecheck m1: success"
We can return a first-class table from a function:
(produce)
;(TTable m1.tab:(TSchema m1.s [i:integer] Meta {_mDocs = Nothing, _mModel = []}) Meta {_mDocs = Nothing, _mModel = []})
But we can't pass a first-class table to a function that consumes one:
(consume (produce))
;tests/pact/table.repl:29:14: Type error: expected table, found table:(TSchema m1.s [i:integer] Meta {_mDocs = Nothing, _mModel = []})
Related: #540