puts "#!/usr/bin/env ruby"

def read(file,red={})
  return if red[file]
  red[file] = true
  f = File.read(file).gsub(/require_relative "\.\/(.*)"\n/){
    read($1,red)
    ""
  }
  puts "\n# #{file} " + "#" * (77 - file.length)
  puts f.sub('<Header.hs>'){ File.read("Header.hs").gsub('\\\\'){'\\\\\\\\'} }
end

puts File.read("LICENSE.txt").gsub(/^/,"# ")
read($*[0] || "main.rb")
