aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2024-09-05 23:13:27 +0100
committerArun Isaac2024-09-05 23:35:11 +0100
commitc28c7950c4894dbb7773c4d9a5e52d56c972e5f1 (patch)
tree216db47df705b25628ea1ac6c0ecde7e6c729ee8
parent8501b0319236c4e1c6223df7db3995507c830f48 (diff)
downloadravanan-c28c7950c4894dbb7773c4d9a5e52d56c972e5f1.tar.gz
ravanan-c28c7950c4894dbb7773c4d9a5e52d56c972e5f1.tar.lz
ravanan-c28c7950c4894dbb7773c4d9a5e52d56c972e5f1.zip
work: Match null type using pattern matching.
* ravanan/work/command-line-tool.scm (vector-empty?): Delete function. (match-type): Match null type using pattern matching.
-rw-r--r--ravanan/work/command-line-tool.scm11
1 files changed, 3 insertions, 8 deletions
diff --git a/ravanan/work/command-line-tool.scm b/ravanan/work/command-line-tool.scm
index 3af1dcf..ecf11b4 100644
--- a/ravanan/work/command-line-tool.scm
+++ b/ravanan/work/command-line-tool.scm
@@ -53,10 +53,6 @@ directory after THUNK returns."
thunk
(cut chdir original-current-directory))))
-(define (vector-empty? vec)
- "Return @code{#t} if @var{vec} is empty. Else, return @code{#f}."
- (zero? (vector-length vec)))
-
;; TODO: Support float types.
(define (object-type obj)
"Return the type of @var{obj}."
@@ -86,10 +82,9 @@ example, when @var{type} is a union type."
((eq? type 'Any)
(object-type obj))
((eq? type 'null)
- (and (or (eq? obj 'null)
- (and (vector? obj)
- (vector-empty? obj)))
- 'null))
+ (match obj
+ ((or 'null #()) 'null)
+ (_ #f)))
((array-type? type)
(and (every (cut match-type <> (array-type-subtype type))
(vector->list obj))