A Functional Longing in my Heart

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).

[Listening to: Rose - A Perfect Circle - Mer De Noms (03:24)]

Related posts:

  1. Java’s Failure to be Lazy
  2. The Functional-Relational Impedance Match
  3. Java and Lazy Lists: I Stand Corrected (Sort Of)
  4. Functional Language Adoption
  5. Death to Arrays!
This entry was posted in To Be Categorized and tagged . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.
  • Categories