summaryrefslogtreecommitdiff
path: root/schemantic/rdf.scm
blob: ededcd5fb6545ed6d2f35bdeefb1a134e46c0daa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
; SPDX-FileCopyrightText: 2020 pukkamustard <pukkamustard@posteo.net>
;
; SPDX-License-Identifier: GPL-3.0-or-later

(define-module (schemantic rdf)
  #:use-module (oop goops)
  #:use-module (oop goops describe)     ; only for dev/debug

  #:use-module (schemantic iri)
  #:use-module (schemantic literal)
  #:use-module (schemantic xsd)

  #:export (<triple>
            make-triple
            triple?
            triple-subject
            triple-predicate
            triple-object)

  #:re-export (<iri>
               make-iri
               iri?
               iri-value
               define-namespace

               <literal>
               make-literal
               make-generic-literal
               literal?
               literal-value
               literal-lexical
               literal-canonical
               literal-datatype))

;; Triple

(define-class <triple> ()
  (subject #:init-keyword #:s #:getter triple-subject)
  (predicate #:init-keyword #:p #:getter triple-predicate)
  (object #:init-keyword '#:o #:getter triple-object))

(define-method (initialize (t <triple>) initargs)
  (next-method))

(define (make-triple s p o)
  (make <triple> #:s s #:p p #:o o))

(define (triple? x)
  (is-a? x <triple>))