Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ujihisa/rubyinline-haskell
https://github.com/ujihisa/rubyinline-haskell
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/ujihisa/rubyinline-haskell
- Owner: ujihisa
- Created: 2008-12-28T09:44:06.000Z (almost 16 years ago)
- Default Branch: master
- Last Pushed: 2009-02-20T08:20:12.000Z (over 15 years ago)
- Last Synced: 2024-05-01T23:19:42.520Z (7 months ago)
- Language: Ruby
- Homepage:
- Size: 82 KB
- Stars: 7
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
README
RubyInline Haskell
class Fib
def self.fib(n)
case n
when 0
return 0
when 1
return 1
else
fib(n-2) + fib(n-1)
end
end
endYou can write it such as
class Fib
RubyInlineHaskell.classmethods << QED
fib :: Fixnum -> Fixnum
fib 0 = 0
fib 1 = 1
fib n = fib(n-2) + fib(n-1)
QED
endYou can also get the corresponding type checking specs.
describe Fib
it 'fib :: Fixnum -> Fixnum' do
n = rand(10)
Fib.fib(n).class.should == Fixnum
end
end# KNOWN ISSUE: fib(n) may become Bignum.
# KNOWN ISSUE: It doesn't support type variable like "[a]"2008-12-28 Implemented in my dream.