Haskell World logo Haskell WorldWrite code, build worlds
Open Source

How to Vet a Haskell Dependency Before You Add It

A student in my second year class added a JSON library to her project because it was the first result she found and the README example compiled on the first try. Four months later the project would not build on the lab machines.

A laptop on a wooden desk showing a package repository file list beside a notebook with a handwritten dependency checklist

A student in my second year class added a JSON library to her project because it was the first result she found and the README example compiled on the first try. Four months later the project would not build on the lab machines. The library had never been tested against the GHC version we upgraded to over the break, and its last real commit was from 2022.

Nothing malicious happened there, and nobody wrote bad code. A library simply stopped being maintained, and nothing on the page she read said so. Catching that in advance takes about twenty minutes, and almost all of it is reading rather than running anything.

What a Hackage page tells you, and what it leaves out

The package page gives you a version number, an upload date, dependency bounds, the license field, and a module list. All of that is true and none of it answers the question you actually have. Three things decide whether you will regret a dependency in a year: whether anyone still answers issues, how wide the library pulls in its own dependencies, and whether the author treats a breaking change as a major version bump or as a quiet Tuesday.

Upload date is the field people misread most. A package uploaded three weeks ago can be thoroughly abandoned, because maintainers and Hackage trustees often push a metadata only revision that relaxes upper bounds so other people's builds stop failing. That bumps the revision without touching a line of code. Click into the changelog instead. If the last substantive entry is from two years ago and everything since has been bound relaxation, you are looking at a library kept breathing by whoever got annoyed first.

The license field deserves one extra click as well. It shows a short identifier like BSD-3-Clause, but the identifier is self reported by the author and occasionally disagrees with the LICENSE file in the repository. If your project has any commercial future, read the file, not the label. Our notes on choosing an open source license for a Haskell library explain which differences actually bite.

The twenty minute source read

I give my students this sequence before their first import, and I still run it myself on anything that will end up in a build I have to maintain. It assumes nothing about Haskell beyond being able to read a type signature.

  1. Open the repository, not the package page. The repository is where the evidence lives. If the source link is dead or points at a personal server that times out, stop here. A library you cannot read is a library you cannot fix.
  2. Sort the issues by recent activity, not by count. Forty open issues with maintainer replies in the last month is a healthy project. Six open issues that have all sat untouched since 2023 is not. Read two closed issues too, because how someone closes a report tells you more than how many they have.
  3. Count the dependencies in the cabal file. Open the build-depends stanza of the library target. A parsing library that needs base, bytestring, containers, and text is cheap. One that needs lens, conduit, and a web framework will drag 60 extra packages into your build plan and roughly double your cold compile time.
  4. Read 50 lines from the middle of the largest module. Not the top, where everybody is on their best behaviour. The middle is where you find out whether the author writes for a reader or for the compiler.
  5. Look at the test directory before the documentation. A test suite with property tests against real edge cases is the strongest signal a library gives you. Fifteen golden files and no properties is weaker but acceptable. An empty test stanza with a main that prints success is a warning, and I have seen it more than once on packages with thousands of downloads.
  6. Compare the changelog against the version numbers. If a function signature changed in 0.4.2, the author is not following the package versioning policy, which means your bounds will not protect you. Our piece on Haskell PVP versioning for maintainers covers what the numbers are supposed to promise.

The last time I ran this on a candidate library, step three ended the discussion in four minutes. The package did one small job, text normalisation, and depended on a full HTTP client because a single helper function fetched a Unicode table at runtime. We copied the 30 lines we needed and moved on.

What the middle of a module tells you

Read for two things. Are the exported functions total, meaning do they return Maybe or Either instead of calling error on bad input? And are the internal helpers named after what they do or after what they are? A module full of go, go', and step is not automatically bad Haskell, that is idiomatic for tight recursion, but when every function in a 400 line file is named that way you will not be able to navigate it under pressure at 11pm.

I also check whether the author uses partial functions from Prelude. One head call on a list the author knows is non empty is fine. Nine of them scattered through a parser means your production crash will arrive as a bare Prelude.head exception with no context about which input caused it.

The standard advice is to take the package with the most downloads. I tell students to ignore download counts almost entirely, and I will defend that.

Download numbers on Hackage measure age and transitive pull, not quality. A library from 2014 that one popular framework depends on will outrank a better library released last year by two orders of magnitude, forever. Worse, the count includes every CI run of every project that already depends on it, so the number partly measures how often other people's builds run.

