Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing types for fx+/wraparound and friends #1309

Open
LiberalArtist opened this issue Feb 15, 2023 · 0 comments
Open

Missing types for fx+/wraparound and friends #1309

LiberalArtist opened this issue Feb 15, 2023 · 0 comments

Comments

@LiberalArtist
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant