Submit Search
Upload
Ruby haskell extension
•
Download as KEY, PDF
•
0 likes
•
691 views
Toshiyuki Terashita
Follow
RubyからHaslekkで記述した関数を呼び出すサンプルの説明です。
Read less
Read more
Technology
Education
Report
Share
Report
Share
1 of 34
Download now
Recommended
20151224-games
20151224-games
Noritada Shimizu
2016 gunma.web games-and-asm.js
2016 gunma.web games-and-asm.js
Noritada Shimizu
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
Cpp
Cpp
Ankit Dubey
Basic Programs of C++
Basic Programs of C++
Bharat Kalia
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
1
1
swetha gokavarapu
Include
Include
Shi Chakep
Recommended
20151224-games
20151224-games
Noritada Shimizu
2016 gunma.web games-and-asm.js
2016 gunma.web games-and-asm.js
Noritada Shimizu
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
Cpp
Cpp
Ankit Dubey
Basic Programs of C++
Basic Programs of C++
Bharat Kalia
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
1
1
swetha gokavarapu
Include
Include
Shi Chakep
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
Include
Include
Angie Borda
C++ programs
C++ programs
Mukund Gandrakota
Bankers Algo Implementation
Bankers Algo Implementation
Deepak Agarwal
Oops in c++
Oops in c++
DravidSh
One dimensional operation of Array in C- language
One dimensional operation of Array in C- language
9096308941
Code
Code
Lay Chan Dara Raksmey
A Shiny Example-- R
A Shiny Example-- R
Dr. Volkan OBAN
Cpp tutorial
Cpp tutorial
Vikas Sharma
Oprerator overloading
Oprerator overloading
Parthipan Parthi
Modificacion del programa
Modificacion del programa
Mario José
PROGRAM FOR INSERTION SORTING IN ARRAY
PROGRAM FOR INSERTION SORTING IN ARRAY
daemian2
Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2
Dr. Loganathan R
ECMAScript 5: Новое в JavaScript
ECMAScript 5: Новое в JavaScript
Департамент Стратегических Технологий
Introduction to cron queue
Introduction to cron queue
ADCI Solutions
week-5x
week-5x
KITE www.kitecolleges.com
Document
Document
AjitRaj12
cosc 281 hw2
cosc 281 hw2
Brian Goggins
Frank-afcproxy
Frank-afcproxy
Toshiyuki Terashita
Amazon aws 20110611
Amazon aws 20110611
Toshiyuki Terashita
More Related Content
What's hot
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
Pratik Bakane C++
Pratik Bakane C++
pratikbakane
Include
Include
Angie Borda
C++ programs
C++ programs
Mukund Gandrakota
Bankers Algo Implementation
Bankers Algo Implementation
Deepak Agarwal
Oops in c++
Oops in c++
DravidSh
One dimensional operation of Array in C- language
One dimensional operation of Array in C- language
9096308941
Code
Code
Lay Chan Dara Raksmey
A Shiny Example-- R
A Shiny Example-- R
Dr. Volkan OBAN
Cpp tutorial
Cpp tutorial
Vikas Sharma
Oprerator overloading
Oprerator overloading
Parthipan Parthi
Modificacion del programa
Modificacion del programa
Mario José
PROGRAM FOR INSERTION SORTING IN ARRAY
PROGRAM FOR INSERTION SORTING IN ARRAY
daemian2
Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2
Dr. Loganathan R
ECMAScript 5: Новое в JavaScript
ECMAScript 5: Новое в JavaScript
Департамент Стратегических Технологий
Introduction to cron queue
Introduction to cron queue
ADCI Solutions
week-5x
week-5x
KITE www.kitecolleges.com
Document
Document
AjitRaj12
cosc 281 hw2
cosc 281 hw2
Brian Goggins
What's hot
(20)
Pratik Bakane C++
Pratik Bakane C++
Pratik Bakane C++
Pratik Bakane C++
Pratik Bakane C++
Pratik Bakane C++
Include
Include
C++ programs
C++ programs
Bankers Algo Implementation
Bankers Algo Implementation
Oops in c++
Oops in c++
One dimensional operation of Array in C- language
One dimensional operation of Array in C- language
Code
Code
A Shiny Example-- R
A Shiny Example-- R
Cpp tutorial
Cpp tutorial
Oprerator overloading
Oprerator overloading
Modificacion del programa
Modificacion del programa
PROGRAM FOR INSERTION SORTING IN ARRAY
PROGRAM FOR INSERTION SORTING IN ARRAY
Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2
ECMAScript 5: Новое в JavaScript
ECMAScript 5: Новое в JavaScript
Introduction to cron queue
Introduction to cron queue
week-5x
week-5x
Document
Document
cosc 281 hw2
cosc 281 hw2
Viewers also liked
Frank-afcproxy
Frank-afcproxy
Toshiyuki Terashita
Amazon aws 20110611
Amazon aws 20110611
Toshiyuki Terashita
Castoro sequense
Castoro sequense
Toshiyuki Terashita
Apache mod authまわりとか
Apache mod authまわりとか
Toshiyuki Terashita
Ruby2.0 - refinements - 鳥取Ruby会 第11回
Ruby2.0 - refinements - 鳥取Ruby会 第11回
Rie HIRONO
とっとるびー(2回目)発表資料
とっとるびー(2回目)発表資料
ionis111
Castoro / RubyKaigi2010
Castoro / RubyKaigi2010
Toshiyuki Terashita
Apache2.3 探訪
Apache2.3 探訪
KLab株式会社
Tottoruby 20130119
Tottoruby 20130119
Takashi SAKAGUCHI
Bazaar
Bazaar
KLab株式会社
Web Server - Internet Applications
Web Server - Internet Applications
sandra sukarieh
Viewers also liked
(11)
Frank-afcproxy
Frank-afcproxy
Amazon aws 20110611
Amazon aws 20110611
Castoro sequense
Castoro sequense
Apache mod authまわりとか
Apache mod authまわりとか
Ruby2.0 - refinements - 鳥取Ruby会 第11回
Ruby2.0 - refinements - 鳥取Ruby会 第11回
とっとるびー(2回目)発表資料
とっとるびー(2回目)発表資料
Castoro / RubyKaigi2010
Castoro / RubyKaigi2010
Apache2.3 探訪
Apache2.3 探訪
Tottoruby 20130119
Tottoruby 20130119
Bazaar
Bazaar
Web Server - Internet Applications
Web Server - Internet Applications
Similar to Ruby haskell extension
C programs Set 2
C programs Set 2
Koshy Geoji
Bijender (1)
Bijender (1)
Ankush Kumar
C Programming lab
C Programming lab
Vikram Nandini
IR Journal (itscholar.codegency.co.in).pdf
IR Journal (itscholar.codegency.co.in).pdf
RahulRoy130127
Chainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみた
Akira Maruoka
C Programming
C Programming
Sumant Diwakar
Basicsof c make and git for a hello qt application
Basicsof c make and git for a hello qt application
Dinesh Manajipet
C basics
C basics
MSc CST
'C' language notes (a.p)
'C' language notes (a.p)
Ashishchinu
CppTutorial.ppt
CppTutorial.ppt
HODZoology3
Final DAA_prints.pdf
Final DAA_prints.pdf
Yashpatel821746
7720
7720
Yashpatel821746
All I know about rsc.io/c2go
All I know about rsc.io/c2go
Moriyoshi Koizumi
JVM code reading -- C2
JVM code reading -- C2
ytoshima
C++ manual Report Full
C++ manual Report Full
Thesis Scientist Private Limited
ISCA Final Presentaiton - Compilations
ISCA Final Presentaiton - Compilations
HSA Foundation
R (Shiny Package) - Server Side Code for Decision Support System
R (Shiny Package) - Server Side Code for Decision Support System
Maithreya Chakravarthula
Billing in a supermarket c++
Billing in a supermarket c++
varun arora
C lab programs
C lab programs
Dr. Prashant Vats
C lab programs
C lab programs
Dr. Prashant Vats
Similar to Ruby haskell extension
(20)
C programs Set 2
C programs Set 2
Bijender (1)
Bijender (1)
C Programming lab
C Programming lab
IR Journal (itscholar.codegency.co.in).pdf
IR Journal (itscholar.codegency.co.in).pdf
Chainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみた
C Programming
C Programming
Basicsof c make and git for a hello qt application
Basicsof c make and git for a hello qt application
C basics
C basics
'C' language notes (a.p)
'C' language notes (a.p)
CppTutorial.ppt
CppTutorial.ppt
Final DAA_prints.pdf
Final DAA_prints.pdf
7720
7720
All I know about rsc.io/c2go
All I know about rsc.io/c2go
JVM code reading -- C2
JVM code reading -- C2
C++ manual Report Full
C++ manual Report Full
ISCA Final Presentaiton - Compilations
ISCA Final Presentaiton - Compilations
R (Shiny Package) - Server Side Code for Decision Support System
R (Shiny Package) - Server Side Code for Decision Support System
Billing in a supermarket c++
Billing in a supermarket c++
C lab programs
C lab programs
C lab programs
C lab programs
Recently uploaded
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
Rafal Los
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
ThousandEyes
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
wesley chun
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
The Digital Insurer
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
Anna Loughnan Colquhoun
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
apidays
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
Enterprise Knowledge
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Miguel Araújo
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
Martijn de Jong
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
Pooja Nehwal
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Katpro Technologies
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
Radu Cotescu
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
Results
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
Enterprise Knowledge
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
Maria Levchenko
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
Malak Abu Hammad
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
Delhi Call girls
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Neo4j
Recently uploaded
(20)
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Ruby haskell extension
1.
2.
3.
4.
5.
6.
7.
�
8.
9.
foreign import ccall
”math.h sin” sin :: CDouble -> CDouble foreign export ccall ”fact” fact :: CInt -> CInt
10.
�
11.
== factorial.hs == Module
Factorial where import Foreign.C.Types foreign export ccall ”factorial” factorial :: CInt -> Cint factorial 0 = 1 factorial x = x * factorial(x-1)
12.
13.
== main.c == #include
<stdio.h> #include “factorial_stub.h” int main(int argc, char* argv[]) { hs_init(&argc, &argv); printf(“%dn”, fact(5)); hs_exit(); return 0; }
14.
$ ghc -shared
-dynamic ... ( )
15.
#include <ruby.h> #include "factorial_stub.h" static
VALUE rb_factorial(VALUE self, VALUE val) { return UINT2NUM(factorial(NUM2UINT(val))); } void Init_factorial(void) { hs_init(NULL, NULL);// Haskell .. rb_define_module_function(rb_mMath, "factorial", RUBY_METHOD_FUNC(rb_factorial), 1); }
16.
(gem install
) $ irb -r factorial/factorial irb(main):001:0> Math.factorial 4 => 24
17.
foreign export ccall
”factorial” factorial :: CInt -> CInt CInt -229 +229-1 9 362,880 10 3,628,800 15 1.30767E+12
18.
19.
20.
21.
$ cd `ghc
--print-libdir` �
22.
23.
24.
require 'rbconfig' TARGET =
'factorial' C_SRC = %w{ main.c } HS_SRC = %w{ factorial.hs } HS_LIBS = %w{ base integer-gmp ghc-prim } CONF = RbConfig::MAKEFILE_CONFIG VALS = %w{prefix includedir RUBY_BASE_NAME ruby_version rubyhdrdir arch MKDIR_P INSTALL INSTALL_PROGRAM}.map{|k| "#{k}=#{CONF[k]}" }.join("n") GHC_LIBDIR=`ghc --print-libdir`.strip FLAGS = "FLAGS=-I$(rubyhdrdir) -I$(rubyhdrdir)/$(arch) - shared -dynamic -no-hs-main -lHSrts -lffin" + "FLAGS+=-no-auto-link-packages -I#{GHC_LIBDIR}/ include -L#{GHC_LIBDIR}n" + HS_LIBS.map{|l| 'FLAGS+=' + `ghc-pkg describe #{l}|sed -ne 's/ library-dirs: /-L/p;s/hs-libraries: /-l/p;'`.gsub(/n/, ' ') }.join("n") + "nFLAGS+=-lgmpn"
25.
File.open("Makefile", "w") {|f|
f.puts <<__MAKEFILE__ TARGET=#{TARGET}.#{CONF['DLEXT']} HS_SRC=#{HS_SRC.join(' ')} C_SRC=#{C_SRC.join(' ')} #{VALS} #{FLAGS} STUB=$(HS_SRC:.hs=_stub.o) all : $(TARGET) $(STUB) : $(HS_SRC) ghc $< $(TARGET) : $(C_SRC) $(STUB) $(HS_SRC:.hs=.o) ghc -o $@ $^ $(FLAGS) install: $(MKDIR_P) ../lib/#{TARGET}/ $(INSTALL_PROGRAM) $(TARGET) ../lib/#{TARGET}/ clean: rm -f $(TARGET) $(C_SRC:.c=.o) $(HS_SRC:.hs=.hi) $ (HS_SRC:.hs=.o) $(HS_SRC:.hs=_stub.)* __MAKEFILE__ }
26.
27.
28.
29.
� �
30.
�
Editor's Notes
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Download now