Is there a type-safe list-ref function provided by Typed Racket?
The list-ref function appears to throw an error if you try to access an index that is out of bounds:
> (require typed/racket)
> (list-ref '(1 2 3) 100)
; list-ref: index too large for list
; index: 100
; in: '(1 2 3)
It makes sense that list-ref returns an error given its type:
> list-ref
- : (All (a) (-> (Listof a) Integer a))
I would imagine that a type-safe version would have a type like the following:
(: list-ref (All (a) (-> (Listof a) Integer (Option a)))
If this type-safe list-ref function is provided somewhere from Typed Racket, how would I have gone about finding it?
If this type-safe list-ref function doesn't exist, then why not? It seems like this function would be generally useful.