summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.org4
-rw-r--r--schemantic/blank-node.scm23
-rw-r--r--schemantic/interop/guile-rdf.scm2
3 files changed, 25 insertions, 4 deletions
diff --git a/README.org b/README.org
index 0a2447f..ead7a10 100644
--- a/README.org
+++ b/README.org
@@ -5,10 +5,6 @@
A [[https://www.gnu.org/software/guile/][Guile]] library for the Semantic Web. Implements the Resource Description Framework (RDF).
* Caveats
-** No Blank Nodes
-
-Instead there is a ~<lvar>~ that can be used as a local existential variable. ~<lvar>~ can not be serialized.
-
** GOOPS
Guile Schemantic uses GOOPS, the object oriented extension to Guile. This is an
diff --git a/schemantic/blank-node.scm b/schemantic/blank-node.scm
new file mode 100644
index 0000000..71d5f5c
--- /dev/null
+++ b/schemantic/blank-node.scm
@@ -0,0 +1,23 @@
+; SPDX-FileCopyrightText: 2020 pukkamustard <pukkamustard@posteo.net>
+;
+; SPDX-License-Identifier: GPL-3.0-or-later
+
+(define-module (schemantic blank-node)
+ #:use-module (schemantic iri)
+
+ #:use-module (oop goops)
+
+ #:export (<blank-node>
+ make-blank-node))
+
+(define-class <blank-node> (<term>)
+ (value #:init-keyword #:value #:getter blank-node-value))
+
+(define-method (equal? (x <blank-node>) (y <blank-node>))
+ (equal? (iri-value x) (iri-value y)))
+
+(define-method (write (self <blank-node>) port)
+ (format port "<blank-node ~a>" (blank-node-value self)))
+
+(define (make-blank-node value)
+ (make <blank-node> #:value value))
diff --git a/schemantic/interop/guile-rdf.scm b/schemantic/interop/guile-rdf.scm
index 97ccfef..d31d949 100644
--- a/schemantic/interop/guile-rdf.scm
+++ b/schemantic/interop/guile-rdf.scm
@@ -4,6 +4,7 @@
(define-module (schemantic interop guile-rdf)
#:use-module (schemantic rdf)
+ #:use-module (schemantic blank-node)
#:use-module ((schemantic ns) #:select (xsd rdf))
#:use-module (rdf rdf)
@@ -36,6 +37,7 @@
(define (rdf-term->term term)
(cond
((string? term) (make-iri term))
+ ((integer? term) (make-blank-node term))
((rdf-literal? term) (rdf-literal->literal term))))
(define (rdf-triple->triple t)