www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

lin+chan-tests.rkt (527B)


      1 #lang s-exp turnstile/examples/linear/lin+chan
      2 (require turnstile/rackunit-typechecking)
      3 
      4 (check-type
      5  (let* ([(c c-out) (make-channel {Int})])
      6    (thread (λ () (channel-put c-out 5)))
      7    (thread (λ () (channel-put c-out 4)))
      8    (let* ([(c1 x) (channel-get c)]
      9           [(c2 y) (channel-get c1)])
     10      (drop c2)
     11      (+ x y)))
     12  : Int -> 9)
     13 
     14 (typecheck-fail
     15  (let* ([(c-in c-out) (make-channel {String})])
     16    (thread (λ () (channel-get c-in)))
     17    (channel-get c-in))
     18  #:with-msg "c-in: linear variable used more than once")