Is it possible statically to check how composable a function is? [edit: possibly how "splittable" a function is instead]

Code duplication detection might actually do what I want here… If it’s fuzzy/disregards function and variable naming.

OK, so I found it, at last. :slight_smile: Correct technical term might be “automatic procedure extraction”. Here’s on PhD work on it and code duplication (PDF): https://research.cs.wisc.edu/areas/pl/theses/raghavan.thesis.pdf

So, you could argue that a function is “splittable” iff the procedure extraction algorithm can extract something from it. Then of course, just as with code duplication detection, the question is how aggressively to set the thresholds/tune the algorithm.

1 Like

Still thinking about this one. I had this formulation of “functional core, imperative shell”:

All code should either:

  1. Organize composable parts; or
  2. Be a composable part

I wonder if 2) should rather be, “be a smallest composable part”.

Edit, factoring out side-effects with monads or tagless-final, would it increase composability?

Oh yeah, being splittable implies not being the smallest composable part.