plai-typed : how to define function type?

210 Views Asked by At

I'm playing with plai-type language. I have a function which should consume a predicate function (returning true or false) and a list of items.

My code looks like:

(define-type-alias IndexT (listof IndexItemT))

(define (index->filter pf [index : IndexT]) : IndexT
  (filter pf index))

and I'd like to express that pf can consume value of type IndexItemT and return bool.

Is it possible to write it in plai-typed lang? If yes, how?

1

There are 1 best solutions below

0
On BEST ANSWER

Yes. You can use -> type constructor to express the type of pf.

(define (index->filter [pf : (IndexItemT -> boolean)] [index : IndexT]) : IndexT
  ....)