Add NonemptyListof.

This commit is contained in:
Sergiu Ivanov 2023-08-09 23:15:33 +02:00
parent 064169f0b6
commit c944841dc6
2 changed files with 9 additions and 1 deletions

View file

@ -45,6 +45,12 @@ the variables.
} }
@defform[(NonemptyListof a)]{
A @racket[(Listof a)] which contains at least one element.
}
@section{Type utilities} @section{Type utilities}
Typed Racket's @racket[cast] should only be used as a last resort, because it Typed Racket's @racket[cast] should only be used as a last resort, because it

View file

@ -4,7 +4,7 @@
(for-syntax syntax/parse racket/syntax racket/list)) (for-syntax syntax/parse racket/syntax racket/list))
(provide (provide
Variable VariableMapping GeneralPair Variable VariableMapping GeneralPair NonemptyListof
assert-type for/first/typed for*/first/typed define/abstract/error assert-type for/first/typed for*/first/typed define/abstract/error
relax-arg-type/any relax-arg-type/any
@ -28,6 +28,8 @@
(define-type Variable Symbol) (define-type Variable Symbol)
(define-type (VariableMapping A) (Immutable-HashTable Variable A)) (define-type (VariableMapping A) (Immutable-HashTable Variable A))
(define-type (NonemptyListof a) (Pairof a (Listof a)))
(define-syntax-parse-rule (assert-type e:expr type:expr) (define-syntax-parse-rule (assert-type e:expr type:expr)
(assert e (make-predicate type))) (assert e (make-predicate type)))