idris-lang/Idris-dev — pull request #1453 by andyarvanitis (2014-08-03 01:47:09+00:00)
Title: Ruby backend, support for multiple FFunction parameters

This pull request actually has three features, so please let me know if you'd like me to break it up, especially if you don't want to accept all of them.

This pull request contains:

1) A Ruby backend, which is very similar (and based on) the JavaScript one.

2) Support for FFunction types with multiple arguments (used in JS and Ruby backends).

3) The preservation of type information in FFunction. Not needed for either of the above, but it's part of the groundwork I'm looking at for support for FFI callbacks in the C (and possibly other) backends.

I've enabled the appropriate tests for the Ruby backend, and they all pass. They've been run on OSX (Mavericks) with its standard version of Ruby, as well as JRuby and Rubinius. I've also done some testing with RubyMotion (http://www.rubymotion.com), which is part of what got me playing around with this.

For the FFunction change, functions are now declared with a list of arguments. For example:

twice : (Int -> Int) -> Int -> IO Int
twice f x = mkForeign (FFun "twice(%0,%1)" [FFunction [FInt] FInt, FInt] FInt ) f x

(a pull request to update the tutorial is also coming)