hubris 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.markdown ADDED
@@ -0,0 +1,17 @@
1
+ ## 0.0.1 2009-08-10
2
+
3
+ * Initial release - allows calls to haskell from ruby.
4
+
5
+ ## 0.0.2 2009-08-16
6
+
7
+ * Fixed up docs
8
+ * Specs now running but not passing
9
+ * Can now run in ruby 1.8 and 1.9
10
+
11
+ ## 0.0.3 2009-08-29
12
+
13
+ * first working inline version (ints only, jhc only, very limited)
14
+
15
+ ## 0.0.4 2009-09-01
16
+
17
+ * floats, strings, nils, booleans now working.
data/Manifest.txt CHANGED
@@ -1,17 +1,10 @@
1
- History.txt
1
+ HISTORY.markdown
2
2
  Manifest.txt
3
3
  PostInstall.txt
4
- README.rdoc
4
+ README.markdown
5
5
  Rakefile
6
- bin/jhc_builder.sh
7
- lib/Hubris.rb
8
- sample/Makefile
9
- sample/Test.hs
10
- sample/hsload.rb
11
- script/console
12
- script/destroy
13
- script/generate
14
- spec/Hubris_spec.rb
6
+ lib/hubris.rb
7
+ sample/Fibonacci.hs
8
+ sample/config.ru
15
9
  spec/spec.opts
16
10
  spec/spec_helper.rb
17
- tasks/rspec.rake
data/PostInstall.txt CHANGED
@@ -1,7 +1,3 @@
1
+ For more information on Hubris, see http://github.com/mwotton/Hubris/tree/master
1
2
 
