brownplt/pyret-lang — pull request #218 by Ericson2314 (2014-06-24 03:35:25+00:00)
Title: Add Pair to base, map methods to Pair and Either

A pair data type is defined in Desugar and Type-Checker, thus beginning to be factoring out somewhere.

Given the simplicity generality of Pair, it seemed potentially worthy to go in the std library, rounding out Either and Option.

I figure the most controversial part of this will be the identifier choices. `Pair` was the name chosen by whoever defined it in `desugar.arr`, and is more friendly than `Product` for students with less math background. I like `map-*` as the operation is clearly a mapping, and the use `map` in the name should set students on the right track in identifying list-map-like combinatorial and seeing the commonalities.

I don't like `bi-map` very much however. I might have picked `map2` but that would recall the `map2` in `List`, which get's the "2" in it's name for very different reasons. Misleading students into thinking that there was deeper connection between the two `map2`s would certainly be counterproductive.

Eventually it would be nice to define `map-*` to by polymorphic on all types with a proper `bi-map` method, but as I am not sure how the type system will eventually work with such definitions, and loath to make a 2nd new file, I figure such changes better wait for a bigger overhaul of the standard library.

If this is OK'd, I'll clean up the exports to not export identity (or move it it somewhere else), and add documentation.