reader.scm 684 B

123456789101112131415161718192021222324252627
  1. (library (reader)
  2. (export read-vocabulary)
  3. (import (rnrs base)
  4. (only (guile)
  5. lambda* λ
  6. ;; file stuff
  7. call-with-input-file
  8. set-port-encoding!)
  9. ;; SRFI 43 - vector procs
  10. (srfi srfi-43)
  11. ;; SRFI 69 - hash tables
  12. (srfi srfi-69)
  13. (json)
  14. (contract)
  15. (model))
  16. (define-with-contract read-vocabulary
  17. (require (string? filename))
  18. (ensure (vocabulary? <?>))
  19. (λ (filename)
  20. (scm->vocabulary
  21. (call-with-input-file filename
  22. (λ (port)
  23. (set-port-encoding! port "UTF-8")
  24. (json->scm port)))))))