Yeah, I had this type constraint system for doing that kind of thing, so I can load a file at compile time to get the type structure and then compile/evaluate to process data in the file or files. Same thing for network connections between communicating processes (type constraints at compile-time decide a protocol, machine code at run-time assumes that protocol).
I wrote Empirical specifically for the use case of wanting to read a CSV file while inferring the type at compile time. Basically, a ton of compile-time function evaluation mixed with type providers.