Skip to content

Commit

Permalink
Minor cleanup with strval-fn arg
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinqian00 committed Feb 9, 2024
1 parent 124a265 commit 584a803
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/main/com/yetanalytics/flint/axiom/impl.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
(defmacro extend-xsd-literal
"Macro that expands into a basic `extend-type` over the Literal protocol.
If `force-iri?` is true, then the resulting literal always has the XSD
datatype IRI appended; `strval-fn` overrides the default `.toString` call.
datatype IRI appended; `strval-fn` overrides the default call to `str`.
Without any kwargs, `(extend-xsd-literal t iri-suffix)` expands into:
```
Expand All @@ -76,15 +76,16 @@
([n] (p/-format-literal n {}))
([n opts] (fmt-impl/format-literal n opts)))
(-format-literal-strval
[n] (.toString n))
[n] (str n))
(-format-literal-lang-tag
[n] nil)
(-format-literal-url
([n] (p/-format-literal-url n {}))
([n opts] (fmt-impl/format-xsd-iri iri-suffix opts))))
```"
[t iri-suffix & {:keys [force-iri?
strval-fn]}]
strval-fn]
:or {strval-fn str}}]
`(extend-type ~t
p/Literal
(~'-valid-literal? [~'_] true)
Expand All @@ -95,9 +96,7 @@
`(fmt-impl/format-literal ~'n (assoc ~'opts :force-iri? true))
`(fmt-impl/format-literal ~'n ~'opts))))
(~'-format-literal-strval [~'n]
~(if (some? strval-fn)
`(~strval-fn ~'n)
`(.toString ~'n)))
(~strval-fn ~'n))
(~'-format-literal-lang-tag [~'_] nil)
(~'-format-literal-url
([~'n] (p/-format-literal-url ~'n {}))
Expand Down

0 comments on commit 584a803

Please sign in to comment.