1

I have a list of optional strings in a typed racket program, i.e.

statements : (Listof (Option String))

I have another function that takes a (Listof String) and I know that unless an exception is raised, all of the strings in statements are present. I'd like to assert this fact, but I don't see how to assert a predicate like (listof? string?) for example to prove this to typed racket.

1 Answer 1

1

You can write one:

(define (listof-string? (l : (Listof Any)))
  (andmap string? l))

Then:

(define (bar (x : (Listof String)))
  x)

(define (foo (x : (Listof (Option String))))
  (bar (assert x listof-string?)))

will typecheck.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.