[racket] color does not match like other structs

From: Danny Yoo (dyoo at hashcollision.org)
Date: Wed Aug 29 14:08:12 EDT 2012

> This came up perhaps a year ago; I'm writing about pattern matching with the
> color struct that comes with 2htdp/image. It is inconsistent with struct
> matching generally.
> In the following excerpt, bar and baz are fine, but foo (commented out)
> causes an error (match: color does not refer to a structure definition):

Although it doesn't appear to be documented, the color structure can
be found in mrlib/image-core.  So you can do this:

#lang racket
(require (except-in 2htdp/image color)
         (only-in mrlib/image-core color))

(match (make-color 3 4 5)
  ([struct color (r g b a)]

I think part of what was interfering with what you were doing earlier
is that the 'color' structure isn't exposed as a structure in
2htdp/image, but instead is exposed as a HTDP-level primitive.

Good luck!

Posted on the users mailing list.