Created
September 14, 2009 11:36
-
-
Save agrimm/186612 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[agrimm@computer_name Hubris]$ irb | |
irb(main):001:0> $LOAD_PATH << './lib' | |
=> ["/usr/lib/ruby/site_ruby/1.8", "/usr/lib/ruby/site_ruby/1.8/i386-linux", "/usr/lib/ruby/site_ruby", "/usr/lib/site_ruby/1.8", "/usr/lib/site_ruby/1.8/i386-linux", "/usr/lib/site_ruby", "/usr/lib/ruby/1.8", "/usr/lib/ruby/1.8/i386-linux", ".", "./lib"] | |
irb(main):002:0> require "hubris" | |
mkdir: cannot create directory `/home/agrimm/.hubris_cache': File exists | |
find: `/home/agrimm/bin': No such file or directory | |
creating Makefile | |
=> true | |
irb(main):003:0> class Target | |
irb(main):004:1> include Hubris | |
irb(main):005:1> def negate(i) | |
irb(main):006:2> return -i | |
irb(main):007:2> end | |
irb(main):008:1> end | |
=> nil | |
irb(main):009:0> | |
irb(main):010:0* t = Target.new | |
=> #<Target:0xb7d71574> | |
irb(main):011:0> t.inline "mydouble (T_FIXNUM i) = T_FIXNUM (i + i) | |
irb(main):012:0" my_double _ = T_NIL" | |
HaskellError: ghc build failed /usr/local/bin/ghc-6.11.20090912 -Wall --make -dynamic -fPIC -shared /tmp/my_double_source.hs -lHSrts-ghc6.11.20090912 -L/usr/local/lib/ghc-6.11.20090912 -no-hs-main -optl-Wl,-rpath,/usr/local/lib/ghc-6.11.20090912 -o ~/.hubris_cache/libmy_double_6251dd98e4502b7c55796bccbd59b023.so stubs.c ./lib/rshim.c ./lib/RubyMap.hs -I/usr/lib/ruby/1.8/i386-linux -I./lib -Werror | |
output: | |
error: [2 of 2] Compiling Main ( /tmp/my_double_source.hs, /tmp/my_double_source.o ) | |
/tmp/my_double_source.hs:25:0: | |
Warning: Pattern match(es) are non-exhaustive | |
In the definition of `mydouble': | |
Patterns not matched: | |
T_NIL | |
T_FLOAT _ | |
T_STRING _ | |
T_ARRAY _ | |
... | |
<no location info>: | |
Failing due to -Werror. | |
-- COMPILED WITH ghc | |
{-# LANGUAGE ScopedTypeVariables, FlexibleInstances, ForeignFunctionInterface, UndecidableInstances #-} | |
-- import Foreign.Ptr() | |
import RubyMap | |
import Prelude hiding (catch) | |
import Control.Exception(SomeException, evaluate, catch) | |
import Foreign(unsafePerformIO) | |
main :: IO () | |
main = return () | |
my_double :: RValue -> RValue | |
my_double_external :: Value -> Value -> Value | |
my_double_external _mod x = unsafePerformIO $ | |
(evaluate (toRuby $ my_double $ fromRuby x)) | |
`catch` (\y -> throwException (show (y::SomeException))) | |
foreign export ccall "my_double_external" my_double_external :: Value -> Value -> Value | |
mydouble :: RValue -> RValue | |
mydouble_external :: Value -> Value -> Value | |
mydouble_external _mod x = unsafePerformIO $ | |
(evaluate (toRuby $ mydouble $ fromRuby x)) | |
`catch` (\y -> throwException (show (y::SomeException))) | |
foreign export ccall "mydouble_external" mydouble_external :: Value -> Value -> Value | |
mydouble (T_FIXNUM i) = T_FIXNUM (i + i) | |
my_double _ = T_NIL | |
from ./lib/hubris.rb:194:in `ghcbuild' | |
from ./lib/hubris.rb:143:in `inline' | |
from ./lib/hubris.rb:169:in `call' | |
from ./lib/hubris.rb:169:in `inline' | |
from (irb):11 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment