My question is basically how one can produce a python program from a functional programming language such as Lean or Haskell.
Personally, I am attracted to the functional programming style and some of the special capabilities (such as theorem proving). However, in practice, mature scientific computing packages are often written in python or some other imperative languages.
So I am wondering, if I write a small library (e.g. for matrix or numerical computation) in Lean (or Haskell), is there a good way to translate these into python code that use scientific libraries such as numpy and pytorch? What needs to be done conceptually?
More specifically, is this task a string-to-string translation from Lean to Python? Or, does it involve analyzing the syntax of both the source and the target languages, and translate between the syntax? Or does it require something else?
In the imperative world (more or less), I know that one can start from a language like Haxe and translate to the python target and many other targets, probably because Haxe and these target languages are quite similar. But I am not sure Lean (or other functional languages) has this kind of capabilities.
I realize that this question is a bit general. What I am interested is knowing (the principles of) how to generate python code or translate into python from a functional language like Lean. If I write a small library of matrix computation in Lean, how would I generate the corresponding python code? What is the proper way?