Open mark-koch opened 2 weeks ago
Also see https://github.com/CQCL/guppylang/pull/618 for usage of this feature in the Guppy context
This ties in nicely with the plans for constants in hugr-model
. My current idea is to have an operation that produces a runtime value from a compile time value (i.e. a TypeArg
): see https://github.com/CQCL/hugr/discussions/1425#discussioncomment-11112848. In the body of a function, we can refer to the static parameters of the function as variables by their index. Therefore we can pass the static parameter as an argument to the constant producing node.
Functions that are generic over bounded nats might want to use their static arguments as runtime values. For example, given an array of generic length
n
, we might want to write a loop that runsn
times and does some indexing into the array. I think it would be worth to give up some parametricity to allow that.I'd suggest to add a new op (to the prelude extension?) that loads these static arguments into a
usize
(?) runtime value. This op would be parametrised over the de Bruijn index of the argument it should load. During monomorphisation, we could then easily lower them to concrete constant values.We could also consider extending this to
Tuple
or evenList
params?