guile.scm 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. ;;; -*-scheme-*-
  2. ;;; GNU Mes --- Maxwell Equations of Software
  3. ;;; Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  4. ;;;
  5. ;;; This file is part of GNU Mes.
  6. ;;;
  7. ;;; GNU Mes is free software; you can redistribute it and/or modify it
  8. ;;; under the terms of the GNU General Public License as published by
  9. ;;; the Free Software Foundation; either version 3 of the License, or (at
  10. ;;; your option) any later version.
  11. ;;;
  12. ;;; GNU Mes is distributed in the hope that it will be useful, but
  13. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ;;; GNU General Public License for more details.
  16. ;;;
  17. ;;; You should have received a copy of the GNU General Public License
  18. ;;; along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
  19. ;;; Commentary:
  20. ;;; Code:
  21. (define-module (mes guile)
  22. #:export (
  23. <cell:char>
  24. <cell:keyword>
  25. <cell:number>
  26. <cell:pair>
  27. <cell:string>
  28. <cell:symbol>
  29. <cell:vector>
  30. %arch
  31. %compiler
  32. append2
  33. core:apply
  34. core:car
  35. core:display
  36. core:display-error
  37. core:display-port
  38. core:exit
  39. core:macro-expand
  40. core:write
  41. core:write-error
  42. core:write-port
  43. core:type
  44. %compiler
  45. equal2?
  46. keyword->string
  47. pmatch-car
  48. pmatch-cdr
  49. )
  50. ;;#:re-export (open-input-file open-input-string with-input-from-string)
  51. )
  52. (cond-expand
  53. (guile-2)
  54. (guile
  55. (define %host-type (string-append (utsname:machine (uname)) "linux-gnu")))
  56. (else))
  57. (cond-expand
  58. (guile
  59. (define pmatch-car car)
  60. (define pmatch-cdr cdr)
  61. (define core:exit exit)
  62. (define core:display display)
  63. (define core:display-port display)
  64. (define (core:display-error o) (display o (current-error-port)))
  65. (define core:write write)
  66. (define (core:write-error o) (write o (current-error-port)))
  67. (define core:write-port write)
  68. (define core:macro-expand identity)
  69. (define (core:apply f a . m) (apply f a))
  70. (define (core:car f a . m) (apply f a))
  71. (define append2 append)
  72. (define equal2? equal?)
  73. (define guile:keyword? keyword?)
  74. (define guile:number? number?)
  75. (define guile:pair? pair?)
  76. (define guile:string? string?)
  77. (define guile:symbol? symbol?)
  78. (define <cell:char> 0)
  79. (define <cell:keyword> 4)
  80. (define <cell:number> 6)
  81. (define <cell:pair> 7)
  82. (define <cell:string> 10)
  83. (define <cell:symbol> 11)
  84. (define <cell:vector> 15)
  85. (define %arch (car (string-split %host-type #\-)))
  86. (define %compiler "gnuc")
  87. (define %compiler "gnuc")
  88. (define keyword->string (compose symbol->string keyword->symbol))
  89. (define (core:type x)
  90. (cond ((guile:keyword? x) <cell:keyword>)
  91. ((guile:number? x) <cell:number>)
  92. ((guile:pair? x) <cell:pair>)
  93. ((guile:string? x) <cell:string>)
  94. ((guile:symbol? x) <cell:symbol>)))
  95. (define (core:car x)
  96. (cond ((guile:string? x) (string->list x)))))
  97. (mes))
  98. (cond-expand
  99. (guile-2.2)
  100. (guile-2)
  101. (guile
  102. (use-modules (ice-9 syncase))
  103. (define (compose proc . rest)
  104. (if (null? rest) proc
  105. (lambda args
  106. (proc (apply (apply compose rest) args)))))
  107. (export compose))
  108. (mes))