[plt-scheme] still stuck with typed scheme problem: "Expected Attribute, but got Attribute"

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Wed Apr 28 18:44:04 EDT 2010

On Wed, Apr 28, 2010 at 4:29 PM, keydana at gmx.de <keydana at gmx.de> wrote:

> Seizing the opportunity, I'd like to ask again about my type matching
> problem :-;
> Right now I'm doing the type matching for
> 1) types defined with define-struct: using (cond (mytype? x)...

If your type is defined using `define-struct:', you can use `match'
with it as well.

> 2) type variants defined with Dave's define-datatype using (match x ((struct
> y (z)) ...

I think `define-datatype' defines predicates (such as `y?') as well.

> but I don't know how to test for 3) union types, nor 4) the type subsuming
> all those variants.
> Or in fact I didn't know, because right now I've found
> (define-predicate test? type)
> in the documentation and it works fine for both cases.
> So perhaps I'm overdoing it here, but I wonder is this bad style (or
> aesthetically unpleasing, somehow), using 3 different ways to match types
> (and in one case, even defining a custom predicate)?

I would use whichever way is most convenient in a particular place.
As indicated above, most of them work in multiple ways.
sam th
samth at ccs.neu.edu

Posted on the users mailing list.