Closed colin-mcd closed 2 years ago
Sorry I missed this earlier. Theoretically, I can't think of a problem with this. Practically, would you be able to make the copies only when they are needed?
Yeah, I don't think that would be too hard. The only consideration I can think of is if you had the terms add n n
and add (add n n) n
, would we want to make the three values like let (n1, n23) = copy n in let (n2, n3) = copy n23 in add (add n1 n2) n3
, or create a custom copy
function for each number of copies (i.e. copy2 : Nat -> (Nat * Nat)
and copy3 : Nat -> (Nat * Nat * Nat)
)?
Let
Given these, one might wish to define a
mult
function:However, given that—IIUC—we currently restrict local vars with recursive datatypes from being used multiple times (just like we do with functions),
add m (mult m n)'
raises an error for its two uses ofm
. But if you first definethen you can define
mult
asComputing a
copy
function behind-the-scenes would be pretty easy—more or less just make a naive fixpoint, but pair all values—so why don't we do this automatically and allowadd m (mult m n')
?