guile-fediverse/activitystreams/predicates.scm

predicates.scm

1
;;;; Copyright (C) 2020 Julien Lepiller <julien@lepiller.eu>
2
;;;; 
3
;;;; This library is free software; you can redistribute it and/or
4
;;;; modify it under the terms of the GNU Lesser General Public
5
;;;; License as published by the Free Software Foundation; either
6
;;;; version 3 of the License, or (at your option) any later version.
7
;;;; 
8
;;;; This library 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 GNU
11
;;;; Lesser General Public License for more details.
12
;;;; 
13
;;;; You should have received a copy of the GNU Lesser General Public
14
;;;; License along with this library; if not, write to the Free Software
15
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
17
(define-module (activitystreams predicates)
18
  #:use-module (activitystreams ontology)
19
  #:use-module (ice-9 match)
20
  #:use-module (jsonld json)
21
  #:use-module (web uri)
22
  #:export (uri? float? mime-type? date? string-or-lang-string? duration?
23
            langtag? link-relation? non-negative-integer?))
24
25
(define (uri? s)
26
  (and (string? s) (string->uri s)))
27
28
(define (float? s)
29
  (or (number? s)
30
      (and (string? s) (string->number s))))
31
32
(define (mime-type? s)
33
  (string? s))
34
35
(define (date? s)
36
  (string? s))
37
38
(define (string-or-lang-string? s)
39
  (or (string? s) (as-string? s)))
40
41
(define (duration? s)
42
  (string? s))
43
44
(define (langtag? s)
45
  (string? s))
46
47
(define (link-relation? s)
48
  (string? s))
49
50
(define (non-negative-integer? s)
51
  (and (number? s) (>= s 0)))
52