The figure worth looking at is reverse dependencies, and specifically whether any of them are packages you recognise and whether those packages upgraded to the current major version. A library with 12 reverse dependencies where eight are on the latest major version is in better shape than one with 300 reverse dependencies all pinned below a version released three years ago. That pattern usually means the new major version broke something nobody wanted to deal with.

There is a second half to this. A small single purpose library maintained by one person who replies within a week is a safer bet than a popular library whose maintainer last commented in 2023, as long as you could maintain a fork yourself if you had to. That last clause is the whole condition. If the library implements a protocol you do not understand, the responsive single maintainer is a risk, not a comfort, because you cannot take over. For libraries in that category I accept the dormant popular option and plan for the migration. There are a few genuinely load bearing packages in the ecosystem that everybody uses, and the curated list of open source Haskell libraries in active use is a reasonable place to start before you go looking further afield.

When copying the function beats adding the dependency

If you need one function, under roughly 50 lines, with no state and no platform specific behaviour, copy it. Keep the author's copyright header, note the source and the commit hash in a comment above it, and check that the license permits it, which BSD and MIT both do. You now own 50 lines you understand instead of a version constraint you will fight during every GHC upgrade.

The line I draw is anything involving cryptography, time zones, character encodings, or network protocols. Those look small and are not. Time zone handling in particular looks like arithmetic until a government changes its rules in March and your copied function keeps the old offset while the maintained library shipped an update within a week.

When you do add the dependency, write down what you checked. I keep a plain text file in the repository root with one line per dependency: the version, the date I vetted it, and the single reason I chose it over the alternative. It takes thirty seconds and it is the only thing that makes the question answerable a year later when somebody asks why the project uses this parser. If the answer turns out to be that the maintainer has vanished, the path forward is documented in our guide to taking over an abandoned Haskell package.

FAQ

How can I tell whether a Haskell library is abandoned or just finished?

Look at whether the maintainer responds, not whether they commit. Some libraries are genuinely done: a small, correct package solving a fixed problem needs no changes for years. The test is whether an issue filed six months ago got a reply. A finished library has a maintainer who answers and says no changes needed. An abandoned one has silence.

Does a low download count mean a library is risky?

Not by itself, though it does mean fewer people have hit the bugs before you. Treat it as a reason to read the test suite more carefully rather than a reason to reject. New libraries by known ecosystem contributors often have low counts for their first year and are perfectly sound.

Should I pin exact versions of every dependency?

Pin for applications, use ranges for libraries. An application wants a freeze file so your build is reproducible six months from now. A library that pins exact versions becomes impossible to include in anyone else's build plan, which is the fastest way to make your package unusable.

How much time is reasonable to spend on this?

Twenty minutes for anything central to the project, two minutes for a build tool or test helper that you could swap out in an afternoon. The cost of a bad dependency scales with how hard it is to remove, so spend your reading time accordingly.

AS
Adil Sato

Adil Sato teaches programming concepts at a community college and writes online guides for the questions students ask most in the second week of class, not the first. His focus is on making type systems, monads, and functional patterns understandable without reducing them to metaphors that break down the moment you try to use them for real work.

More posts by Adil

More in Open Source

01doorganico 084goad 3hot8 4465456 after5internprogram ahandfulofblessings ahmadpc ahomcybersecurity allodialresources annodex antiquesandperiodcollectibles aotc asianworldkashmir beedlectrics bloggertemplatefree bluefeatheragency bodyweightsolution campaign08blog carfixadvisor catstreetcollective cbstvsports cnfanspurchasing committeeof500yearsofdignityandresistance covertopsdjs cs-kaiyuangame cuestacomunicaciontotal cxoutlet dancebetgame deskgearhub destinyvillastay detectmagazine di33 diamondsteelbuildings donmo dyanadropship emarsysfinance emimattl escapechan eskitarih evautoplay everythingweddings-orlando farmzone feedviewerapp foxstudiosscratch gamevui123 gleasongrade greetingsday hacklabasu iw-kaiyun jagoanproperti jilidskripsi joltbusinessfinance juegodepokergratis juegospucca kaeru-festival latestmehndidesigns lestanzediottaviano litemagazines localcommunityhero lustrsazan mariashebets menswheels newwebstechs1 nikkit ootheday oxigenvpn plurfitness prefetial probudgetcarpetcleaning psychicmrsmartin pyaten qvantor rejoignezlogis rexzbot riselayouts ruchin rwxqsgd5 sakaltime shibiaowang shop-bot skrtips spotlesshaven strcoding tetapatrium topselller uneplanteartificielle vipertechcr webtech1223411 wo-kygaming yamaha-mekar yeknava yoybuysheets zenunwa yamaha-mekar jilidskripsi ankertoto ankertoto ankertoto