typed-racket
typed-racket copied to clipboard
Missing types for `fx+/wraparound` and friends
Here's a motivating example, inspired by the discussion on Discord:
#lang typed/racket/base
(: fib (-> Nonnegative-Fixnum Nonnegative-Fixnum))
(define (fib n)
(let loop ([n : Nonnegative-Fixnum n]
[prev : Nonnegative-Fixnum 0]
[cur : Nonnegative-Fixnum 1])
(cond
[(= n 0)
prev]
[(= n 1)
cur]
[else
(loop (- n 1)
cur
(abs (fx+/wraparound prev cur)))])))
;; Shouldn't need this!
(require typed/racket/unsafe)
(unsafe-require/typed
racket/unsafe/ops
[(unsafe-fxabs abs) (-> Fixnum Nonnegative-Fixnum)]
[(unsafe-fx+/wraparound fx+/wraparound) (-> Fixnum Fixnum Fixnum)])
Maybe there should be a CI test for certain modules that all of their functions have type information?