Jaro
Jaro

Reputation: 3887

plai-typed : how to define function type?

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?

Upvotes: 1

Views: 217

Answers (1)

Alex Knauth
Alex Knauth

Reputation: 8373

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

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

Upvotes: 3

Related Questions