Closed larrytheliquid closed 13 years ago
I don't like that interface much. I think it should be possible to do it all on the Haskell side - you'd just need to provide instances for Haskellable and Rubyable for each of the sizes of tuple you were interested in - perhaps some Template Haskell could make that less repetitive. I think the real problem is that there's currently no way to inject new instances into the scanning stage.
so, to clarify, this use case ought to work
class Foo
hubris :inline => "tupler (a,b) = (b,a)"
hubris :inline => "doubler l = map (2*) "
end
f=Foo.new
f.tupler([1,2])
=> [2,1]
f.doubler([1,2])
=> [2,4]
so it'd be all arrays on the ruby side.
i think that'll work. i was worried about array being used for both tuples and lists in the nested cases, but in hindsight the haskell side will just work with whatever type it ended up declaring
yeah, that's the theory. should really come up with some twisted test cases though.
ok, I think this is working, at least on https://ci.shimweasel.com.
Not sure what the ideal api would be here... maybe just: class Hubris::Tuple < Array def initialize(_args) super([_args]) end def inspect() super.gsub!('[', '(').gsub(']', ')') end end So: class Tupler hubris :inline => "idTuple :: (Integer, Char) -> (Integer, Char) ; idTuple x = x" end