Fix representation of Option

This commit is contained in:
Fabio Labella 2023-02-13 14:08:39 +00:00
parent b7d8eb0802
commit 774addbab5
2 changed files with 7 additions and 8 deletions

View File

@ -21,10 +21,10 @@
(import (rnrs))
; Option a
(define none (cons 0 ()))
(define none `(0))
; a -> Option a
(define (some a) (cons 1 a))
(define (some a) `(1 ,a))
; Option a -> Bool
(define (some? option) (eq? 1 (car option)))
@ -36,7 +36,7 @@
(define (option-get option)
(if
(some? option)
(cdr option)
(car (cdr option))
(raise "Cannot get the value of an empty option ")))
; TODO this might be reduntant, #<void> works

View File

@ -5,8 +5,8 @@ concurrency.tests = Tests.main do
!casTest
!promiseSequentialTest
!promiseConcurrentTest
-- !forkKillTest
-- !tryEvalForkTest
-- !forkKillTest
-- !tryEvalForkTest
!fullTest
simpleRefTest = do
@ -55,9 +55,8 @@ promiseSequentialTest = do
Promise.write_ p 1
v2 = read p
checkEqual "Promise can only be written to once" v2 v1
-- TODO fix bug in boot.ss here
-- v3 = Promise.tryRead p
-- checkEqual "Once the Promise is full, tryRead is the same as read" v3 (Some v2)
v3 = Promise.tryRead p
checkEqual "Once the Promise is full, tryRead is the same as read" v3 (Some v2)
millis = 1000
sleep_ n = unsafeRun! do sleep n