<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>What I’m trying to accomplish is something more like this:</div><div><font face="Courier New">#lang typed/racket</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(require "dimensions.rkt")</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(struct (d) unit ([name : Any] [scalar : Positive-Real] [dimension : d]) #:transparent</font></div><div><font face="Courier New"> #:guard (lambda (name scalar dimension _)</font></div><div><font face="Courier New"> (unless (dimension? dimension)</font></div><div><font face="Courier New"> (error 'unit "expected Dimension, given ~v" dimension))</font></div><div><font face="Courier New"> (values name scalar dimension)))</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(define-type (Unitof d) </font><span style="font-family: 'Courier New';">(unit d))</span></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(define-type Unit (Unitof Dimension))</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(define Unit? (make-predicate Unit))</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(define-type Unitish</font></div><div><font face="Courier New"> (U (Unitof Any)</font></div><div><font face="Courier New"> Dimension</font></div><div><font face="Courier New"> Positive-Real))</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(: ->unit : (All (d) (case-> [(Unitof d) -> (Unitof d)]</font></div><div><font face="Courier New"> [Unitish -> Unit])))</font></div><div><font face="Courier New">(define (->unit u)</font></div><div><font face="Courier New"> (cond [(unit? u)</font></div><div><font face="Courier New"> (unless (Unit? u) ; this should never happen anyway because of the guard</font></div><div><font face="Courier New"> (error '->unit "expected (Unitof Dimension), given ~v" u))</font></div><div><font face="Courier New"> u]</font></div><div><font face="Courier New"> [(dimension? u) </font><span style="font-family: 'Courier New';">(unit u 1 u)]</span></div><div><span style="font-family: 'Courier New';"> [(positive-real? u) (unit u u dimensionless-dimension)]))</span></div><div><br></div><br><div><div>On Sep 25, 2014, at 6:19 PM, Sam Tobin-Hochstadt <<a href="mailto:samth@cs.indiana.edu">samth@cs.indiana.edu</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">No, I don't think you can do this. Can you say more about what you're<br>trying to accomplish?<br><br>Sam<br><br>On Thu, Sep 25, 2014 at 6:15 PM, Alexander D. Knauth<br><<a href="mailto:alexander@knauth.org">alexander@knauth.org</a>> wrote:<br><blockquote type="cite">Do any of you have any advice for getting a function like this to<br>type-check?<br>#lang typed/racket<br><br>(: check-int : (All (a) (case-> [a -> a]<br> [Any -> Integer])))<br>(define (check-int int)<br> (unless (exact-integer? int)<br> (error 'check-int "expected Integer, given ~v" int))<br> int)<br><br>;. Type Checker: type mismatch<br>; expected: a<br>; given: Integer in: int<br><br><br><br>____________________<br> Racket Users list:<br> <a href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a><br><br></blockquote></blockquote></div><br></body></html>