No description, website, or topics provided.
Ruby
Switch branches/tags
Nothing to show
Clone or download
carview.php?tsp= Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
carview.php?tsp= lib
carview.php?tsp= README
carview.php?tsp= memo.txt

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.