[Haskell-cafe] where to put general-purpose utility functions
jmg at gaillourdet.net
Mon Jan 23 11:36:15 CET 2012
On 21.01.2012, at 21:20, Joey Hess wrote:
> My problem now is that as I start new projects, I want to have my haskell
> utility functions available, and copying them around is not ideal. So, put
> them on hackage. But where, exactly? It already has several grab bag utility
> libraries. The only one with much traction is MissingH. Using the others
> makes a program have an unusual dependency, which while only a cabal
> install away, would make work for distributions that want to package the
> program. I've ruled out using a couple on that basis. Doesn't encourage me
> to add another one.
> My 2000+ lines of reusable code are a grab-bag of generic utility
> functions. Looking them over (see Appendix), I could try to get portions
> into existing libraries on hackage, but it's unlikely I'd find a home
> for most of them, so I'm still left with this problem of what to do.
> I wonder if the model used for xmonad-contrib, of a big library package,
> that is very open to additions from contributors, would be helpful here?
> John, any interest in moving MissingH in this direction? I get the
> impression it's not otherwise changing much lately, and parts of it are
> becoming naturally obsolete, maybe this could inject some life into it.
> Any other thoughts you have on grab-bag utility libraries on hackage
> also appreciated.
Personally, I've always been avoiding those grab-bags of functionality like MissingH and other libraries. Not because I think they don't provide anything useful. But, because their level of maintenance is not clear to me. A rather large library of utility functions tends to need many dependencies on other hackage packages. That makes the question of maintenance even more important.
As others have pointed out some of your functions may already exist in some widely used package. And other might be easy to be replaced by some idiom. Don't underestimate the depth of Haskell and it's well thought libraries. I am regularly amazed by finding some new way to combine seemingly trivial functions to do some non-trivial task. Every time that happens I can remove some of my utility functions.
Therefore, I would reuse my own collection of utility code as a separate repository to be included as a sub repository in other projects. Mercurial and Git support that very well, I am not sure about darcs' support for that. This approach allows you to avoid copy&paste reuse and it allows you to evolve your personal collection at your speed without worrying for backwards compatibility or API changes.
Publishing a library on hackage comes --- at least in an ideal world --- with some commitment to document it, keep it compiling and working with a set of compiler and library permutations, fix bugs and so on. In short it comes with a commitment to maintain it. At least for some time. If you would just like to drop some pile of code in hope someone will find it useful. Do that, but perhaps there might be better places for that than hackage.
More information about the Haskell-Cafe