2 ;; "Mu Lei" known as "NalaGinrut" <NalaGinrut@gmail.com>
3 ;; This file is free software: you can redistribute it and/or modify
4 ;; it under the terms of the GNU General Public License as published by
5 ;; the Free Software Foundation, either version 3 of the License, or
6 ;; (at your option) any later version.
8 ;; This file is distributed in the hope that it will be useful,
9 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 ;; GNU General Public License for more details.
13 ;; You should have received a copy of the GNU General Public License
14 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
18 (import (guile) (types) (ice-9 match) (ice-9 regex)))
20 (define (print-hashmap hm p)
21 (call-with-output-string
28 (format #f "~a ~a" (pr_str k #t) (pr_str v #t)))
34 (define (pr_str obj readable?)
38 (string-sub s "\\\\" "\\\\")
41 (define (%pr_str o) (pr_str o readable?))
43 ((? box?) (%pr_str (unbox obj)))
44 ((? is-func?) "#<function>")
45 ((? is-macro?) "#<macro>")
46 ((? list?) (format #f "(~{~a~^ ~})" (map %pr_str obj)))
47 ((? vector?) (format #f "[~{~a~^ ~}]" (map %pr_str (vector->list obj))))
48 ((? hash-table?) (print-hashmap obj %pr_str))
52 => (lambda (m) (format #f ":~a" (substring obj 1))))
53 (else (if readable? (format #f "\"~a\"" (->str obj)) obj))))
54 ;;((? number?) (format #f "~a" obj))
55 ;;((? symbol?) (format #f "~a" obj))
56 ((? atom?) (format #f "(atom ~a)" (%pr_str (atom-val obj))))
60 (else (format #f "~a" obj))))