A: 

You should have a look at the intermediate representations for GCC and LLVM. Both support multiple language front-ends (including Fortran and C). They may not be the simplest or the best, but they are both production-quality.

Chris Conway
+1  A: 

Haskell has decent LLVM bindings thanks to Bryan O'Sullivan and Lennart Augustsson, you might want to look there. However, that may be a bit lower level than you are looking for. That said, it has the benefits that it is readily generated out of llvm-gcc and by a bunch of other platforms.

If you are looking at doing forward-mode AD that might be sufficient -- just shadow each of the floating point arguments with a derivative. You might have to fight a bit with data structures and calling conventions, but it doesn't seem insurmountable. On the other hand, doing reverse-mode AD may be tricky with just that much information, because its basically a whole program transformation.

As for anything higher level, assuming you'd want to work on source statements and perform a source translation, I am not aware of a good existing cross-language imperative language IR in use in the Haskell community, so you may have to roll your own.

Edward Kmett
A: 

LLVM, gcc, and GHC's internal Cmm language are all very low-level to intertranslate between Fortran and C. I'd look at George Necula's CIL (C Intermediate Language) which was part of the C-Cured project at Berkeley. I'd also look at the C AST Kit done at Bell Labs in the late 1990s by Nevin Heintze and others. They're both written in versions of ML, so doing something similar in Haskell should not be difficult.

The old MIT Macsyma papers should be required reading :-)

Norman Ramsey
thanks where can I find the mentioned papers?
Cetin Sert
A: 

There's already a tool called Language.C (website, blog, hackage) written in Haskell that's similar to CIL, which is written in OCaml. I think it's less mature than CIL though.

Wei Hu