(struct fruit (name color))

-> (struct? (fruit 'apple 'red))
#f

This surprised me.  I'm trying to wrap my head around the docs for
struct? and struct-info? and not having a lot of success.  Is there a
way to simply say "is this a struct of some sort?"

Context:

I'm playing around with structs that contain information about structs
and I'd like to be able to validate the information that's going in:

(struct field-info (field-name predicate getter setter required?
default on-update)
  #:guard (lambda  (field-name predicate getter setter required?
default on-update type)
            (define/contract (init-field-info field-name predicate
getter setter required? default on-update)
              (-> symbol?                   ; field name
                  (-> any/c   boolean?)     ; predicate
                  (-> struct? any/c)        ; getter
                  (-> struct? struct?)      ; setter
                  boolean?                  ; required
                  (or/c (not/c procedure?)  ; default
                          (-> struct? any/c))
                  (-> struct? any/c any)    ; on-update
                  any ; unchecked return value
                  )
              (when (and required? (not-equal? default
'no-default-specified-by-field-info))
                    (raise-arguments-error 'init-field-info
                                       "Cannot specify a default for a
required field"
                                       "default" default))
              (values field-name predicate getter setter required?
default on-update))
            ;
            (init-field-info field-name predicate getter setter
required? default on-update)))

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to