1

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?

Jaro
  • 3,799
  • 5
  • 31
  • 47

1 Answers1

3

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

(define (index->filter [pf : (IndexItemT -> boolean)] [index : IndexT]) : IndexT
  ....)
Alex Knauth
  • 8,133
  • 2
  • 16
  • 31