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
2008-12-28 Implemented in my dream.