2
- For more information on Hubris, see http://Hubris.rubyforge.org
3
-
4
- NOTE: Change this information in PostInstall.txt
5
- You can also delete it if you don't want it.
6
-
7
-
3
+ You should now have a bin file named jhc_builder that you can use to compile Haskell files into .so files
data/README.markdown ADDED
@@ -0,0 +1,142 @@
1
+ # Hubris
2
+
3
+ ## Description
4
+
5
+ Hubris is a bridge between Ruby and Haskell, between love and bondage,
6
+ between slothful indolence and raw, blazing speed. Hubris will wash
7
+ your car, lie to your boss, and salvage your love life. If you are
8
+ very, very lucky, it might also let you get some functional goodness
9
+ into your ruby programs through the back door.
10
+
11
+ I probably don't have to say this, but patches are very much
12
+ welcome. If you have trouble installing it, tell me, and help me
13
+ improve the docs.
14
+
15
+ ## Synopsis
16
+
17
+ The best docs, as ever, are in the tests, but as a quick precis, you
18
+ can use it a little like this:
19
+
20
+ require 'hubris' # best line ever
21
+
22
+ class Target
23
+ hubris :inline =>"triple::Int->Int; triple n = 3*n"
24
+ end
25
+
26
+ t = Target.new
27
+ puts t.triple(10)
28
+ => 30
29
+
30
+ There are a few restrictions. All functions take one argument and
31
+ return one value: this shouldn't be a major problem because you can
32
+ pass arrays of arguments in if you need more. Hubris can currently
33
+ handle numbers, strings, basic types (like nil, true and false),
34
+ arrays and hashes. There will probably be some Ruby structures
35
+ (modules, regular expressions, etc) that won't ever be handled
36
+ natively unless someone can convince me it's a sensible thing to do.
37
+
38
+ Hubris will refuse to compile Haskell code that produces any
39
+ warnings. You can suppress this admittedly fairly strict behaviour by
40
+ passing the ":no_strict => true" flag, but in your heart of hearts
41
+ you'll know you've done the wrong thing.
42
+
43
+ There are also two other modes:
44
+
45
+ hubris :source => "MyCoolModule.hs"
46
+
47
+ which loads a source file on disk (in the same directory as your ruby),
48
+ and
49
+
50
+ hubris :module => "Data.ByteString", :packages => ["bytestring"]
51
+
52
+ which will load the Data.ByteString module which is installed on the
53
+ system. In this case, we also need to let the Haskell side know that
54
+ we'll be using the "bytestring" package, so we pass that too: You may
55
+ need to load extra packages with :inline and :source as well, and
56
+ that's supported.
57
+
58
+
59
+ ## Requirements
60
+
61
+ * ghc 6.10 (to bootstrap 6.12) and cabal-install. This comes with the
62
+ Haskell Platform
63
+ * ruby 1.8.6 or higher (most heavily tested on 1.9.1)
64
+ * Linux or Mac. See
65
+ <http://www.shimweasel.com/2009/09/14/unprincipled-skulduggery-with-ghc-6-12-dylibs-on-mac-os-x>
66
+ and the following entry for more info on the Mac build.
67
+ * zsh or bash
68
+ * git
69
+
70
+ ## Install
71
+
72
+ First, we install GHC 6.12 RC2 (living on the cutting edge is fun,
73
+ right?)
74
+
75
+ wget http://www.haskell.org/ghc/dist/6.12.1-rc2/ghc-6.12.0.20091121-src.tar.bz2
76
+ tar -jxvf ghc-6.12.0.20091121-src.tar.bz2
77
+ cd ghc-6.12.0.20091121-src
78
+ # adjust the argument to -j to your number of cores, and the prefix if you need to install somewhere else
79
+ sh boot && ./configure --enable-shared --prefix=/usr/local && make -j 4 && sudo make install
80
+ # check ghc --version at the prompt tells you you're running 6.12
81
+
82
+ Then get the Haskell support libraries installed
83
+
84
+ cabal install c2hs
85
+ # probably a better way of doing this, but this is how i build it.
86
+ cabal unpack hubris
87
+ cd hubris-0.0.2
88
+ # edit the --extra-include-dirs and --extra-lib-dirs to reflect
89
+ # your installation. You'll need the ruby headers installed -
90
+ # they're installed already in ports, and it's ruby1.9.dev on Ubuntu.
91
+ runhaskell Setup configure --enable-shared --user --ghc-options=-dynamic --extra-include-dirs=/usr/local/include/ruby-1.9.1/ --extra-lib-dirs=/usr/local/lib/
92
+ runhaskell Setup build
93
+ runhaskell Setup install
94
+ # check that Hubrify is now in your path.
95
+
96
+ Then the Ruby side
97
+
98
+ sudo gem install rake open4 rspec hubris
99
+
100
+ git clone git://github.com/mwotton/Hubris.git
101
+ cd Hubris/lib
102
+ ruby extconf.rb && make
103
+ cd ..
104
+ spec .
105
+
106
+ I'll gemify this soon too.
107
+
108
+
109
+ ## Contributors
110
+
111
+ * Mark Wotton
112
+ * James Britt
113
+ * Josh Price
114
+ * Tatsuhiro Ujihisa
115
+
116
+ ## License
117
+
118
+ (The MIT License)
119
+
120
+ Copyright (c) 2009 Mark Wotton
121
+
122
+ Permission is hereby granted, free of charge, to any person obtaining
123
+ a copy of this software and associated documentation files (the
124
+ 'Software'), to deal in the Software without restriction, including
125
+ without limitation the rights to use, copy, modify, merge, publish,
126
+ distribute, sublicense, and/or sell copies of the Software, and to
127
+ permit persons to whom the Software is furnished to do so, subject to
128
+ the following conditions:
129
+
130
+ The above copyright notice and this permission notice shall be
131
+ included in all copies or substantial portions of the Software.
132
+
133
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
134
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
135
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
136
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
137
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
138
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
139
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
140
+
141
+
142
+ [haskell_platform]: http://hackage.haskell.org/platform/
data/Rakefile CHANGED
@@ -1,28 +1,51 @@
1
- require 'rubygems'
2
- gem 'hoe', '>= 2.1.0'
3
- require 'hoe'
4
- require 'fileutils'
5
- require './lib/Hubris'
6
- require 'rake/clean'
7
-
8
- CLEAN.include('tmp', 'libdynhs.so')
9
-
10
- Hoe.plugin :newgem
11
- # Hoe.plugin :website
12
- # Hoe.plugin :cucumberfeatures
13
-
14
- # Generate all the Rake tasks
15
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
16
- $hoe = Hoe.spec 'hubris' do
17
- self.developer 'Mark Wotton', 'mwotton@gmail.com'
18
- self.rubyforge_name = self.name # TODO this is default value
19
- # self.extra_deps = [['activesupport','>= 2.0.2']]
20
-
21
- end
22
-
23
- require 'newgem/tasks'
24
- Dir['tasks/**/*.rake'].each { |t| load t }
25
-
26
- # TODO - want other tests/tasks run by default? Add them to the list
27
- # remove_task :default
28
- # task :default => [:spec, :features]
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/hubris'
6
+
7
+ # Hoe.plugin :newgem
8
+ # Hoe.plugin :website
9
+ # Hoe.plugin :cucumberfeatures
10
+
11
+ # Generate all the Rake tasks
12
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
+ $hoe = Hoe.spec 'hubris' do
14
+ self.developer 'Mark Wotton', 'mwotton@gmail.com'
15
+ self.rubyforge_name = "hubris"
16
+ self.summary = 'tool to help build .so files from haskell code for use in Ruby via dl'
17
+ self.post_install_message = 'PostInstall.txt'
18
+ self.readme_file = "README.markdown"
19
+ self.history_file = "HISTORY.markdown"
20
+ end
21
+
22
+ #require 'newgem/tasks'
23
+ # Dir['tasks/**/*.rake'].each { |t| load t }
24
+
25
+
26
+ #file "lib/RubyMap.hs" => ["lib/RubyMap.chs"] do
27
+ # str = "c2hs -v --cppopts='-I" + Hubris::RubyHeader + "' --cpp=gcc --cppopts=-E --cppopts=-xc lib/RubyMap.chs"
28
+ # # print str
29
+ # system(str)
30
+ #end
31
+
32
+ require 'spec'
33
+ require 'spec/rake/spectask'
34
+
35
+ # desc "Run the specs under spec/"
36
+ # all_examples = Spec::Rake::SpecTask.new do |t|
37
+ # t.spec_opts = ['--options', "spec/spec.opts"]
38
+ # t.spec_files = FileList['spec/*.rb']
39
+ # end
40
+
41
+ # task :spec => ["lib/RubyMap.hs"]
42
+
43
+ task :clean do
44
+ FileList[File.expand_path("~/.hubris_cache/*"),
45
+ 'lib*.so', 'lib/*.o', 'libfoo_*.bundle' ].each do |f|
46
+ begin
47
+ File.delete(f)
48
+ rescue
49
+ end
50
+ end
51
+ end
data/lib/hubris.rb ADDED
@@ -0,0 +1,131 @@
1
+ require 'tmpdir'
2
+ require 'rubygems'
3
+ require 'open4'
4
+ require 'digest/md5'
5
+ require 'rbconfig'
6
+
7
+ # require 'file/temp'
8
+ # require 'libHaskell'
9
+ # TODO delete old files
10
+
11
+ class HaskellError < RuntimeError
12
+ end
13
+
14
+ class File
15
+ # takes block
16
+ @@used = 0
17
+ def self.withTempFile(template)
18
+ # put the code in a temporary file, set opt[:source]
19
+
20
+ filename="/tmp/foo_#{$$}_#{@@used}.hs" # File::Temp.new(false)
21
+ @@used += 1
22
+ handle=File.open(filename, 'w')
23
+ yield(filename, handle)
24
+ File::delete(filename)
25
+ end
26
+ end
27
+
28
+ module Hubris
29
+ VERSION = '0.0.2'
30
+ SO_CACHE = File.expand_path("/var/hubris/cache")
31
+ HS_CACHE = File.expand_path("/var/hubris/source")
32
+ require 'HubrisStubLoader'
33
+ [SO_CACHE,HS_CACHE].each {|dir| FileUtils.mkdir_p(dir)}
34
+ $:.push(SO_CACHE)
35
+ @always_rebuild=false
36
+
37
+ @@basepackages = []
38
+ def self.add_packages(packages)
39
+ @@basepackages.concat packages
40
+ end
41
+
42
+ # load the new functions into target
43
+ def hubris(options = { })
44
+ # :inline beats :source beats :mod
45
+ immediate, source, mod,packages = [:inline,:source,:module,:packages].collect {|x| options[x]}
46
+ build_args = options[:no_strict] ? [] : ["--strict"]
47
+ # puts packages
48
+
49
+ # leaves generated source lying around - might want to clean up, but
50
+ # useful for debugging too...
51
+ source = anonymous_module(immediate, build_args) if immediate
52
+ mod = gen_modname(source) if source
53
+ raise "code error, should never happen" unless mod
54
+ require(hubrify(mod,build_args,source||"",packages||[])) # let it crash
55
+
56
+ # bind the functions from the Exports namespace
57
+ include(eval("Hubris::Exports::#{zencode(mod)}"))
58
+ end
59
+
60
+ private
61
+
62
+ def anonymous_module(source,build_args)
63
+ mod = "Inline_#{Digest::MD5.hexdigest(source + build_args.to_s)}"
64
+ filename = "#{HS_CACHE}/#{zencode(mod)}.hs"
65
+ File.open(filename, "w") {|h| h.write "module #{mod} where\nimport Language.Ruby.Hubris.Binding\n#{source}\n"}
66
+ return filename
67
+ end
68
+
69
+ def gen_modname(filename)
70
+ # find the code, compile into haskell module in namespace, set
71
+ l = File.open(filename).read
72
+ l =~ /^ *module *([^ \t\n]*)/
73
+ return $1
74
+ end
75
+
76
+ def zencode(name)
77
+ name.gsub(/Z/, 'ZZ').gsub(/z/, 'zz').gsub(/\./,'zi').gsub(/_/,'zu').gsub(/'/, 'zq')
78
+ end
79
+
80
+ def hubrify(mod, args, src,packages=[])
81
+ libFile = "#{SO_CACHE}/#{zencode(mod)}.#{dylib_suffix}"
82
+ if @always_rebuild or !File.exists?(libFile)
83
+ status,msg = Hubris.noisy("Hubrify --module #{mod} --output #{libFile} #{args.join(' ')} " +
84
+ (packages+@@basepackages).collect{|x| "--package #{x}"}.join(' ') + ' ' + src)
85
+ # if Hubrify's not installed, we throw an exception. just as good as explicitly checking a flag.
86
+ raise HaskellError.new("Hubrify error:\n#{msg + status.exitstatus.to_s}") unless status.exitstatus == 0
87
+ end
88
+ return libFile
89
+ end
90
+
91
+ def dylib_suffix
92
+ case Config::CONFIG['target_os']
93
+ when /darwin/
94
+ "bundle"
95
+ when /linux/
96
+ "so"
97
+ else
98
+ "so" #take a punt
99
+ end
100
+ end
101
+
102
+ def self.noisy(str)
103
+ pid, stdin, stdout, stderr = Open4.popen4 str
104
+ # puts "running #{str}\n"
105
+
106
+
107
+ # puts "Status: #{status.exitstatus}"
108
+ # puts "#{pid} done"
109
+
110
+
111
+ msg =<<-"EOF"
112
+ ran |#{str}|
113
+ output|#{stdout.read}|
114
+ error |#{stderr.read}|
115
+ EOF
116
+ ignored, status = Process.waitpid2 pid
117
+ msg += "status |#{status}|"
118
+ return status, msg
119
+ end
120
+
121
+ end
122
+
123
+ # this may be sketchy :)
124
+ class Class
125
+ include Hubris
126
+ end
127
+
128
+ # rescue LoadError
129
+ # raise HaskellError, "loading #{libFile} failed:\n#{$!.to_s}" +
130
+ # `nm #{libFile} 2>/dev/null` + "\n"
131
+ # end
@@ -1,5 +1,4 @@
1
- {-# LANGUAGE ForeignFunctionInterface #-}
2
-
1
+ module Fibonacci where
3
2
  -- module Test where
4
3
 
5
4
  import Foreign.C.Types
@@ -18,11 +17,3 @@ fibonacci n = fibs !! n
18
17
 
19
18
  -- lookup_hs ::CInt -> CInt
20
19
  -- lookup_hs = fromIntegral . Maybe.fromJust . ((flip Data.Map.lookup) local_map) . fromIntegral
21
- -- foreign export ccall lookup_hs :: CInt -> CInt
22
-
23
- fibonacci_hs :: CInt -> CInt
24
- fibonacci_hs = fromIntegral . fibonacci . fromIntegral
25
-
26
- foreign export ccall fibonacci_hs :: CInt -> CInt
27
-
28
-
data/sample/config.ru ADDED
@@ -0,0 +1,21 @@
1
+ #\ -w -p 8765
2
+ use Rack::Reloader, 0
3
+ use Rack::ContentLength
4
+
5
+ require 'pp'
6
+ require 'hubris'
7
+ class Fibonacci
8
+ hubris :source => 'Fibonacci.hs'
9
+ end
10
+
11
+
12
+ def arg_from env
13
+ env['REQUEST_URI'] ? env['REQUEST_URI'].to_s.sub(/^\//, '').to_i : 0
14
+ end
15
+
16
+ app = proc do |env|
17
+ value = Fibonacci.new.fibonacci( arg_from env )
18
+ [ 200, {'Content-Type' => 'text/plain'}, "The fib number is #{value }" ]
19
+ end
20
+
21
+ run app
data/spec/spec_helper.rb CHANGED
@@ -7,4 +7,4 @@ rescue LoadError
7
7
  end
8
8
 
9
9
  $:.unshift(File.dirname(__FILE__) + '/../lib')
10
- require 'Hubris'
10
+ require 'hubris'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hubris
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Wotton
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-10 00:00:00 +10:00
12
+ date: 2009-11-30 00:00:00 +11:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,41 +22,44 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: 2.3.3
24
24
  version:
25
- description: This is a quick and dirty way to call haskell functions from ruby.
25
+ description: |-
26
+ Hubris is a bridge between Ruby and Haskell, between love and bondage,
27
+ between slothful indolence and raw, blazing speed. Hubris will wash
28
+ your car, lie to your boss, and salvage your love life. If you are
29
+ very, very lucky, it might also let you get some functional goodness
30
+ into your ruby programs through the back door.
31
+
32
+ I probably don't have to say this, but patches are very much
33
+ welcome. If you have trouble installing it, tell me, and help me
34
+ improve the docs.
26
35
  email:
27
36
  - mwotton@gmail.com
28
- executables:
29
- - jhc_builder.sh
37
+ executables: []
38
+
30
39
  extensions: []
31
40
 
32
41
  extra_rdoc_files:
33
- - History.txt
34
42
  - Manifest.txt
35
43
  - PostInstall.txt
36
44
  files:
37
- - History.txt
45
+ - HISTORY.markdown
38
46
  - Manifest.txt
39
47
  - PostInstall.txt
40
- - README.rdoc
48
+ - README.markdown
41
49
  - Rakefile
42
- - bin/jhc_builder.sh
43
- - lib/Hubris.rb
44
- - sample/Makefile
45
- - sample/Test.hs
46
- - sample/hsload.rb
47
- - script/console
48
- - script/destroy
49
- - script/generate
50
- - spec/Hubris_spec.rb
50
+ - lib/hubris.rb
51
+ - sample/Fibonacci.hs
52
+ - sample/config.ru
51
53
  - spec/spec.opts
52
54
  - spec/spec_helper.rb
53
- - tasks/rspec.rake
54
55
  has_rdoc: true
55
- homepage: http://github.com/mwotton/Hubris
56
- post_install_message:
56
+ homepage:
57
+ licenses: []
58
+
59
+ post_install_message: PostInstall.txt
57
60
  rdoc_options:
58
61
  - --main
59
- - README.rdoc
62
+ - README.markdown
60
63
  require_paths:
61
64
  - lib
62
65
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -74,9 +77,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
77
  requirements: []
75
78
 
76
79
  rubyforge_project: hubris
77
- rubygems_version: 1.3.1
80
+ rubygems_version: 1.3.5
78
81
  signing_key:
79
- specification_version: 2
80
- summary: This is a quick and dirty way to call haskell functions from ruby.
82
+ specification_version: 3
83
+ summary: tool to help build .so files from haskell code for use in Ruby via dl
81
84
  test_files: []
82
85
 
data/History.txt DELETED
@@ -1,4 +0,0 @@
1
- === 0.0.1 2009-08-10
2
-
3
- * 1 major enhancement:
4
- * Initial release - allows calls to haskell from ruby.
data/README.rdoc DELETED
@@ -1,61 +0,0 @@
1
- = Hubris
2
-
3
- * http://github.com/mwotton/Hubris
4
-
5
- == DESCRIPTION:
6
-
7
- This is a quick and dirty way to call haskell functions from ruby.
8
-
9
- == FEATURES/PROBLEMS:
10
-
11
- Hubris will wash your car, lie to your boss, and salvage your love life.
12
- If you are very, very lucky, it might also let you get some uber-fast
13
- functional goodness into your ruby programs through the back door.
14
-
15
- == SYNOPSIS:
16
-
17
- Eventually, we'll integrate with RubyInline or something similar,
18
- so we can write inline Haskell. Until that happy day:
19
-
20
- write a haskell file (say sample/foo.hs) with some ccall exports declared
21
- call "jhc_builder.sh foo.hs". This will build "libfoo.so".
22
- write a ruby file similar to sample/hsload.rb in order to call the functions from ruby
23
-
24
- if all else fails, mail mwotton@gmail.com with tales of woe.
25
-
26
- == REQUIREMENTS:
27
-
28
- - jhc <http://repetae.net/computer/jhc/>
29
- - gcc < ... oh, come on. don't tell me you don't have it. >
30
- - ruby 1.8.6 or higher
31
- - linux (mostly because jhc doesn't seem to be working on Mac at the moment.)
32
- - bash
33
-
34
- == INSTALL:
35
-
36
- * sudo gem install Hubris
37
-
38
- == LICENSE:
39
-
40
- (The MIT License)
41
-
42
- Copyright (c) 2009 Mark Wotton
43
-
44
- Permission is hereby granted, free of charge, to any person obtaining
45
- a copy of this software and associated documentation files (the
46
- 'Software'), to deal in the Software without restriction, including
47
- without limitation the rights to use, copy, modify, merge, publish,
48
- distribute, sublicense, and/or sell copies of the Software, and to
49
- permit persons to whom the Software is furnished to do so, subject to
50
- the following conditions:
51
-
52
- The above copyright notice and this permission notice shall be
53
- included in all copies or substantial portions of the Software.
54
-
55
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
56
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
57
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
58
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
59
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
60
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
61
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/bin/jhc_builder.sh DELETED
@@ -1,17 +0,0 @@
1
- #!/bin/sh
2
-
3
- # $1 is our source haskell
4
- rm -rf tmp.old
5
- mv tmp tmp.old
6
- mkdir tmp
7
- tmp="tmp/$1"
8
- cat $1 >> $tmp
9
- echo "main :: IO ()" >> $tmp
10
- echo "main = return ()" >> $tmp
11
-
12
- cd tmp
13
- jhc "$1"
14
- sed -i 's/^main(/disregard_main(/' hs.out_code.c
15
- gcc '-std=gnu99' -D_GNU_SOURCE '-falign-functions=4' -ffast-math -Wshadow -Wextra -Wall -Wno-unused-parameter -o libdynhs.so \
16
- hs.out_code.c -DNDEBUG -O3 -fPIC -shared
17
- mv libdynhs.so ..
data/lib/Hubris.rb DELETED
@@ -1,6 +0,0 @@
1
- $:.unshift(File.dirname(__FILE__)) unless
2
- $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
-
4
- module Hubris
5
- VERSION = '0.0.1'
6
- end
data/sample/Makefile DELETED
@@ -1,6 +0,0 @@
1
- all: libdynhs.so
2
- libdynhs.so: Test.hs
3
- ../bin/jhc_builder.sh Test.hs
4
-
5
- clean:
6
- rm -rf tmp/ libdynhs.so
data/sample/hsload.rb DELETED
@@ -1,9 +0,0 @@
1
- require 'dl/import'
2
-
3
- module HaskyPants
4
- extend DL::Importable
5
- dlload "./libdynhs.so"
6
- extern "int fibonacci_hs(int)"
7
- end
8
-
9
- puts HaskyPants.fibonacci_hs(12)
data/script/console DELETED
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # File: script/console
3
- irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
-
5
- libs = " -r irb/completion"
6
- # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
- # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
- libs << " -r #{File.dirname(__FILE__) + '/../lib/Hubris.rb'}"
9
- puts "Loading Hubris gem"
10
- exec "#{irb} #{libs} --simple-prompt"
data/script/destroy DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/destroy'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/generate'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Generate.new.run(ARGV)
data/spec/Hubris_spec.rb DELETED
@@ -1,11 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- # Time to add your specs!
4
- # http://rspec.info/
5
- describe "Hubris tests" do
6
-
7
- it "can build the sample app" do
8
- # violated "Be sure to write your specs"
9
- end
10
-
11
- end
data/tasks/rspec.rake DELETED
@@ -1,21 +0,0 @@
1
- begin
2
- require 'spec'
3
- rescue LoadError
4
- require 'rubygems' unless ENV['NO_RUBYGEMS']
5
- require 'spec'
6
- end
7
- begin
8
- require 'spec/rake/spectask'
9
- rescue LoadError
10
- puts <<-EOS
11
- To use rspec for testing you must install rspec gem:
12
- gem install rspec
13
- EOS
14
- exit(0)
15
- end
16
-
17
- desc "Run the specs under spec/models"
18
- Spec::Rake::SpecTask.new do |t|
19
- t.spec_opts = ['--options', "spec/spec.opts"]
20
- t.spec_files = FileList['spec/**/*_spec.rb']
21
- end