Wow! This really blew me away: http://eigenclass.org/hiki/addressing-orm-problem-typed-relational-algebra
It is one thing to do crazy metaprogramming stuff during runtime to inspect database schemas(ActiveRecord), it's quite another to do it during compile time! What it actually does is uses a pre-processor called camlp4, which allows you to write your own extensions to the OCaml language. Hmm, when you look at it that way, I guess it doesn't seem THAT amazing, I suppose you could do that with any language if you add a pre-processing step. For dynamic languages, this would suck because it adds a build step where there were none). But for a compiled language like OCaml, you don't notice it at all, but cause you are already used to having to compile the code. Pretty much like the C macro-processor in terms of building. But! I think that to call it a pre-processor is really not fair at all. It can do things that most pre-processors can only dream of. What it's doing is not merely a straight text replace, but it hooks into OCaml directly and controls the way it does type checking and type inference, so that the functions that it returns you are typed both in the inputs and outputs: the types which are mapped from the database schema. And because it directly hooks into OCaml, you can use it with the interactive shell too. I haven't seen any code posted yet, so it's pretty much vaporware as of now, but I'll keep an eye on this development.