From c28c7950c4894dbb7773c4d9a5e52d56c972e5f1 Mon Sep 17 00:00:00 2001
From: Arun Isaac
Date: Thu, 5 Sep 2024 23:13:27 +0100
Subject: 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.
---
 ravanan/work/command-line-tool.scm | 11 +++--------
 1 file 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))
-- 
cgit v1.2.3