Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ujihisa/rubyinline-haskell


https://github.com/ujihisa/rubyinline-haskell

Last synced: about 1 month ago
JSON representation

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
end

You 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
end

You 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.