Add some of missing type annotations and assertions master
authorSiraaj Khandkar <siraaj@khandkar.net>
Fri, 17 Dec 2021 22:35:39 +0000 (17:35 -0500)
committerSiraaj Khandkar <siraaj@khandkar.net>
Fri, 17 Dec 2021 22:35:39 +0000 (17:35 -0500)
tt.rkt

diff --git a/tt.rkt b/tt.rkt
index d11c151..e93c26f 100644 (file)
--- a/tt.rkt
+++ b/tt.rkt
       [((Peer #f _ _ _) (Peer #f _ _ _))                    p1] ; TODO update with most-common nick?
       [((Peer n1 _ _ _) (Peer #f _ _ _))                    p1]
       [((Peer #f _ _ _) (Peer n2 _ _ _))                    p2]))
       [((Peer #f _ _ _) (Peer #f _ _ _))                    p1] ; TODO update with most-common nick?
       [((Peer n1 _ _ _) (Peer #f _ _ _))                    p1]
       [((Peer #f _ _ _) (Peer n2 _ _ _))                    p2]))
+  (: merge-n (-> (Listof Peer) Peer))
   (define (merge-n peers)
     (match peers
       ['() (raise 'impossible)]
   (define (merge-n peers)
     (match peers
       ['() (raise 'impossible)]
 (define (dispatch command)
   (match command
     [(or "d" "download")
 (define (dispatch command)
   (match command
     [(or "d" "download")
-     (let ([num-workers 20] ; 20 was fastest out of the tried: 1, 5, 10, 20, 25, 30.
-           [timeout     10.0])
+     ; 20 was fastest out of the tried: 1, 5, 10, 20, 25, 30.
+     (let ([num-workers : Positive-Integer 20]
+           [timeout     : Positive-Flonum  10.0])
        (command-line
          #:program "tt download"
          #:once-each
          [("-j" "--jobs")
        (command-line
          #:program "tt download"
          #:once-each
          [("-j" "--jobs")
-          njobs "Number of concurrent jobs."
-          (set! num-workers (string->number njobs))]
+          positive-integer "Number of concurrent jobs."
+          (set! num-workers
+                (assert (string->number positive-integer)
+                        (conjoin exact-positive-integer?)))]
          [("-t" "--timeout")
          [("-t" "--timeout")
-          seconds "Timeout seconds per request."
-          (set! timeout (string->number seconds))]
+          positive-float "Timeout seconds per request."
+          (set! timeout
+                (assert (string->number positive-float)
+                        (conjoin positive? flonum?)))]
          #:args file-paths
          (download file-paths num-workers timeout)))]
     [(or "u" "upload")
          #:args file-paths
          (download file-paths num-workers timeout)))]
     [(or "u" "upload")
This page took 0.032832 seconds and 4 git commands to generate.