@@ -69,8 +69,9 @@ primitives = map (Data.Bifunctor.second SPrimativeProc)
69
69
, (" cdr" , cdr)
70
70
, (" cons" , cons)
71
71
72
- , (" eqv ?" , eqv )
72
+ , (" wya/eq ?" , wyaEq )
73
73
, (" eq?" , eq)
74
+ , (" eqv?" , eqv)
74
75
, (" equal?" , equal)
75
76
76
77
, (" num-args-error" , numArgsError)
@@ -329,19 +330,20 @@ cons args = throwError $ NumArgs 2 args
329
330
-- equality
330
331
-----------------------------------------
331
332
332
- -- ... a most unpermissive eq?
333
- -- TODO: oops, this isn't spec-compliant...
334
- _eq :: SchemeVal -> SchemeVal -> Bool
335
- _eq a b = case (a, b) of
333
+ -- a most discerning eq?... non-standard
334
+ -- if `wya/id` existed, would be same as
335
+ -- (define (wya/eq? a b) (= (wya/id a) (wya/id b)))
336
+ _wyaEq :: SchemeVal -> SchemeVal -> Bool
337
+ _wyaEq a b = case (a, b) of
336
338
(SchemeVal (Just tagA) _, SchemeVal (Just tagB) _) -> tagA == tagB
337
339
_ -> False
338
340
339
- eq :: [SchemeVal ] -> SchemeValOrError
340
- eq [a, b] = return $ SBool $ _eq a b
341
- eq args = throwError $ NumArgs 2 args
341
+ wyaEq :: [SchemeVal ] -> SchemeValOrError
342
+ wyaEq [a, b] = return $ SBool $ _wyaEq a b
343
+ wyaEq args = throwError $ NumArgs 2 args
342
344
343
- _eqv :: SchemeVal -> SchemeVal -> Bool
344
- _eqv a b = case (a, b) of
345
+ _eq :: SchemeVal -> SchemeVal -> Bool
346
+ _eq a b = case (a, b) of
345
347
(SChar a', SChar b') -> a' == b'
346
348
(SString a', SString b') -> a' == b'
347
349
(SSymbol a', SSymbol b') -> a' == b'
@@ -354,12 +356,20 @@ _eqv a b = case (a, b) of
354
356
(SComplex a'', SComplex b'') -> a'' == b''
355
357
(_, _) -> False
356
358
(SList [] , SList [] ) -> True
357
- (a', b') -> _eq a' b'
359
+ (a', b') -> _wyaEq a' b'
360
+
361
+ eq :: [SchemeVal ] -> SchemeValOrError
362
+ eq [a, b] = return $ SBool $ _eq a b
363
+ eq args = throwError $ NumArgs 2 args
364
+
358
365
366
+ -- the spec permits (define eqv? eqv?)
367
+ _eqv :: SchemeVal -> SchemeVal -> Bool
368
+ _eqv = _eq
359
369
360
370
eqv :: [SchemeVal ] -> SchemeValOrError
361
- eqv [a, b] = return $ SBool $ _eqv a b
362
- eqv args = throwError $ NumArgs 2 args
371
+ eqv = eq
372
+
363
373
364
374
_equal :: SchemeVal -> SchemeVal -> Bool
365
375
_equal a b = case (a, b) of
0 commit comments