hubris 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +17 -0
- data/PostInstall.txt +7 -0
- data/README.rdoc +61 -0
- data/Rakefile +28 -0
- data/bin/jhc_builder.sh +17 -0
- data/lib/Hubris.rb +6 -0
- data/sample/Makefile +6 -0
- data/sample/Test.hs +28 -0
- data/sample/hsload.rb +9 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/Hubris_spec.rb +11 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- data/tasks/rspec.rake +21 -0
- metadata +82 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
PostInstall.txt
|
4
|
+
README.rdoc
|
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
|
15
|
+
spec/spec.opts
|
16
|
+
spec/spec_helper.rb
|
17
|
+
tasks/rspec.rake
|
data/PostInstall.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,61 @@
|
|
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/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
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]
|
data/bin/jhc_builder.sh
ADDED
@@ -0,0 +1,17 @@
|
|
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
ADDED
data/sample/Makefile
ADDED
data/sample/Test.hs
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
{-# LANGUAGE ForeignFunctionInterface #-}
|
2
|
+
|
3
|
+
-- module Test where
|
4
|
+
|
5
|
+
import Foreign.C.Types
|
6
|
+
-- import Data.Map
|
7
|
+
import Maybe
|
8
|
+
|
9
|
+
-- main = putStrLn "11"
|
10
|
+
|
11
|
+
fibonacci :: Int -> Int
|
12
|
+
fibonacci n = fibs !! n
|
13
|
+
where fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
|
14
|
+
|
15
|
+
-- local_map = Data.Map.fromList [(1,2), (3,4)]
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
-- lookup_hs ::CInt -> CInt
|
20
|
+
-- 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/hsload.rb
ADDED
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
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
ADDED
@@ -0,0 +1,14 @@
|
|
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
ADDED
@@ -0,0 +1,14 @@
|
|
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
ADDED
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/spec/spec_helper.rb
ADDED
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,21 @@
|
|
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
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hubris
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mark Wotton
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-08-10 00:00:00 +10:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hoe
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.3.3
|
24
|
+
version:
|
25
|
+
description: This is a quick and dirty way to call haskell functions from ruby.
|
26
|
+
email:
|
27
|
+
- mwotton@gmail.com
|
28
|
+
executables:
|
29
|
+
- jhc_builder.sh
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files:
|
33
|
+
- History.txt
|
34
|
+
- Manifest.txt
|
35
|
+
- PostInstall.txt
|
36
|
+
files:
|
37
|
+
- History.txt
|
38
|
+
- Manifest.txt
|
39
|
+
- PostInstall.txt
|
40
|
+
- README.rdoc
|
41
|
+
- 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
|
51
|
+
- spec/spec.opts
|
52
|
+
- spec/spec_helper.rb
|
53
|
+
- tasks/rspec.rake
|
54
|
+
has_rdoc: true
|
55
|
+
homepage: http://github.com/mwotton/Hubris
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options:
|
58
|
+
- --main
|
59
|
+
- README.rdoc
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: "0"
|
67
|
+
version:
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: "0"
|
73
|
+
version:
|
74
|
+
requirements: []
|
75
|
+
|
76
|
+
rubyforge_project: hubris
|
77
|
+
rubygems_version: 1.3.1
|
78
|
+
signing_key:
|
79
|
+
specification_version: 2
|
80
|
+
summary: This is a quick and dirty way to call haskell functions from ruby.
|
81
|
+
test_files: []
|
82
|
+
|