countvajhula / social-contract

High-level, composable syntax for describing contracts in Racket.
3 stars 1 forks source link

Generalize map/c and filter/c to functors #4

Open countvajhula opened 3 years ago

countvajhula commented 3 years ago

Map and filter notions could apply to types that aren't sequences. E.g. generator-map should be able to use map/c but it can't at the moment.

map/c should be generalized to accept a "functor" parameter in some way (without necessarily requiring a functor interface) so that it needn't be a sequence.

countvajhula commented 3 years ago

generator-map could now be expressed as (self-map/c generator? (head function/c)).

It would still be useful if we could use something like (map/c #:container generatorof integer? string?), which would tell us that the input generator has integer values and the output one has string values, but in order to do this we'd likely need such types to provide their own container forms, e.g. generatorof.