require 'dl/import' require 'tempfile' module Hubris VERSION = '0.0.1' class Hubris extend DL::Importer # Importable in 1.8, FIXME def initialize(haskell_str) build_jhc(haskell_str) end def build_jhc(haskell_str) file=Tempfile.new("TempHs.hs") # TODO add foreign export calls immediately for each toplevel func # cheap hacky way: first word on each line, nub it to get rid of # function types. # tricky bit: generating interface for each headers = haskell_str.each_line do |line| file.write "#{line.split(/ /)[0]} :: RValue -> IO RValue" end # cheap way: assert type sigs binding to RValue. Might be able to do better after, # but this'll do for the moment file.write(<