serialize.ss
#lang scheme/base

(require (prefix-in stupid: scheme/serialize)
         "define-provide.ss")

(define (implicit? v)
  ; do NOT use (list?)
  (or (string? v) (integer? v) (symbol? v) (bytes? v) (boolean? v) (null? v)))

(define/provide (encode v)
  (cond
    ((pair? v) (cons (encode (car v)) (encode (cdr v))))
    ((implicit? v) v)
    (else (stupid:serialize v))))

(define/provide (decode v)
  (cond
    ((pair? v) (cons (decode (car v)) (decode (cdr v))))
    ((implicit? v) v)
    (stupid:deserialize v)))

(provide (rename-out (stupid:serializable? encodable?)))