I’m in Java right now, and I so want to be in Ocaml. The reason is because I’m working with filtering, partitioning, and folding a collection of objects, but the natural way to write this (for me, anyway) is being faught by the type system. I’ve already written “select”, “fold”, and “partition” in Java, so at least I have those. I’m leveraging Jakarta-Common’s “functor” package and the wonderfully named BeanPropertyValueEqualsPredicate, which don’t give me the quasi-goodness of generics, but it’s at least a start. I really should be using Trove’s functional capabilities, but it’d be work to introduce Trove into this project at this point.
Even with the functor library, here’s what I’m missing which is type checked and easy in Ocaml:
1) A function that is given an object, and applies a given field of that object to another function. The reason I want this is because I’m often saying “Filter out all the foo objects whose foo.bar returns false on baz.”, with “bar” and “baz” being free variables.
2) A function that takes a collection of objects, and returns a map of the objects partitioned by a field. This might exist in Jakarta-Common’s BeanUtils, but I can’t find it (try for yourself).
One Trackback
The “Hole in the middle” pattern…
Surfing on Chia’s Functional Longing article, I wanted to post an experience I had recently, working on some C# code. The point of this blog entry is that it’s not what a programming language make possible, it’s what a programming la…