Hi, I have not really tried roc yet and I hope this is the right place for my question.
I wanted to ask if it is possible to ouput one variable's type as data
TypeOf = / x -> typeOfX
TypeOf "a string" //output Str
I tried to look for the answer in vain. It feels that it would belong to the dark meta programming side of the force that roc does not want to mingle with; but I wanted to be sure of that.
you can do a limited form of this with the Encode ability, but by design runtime type introspection isn't part of the language
I'm curious if there's a specific program (or feature) you wanted to build using that though!
Thanks for the reply.
It is just an idea of a toy project.
Building "function-like" nodes and seeing if I can generate a graph that acts like a big function , or a sort of neural network.
Linking (more or less randomly) nodes by checking input/output types.
I could rewrite by hand an equivalent of the type signature into a struct for each function but I would rather not...
I am not sure if it is a smart idea or if it already exists or if that meta step could be accomplished only at compile time or if it has to be runtime.
Last updated: Jul 06 2025 at 12:14 UTC