<span id="mailbox-conversation"><div>Where are you calling `cubic-bezier` from? If its from the REPL, the module itself, or a submodule the function won’t have a contract attached. Only code outside `cubic-bezier`s module will have the version of `cubic-bezier` with a contract attached.</div></span><div class="mailbox_signature"><br></div>
<br><br><div class="gmail_quote"><p>On Wed, Oct 1, 2014 at 9:46 PM, Alexander McLin <span dir="ltr"><<a href="mailto:alex.mclin@gmail.com" target="_blank">alex.mclin@gmail.com</a>></span> wrote:<br></p><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div dir="ltr">Hello,<div><br></div>
<div>I've been working on a sample project to better understand how to use the contract system. I created a simple Bezier curve implementation and am using (provide (contract-out...) to attach contracts to the provided bindings.</div>
<div><br></div>
<div>Basically I have a procedure called cubic-bezier that accepts two control point structs used to define the curve. It returns another procedure that actually generates the curve, it accepts an integer parameter that lies on [0, 1] and an optional keyword #:clamp-range. The generator procedure returns a number.</div>
<div><br></div>
<div>The control point structure is a simple posn type that accepts X and Y fields where X must be between 0 and 1, and Y is allowed to be any number.</div>
<div><br></div>
<div>Here are the contracts I defined provisionally:</div>
<div><br></div>
<div>
<div>(provide (contract-out</div>
<div>          [struct bezier-control-point ((x (and/c number? (between/c 0 1)))</div>
<div>                                                      (y number?))]</div>
<div>          [cubic-bezier (-> bezier-control-point? </div>
<div>                                     bezier-control-point?</div>
<div>                                    (->* ((and/c number? (between/c 0 1)))</div>
<div>                                           (#:clamp-range boolean?)</div>
<div>                                           number?))]))</div>
</div>
<div><br></div>
<div>For the contract attached to cubic-bezier using ->, my thinking was to use ->* to generate the contract for the procedure returned by cubic-bezier but it's not working, meaning I'm not getting the any contract violations I'm expecting when giving bad inputs to cubic-bezier's value.</div>
<div><br></div>
<div>How can I attach a more complex contract to cubic-bezier's value?</div>
<div><br></div>
<div>Thank you</div>
<div>Alexander McLin</div>
</div></blockquote></div><br>