<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi all,<br><br>I'm afraid it's horribly impolite to be pressing like this, but I'm really totally stuck with this type matching problem, in fact I cannot go on without at all, type matching being fundamental everywhere in the code...<br>I don't know if I'm simply overlooking something here or if something more complicated is going on (possibly related to the mixing of the different ways of defining types?).<br><br>I'd be grateful for any hint what I might do/try here :-;<br><br>Here again (because of the changed subject) is the code:<br><br>#lang typed/scheme<br>(require scheme/match)<br>(require (planet dherman/types:2))<br><br>(define-datatype Value<br>(S ((s : String)))<br>(N ((n : Real))))<br><br>(define-struct: Attribute ((name : String) (typename : Symbol)) #:mutable)<br><br>(define-datatype Operator<br>(Greater #:constant greater)<br>(GreaterEql #:constant greatereql)<br>(Less #:constant less)<br>(*LessEql* #:constant *lesseql*)<br>(Eql #:constant eql)<br>(NotEql #:constant noteql))<br><br>(define-type Operand (U Attribute Value))<br><br>(define-datatype Predicate<br>(Is ((op : Operator) (rand1 : Operand) (rand2 : Operand)))<br>(Not ((p : Predicate)))<br>(And ((p1 : Predicate) (p2 : Predicate)))<br>(Or ((p1 : Predicate) (p2 : Predicate))))<br><br>(define p (make-Is eql (make-Attribute "name" 'type) (make-N 3.6)))<br>(display (match p<br> ((struct Is (op r1 r2)) (cond ((Attribute? r1) (Attribute-typename r1))<br> (else #f)))))<br><br><br>Ciao,<br>Sigrid<div><br></div><div><br><div><br></div><div><br></div><div>---------------------------------------------------------------------------------------------------------------------------</div><div><br></div><div><br></div><div><br></div><div>Ah you're right, I'm sorry. Here is a piece now which works (apart from the error it's about):</div><div><div><br>#lang typed/scheme<br>(require scheme/match)<br>(require (planet dherman/types:2))<br><br>(define-datatype Value<br> (S ((s : String)))<br> (N ((n : Real))))<br><br>(define-struct: Attribute ((name : String) (typename : Symbol)) #:mutable)<br><br>(define-datatype Operator<br> (Greater #:constant greater)<br> (GreaterEql #:constant greatereql)<br> (Less #:constant less)<br> (LessEql #:constant lesseql)<br> (Eql #:constant eql)<br> (NotEql #:constant noteql))<br><br>(define-type Operand (U Attribute Value))<br><br>(define-datatype Predicate<br>(Is ((op : Operator) (rand1 : Operand) (rand2 : Operand)))<br>(Not ((p : Predicate)))<br>(And ((p1 : Predicate) (p2 : Predicate)))<br>(Or ((p1 : Predicate) (p2 : Predicate))))<br><br>(define p (make-Is eql (make-Attribute "name" 'type) (make-N 3.6))) <br>(display (match p<br> ((struct Is (op r1 r2)) (cond ((Attribute? r1) (Attribute-typename r1))<br> (else #f)))))<br><br>Ciao,<br>Sigrid<br><br><br><br>Am 25.04.2010 um 14:01 schrieb Sam Tobin-Hochstadt:<br><br><blockquote type="cite">On Sun, Apr 25, 2010 at 2:06 AM, <a href="mailto:keydana@gmx.de">keydana@gmx.de</a> <<a href="mailto:keydana@gmx.de">keydana@gmx.de</a>> wrote:<br></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">I'm stuck with a problem during type matching in typed scheme which I don't<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">know how to get along with. Somehow I suspect it might be related to nesting<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">type definitions in the standard type scheme (define-struct: and<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">define-type)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">and the planet dherman/types:2 package (define-datatype) way, like this:<br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">There seems to be some missing code in your example. What is `eql'<br></blockquote><blockquote type="cite">and what is `Operator'? Neither of them are defined.<br></blockquote><blockquote type="cite">-- <br></blockquote><blockquote type="cite">sam th<br></blockquote><blockquote type="cite"><a href="mailto:samth@ccs.neu.edu">samth@ccs.neu.edu</a><br></blockquote><div><br></div></div></div></div></body></html>