Alex Fedorov
Alex Fedorov
`Rec` should be just a builtin contract I think. Example: ``` ruby TreeContract = C::Rec[:X] { C::Or[Num, PairContract[X, X]] } # ... Contract TreeContract, TreeContract => TreeContract def union(a, b)...
Closing this in favor of #157
#157 will add additional syntax that uses isolated namespace and can be evaluated lazily, i.e.: ``` ruby Contract { [c.Num => MyApp::YetToBeDefined] } # ... class MyApp::YetToBeDefined # ... end...
On the other hand, I think you are right. This still should be opened. And this solution with isolated namespace solves more this issue rather than #157
Currently it can be like this: ``` ruby Item = Struct.new(:name, :weight, :value) do include Contracts Contract String, Num, Maybe[Num] => None def initialize(*args) super nil end end ``` Shortcut...
Could be something along these lines: ``` ruby Contract { Num, Num => ArrayOf[ArrayOf[nil, size: @args[1]], size: @args[0]] } # def ... ```
But it will be slower, since contract is more dynamic and basically depends on argument list - means it needs to be evaluated on each call.
I have some freaking awesome and simple idea that might work or might not regarding this code example https://github.com/egonSchiele/contracts.ruby/issues/113#issuecomment-87329450 I will try it out soon and post results.
Well, conceptually `sith` looks awesome, but it doesn't quite work (everything I tried to do got me a ruby parsing error :D). Before we can use it, we might want...
Currently all invariants get validated after each contracted method call here: https://github.com/egonSchiele/contracts.ruby/blob/master/lib/contracts/call_with.rb#L87 So that is only logical that it fails with `stack level too deep` if invariant itself calls any...