# Using different versions of the same dependency like Rust

**URL:** <https://discourse.haskell.org/t/using-different-versions-of-the-same-dependency-like-rust/14298>\
**Category:** Uncategorized\
**Created:** [June 19, 2026, 9:41pm UTC](https://discourse.haskell.org/t/using-different-versions-of-the-same-dependency-like-rust/14298 "2026-06-19T21:41:28Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaror](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/jaror/32/3271_2.png) [@jaror](https://discourse.haskell.org/u/jaror)\
**Post date:** [June 19, 2026, 9:41pm UTC](https://discourse.haskell.org/t/using-different-versions-of-the-same-dependency-like-rust/14298/1 "2026-06-19T21:41:28Z")

</div>

> [@\[RFC\] "http-types" breakage / additions / rework](https://discourse.haskell.org/t/rfc-http-types-breakage-additions-rework/14286/29):
>
> I think we could extend GHC’s `PackageImports` (or add a new extension) to be able to specify major versions and that would let GHC expose multiple versions of a package at once.

Yeah, that sounds like it could work. We can also copy cargo’s feature of renaming packages which solves the package imports problem. Imagined syntax:

```haskell
  build-deps: base
            , http-types ^>= 0.12.5 as old-http-types
            , http-types ^>= 1.0.0 as new-http-types

```

```haskell
import "old-http-types" Network.HTTP.Types as Old
import "new-http-types" Network.HTTP.Types as New

```

---

<div class="post-metadata">

**Author:** ![chrisdone](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/chrisdone/32/1408_2.png) [@chrisdone](https://discourse.haskell.org/u/chrisdone)\
**Post date:** [June 20, 2026, 6:51am UTC](https://discourse.haskell.org/t/using-different-versions-of-the-same-dependency-like-rust/14298/2 "2026-06-20T06:51:18Z")

</div>

That’s a really interesting idea I wasn’t aware of. 🤔 I’ll take a look at that in Cargo.

---

<div class="post-metadata">

**Author:** ![tristanC](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/tristanc/32/827_2.png) [@tristanC](https://discourse.haskell.org/u/tristanC)\
**Post date:** [June 20, 2026, 7:26am UTC](https://discourse.haskell.org/t/using-different-versions-of-the-same-dependency-like-rust/14298/3 "2026-06-20T07:26:59Z")

</div>

Assuming the plan is to get http-client/wai to adopt the new types, then it doesn’t sound like renaming the packages will help. In rust, this will result in a `there are multiple different versions of crate http-types in the dependency graph` error if the user doesn’t have the same http-types as its dependencies.

---

<div class="post-metadata">

**Author:** ![jaror](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/jaror/32/3271_2.png) [@jaror](https://discourse.haskell.org/u/jaror)\
**Post date:** [June 20, 2026, 10:03am UTC](https://discourse.haskell.org/t/using-different-versions-of-the-same-dependency-like-rust/14298/4 "2026-06-20T10:03:05Z")

</div>

I am not a Rust user, but all the information I can find online points to Rust allowing multiple different versions of the same crate in the dependency graph (e.g., [Articles - Stephen Coakley](https://stephencoakley.com/2019/04/24/how-rust-solved-dependency-hell)). Why wouldn’t that work in this case?

---

<div class="post-metadata">

**Author:** ![tristanC](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/tristanc/32/827_2.png) [@tristanC](https://discourse.haskell.org/u/tristanC)\
**Post date:** [June 20, 2026, 10:21am UTC](https://discourse.haskell.org/t/using-different-versions-of-the-same-dependency-like-rust/14298/5 "2026-06-20T10:21:19Z")

</div>

This is fine for internal libraries that are not re-exported. I assumed that a new http-types will come to end users through http-client or wai, which will requires using the same versions.

---

<div class="post-metadata">

**Author:** ![TeofilC](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/teofilc/32/3987_2.png) [@TeofilC](https://discourse.haskell.org/u/TeofilC)\
**Post date:** [June 20, 2026, 10:34am UTC](https://discourse.haskell.org/t/using-different-versions-of-the-same-dependency-like-rust/14298/6 "2026-06-20T10:34:17Z")

</div>

See also private dependencies which has a working prototype afaik. It’s a similar idea but rather than renaming, you can depend on a package and then guarantee that it’s not exposed in your public API, and then you can have multiple versions in the same build graph [Private dependencies · Issue #4035 · haskell/cabal · GitHub](https://github.com/haskell/cabal/issues/4035)

---

<div class="post-metadata">

**Author:** ![jaror](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/jaror/32/3271_2.png) [@jaror](https://discourse.haskell.org/u/jaror)\
**Post date:** [June 20, 2026, 10:37am UTC](https://discourse.haskell.org/t/using-different-versions-of-the-same-dependency-like-rust/14298/7 "2026-06-20T10:37:53Z")

</div>

I don’t think it has to be limited to private/internal libraries. The APIs will be incompatible, but one could write a compat package to map types from one version to the other, or it may just be that the particular parts of the API that are incompatible are not actually used together. Again, from all my internet searching that seems to be what Rust does (e.g., it produces errors like this: [https://stackoverflow.com/questions/78298605/rust-duplicate-dependencies](https://stackoverflow.com/questions/78298605/rust-duplicate-dependencies)).

---

<div class="post-metadata">

**Author:** ![andremarianiello](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/andremarianiello/32/4870_2.png) [@andremarianiello](https://discourse.haskell.org/u/andremarianiello)\
**Post date:** [June 20, 2026, 11:54am UTC](https://discourse.haskell.org/t/using-different-versions-of-the-same-dependency-like-rust/14298/8 "2026-06-20T11:54:56Z")

</div>

FYI Go also had a similar idea. You can depend on multiple major versions of the same library, but the there is no renaming at the library level - multiple different versions are denoted with `import.path/v1`, `import.path/v2`, etc.

---

<div class="post-metadata">

**Author:** ![dschrempf](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/dschrempf/32/1933_2.png) [@dschrempf](https://discourse.haskell.org/u/dschrempf)\
**Post date:** [June 20, 2026, 3:50pm UTC](https://discourse.haskell.org/t/using-different-versions-of-the-same-dependency-like-rust/14298/9 "2026-06-20T15:50:12Z")

</div>

As far as I understand, a lot of these problems (and many other problems) could be solved with a proper module system, right?

```haskell
module X (
  module Y as YVersion2
  ) where

import Y qualified as Y -- Pavkage version 2 of package with module Y in scope

```

Or at least, a proper module system could be part of the solution.

---

<div class="post-metadata">

**Author:** ![jeffstyr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/jeffstyr/32/2409_2.png) [@jeffstyr](https://discourse.haskell.org/u/jeffstyr)\
**Post date:** [June 20, 2026, 4:29pm UTC](https://discourse.haskell.org/t/using-different-versions-of-the-same-dependency-like-rust/14298/10 "2026-06-20T16:29:22Z")

</div>

If you are expected to be able to use two different version of the same library in one process, then I assume that means that the contents of the two are disjoint (or the build infrastructure makes them so, i.e. makes ModuleA become ModuleA.v1 and ModuleA.v2), so it seems much simpler for these to just be packaged as two separate libraries–that’s easy to understand, and no new tooling is required.

This is qualitatively different than just a major version change–a major version change means that things can break, but this means that de facto everything has changed.

Or to put it another way, if I can use multiple version of the same library side-by-side in an application, then that really strains the notion of it being “the same library”.

---

<div class="post-metadata">

**Author:** ![dschrempf](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/dschrempf/32/1933_2.png) [@dschrempf](https://discourse.haskell.org/u/dschrempf)\
**Post date:** [June 20, 2026, 6:14pm UTC](https://discourse.haskell.org/t/using-different-versions-of-the-same-dependency-like-rust/14298/11 "2026-06-20T18:14:36Z")

</div>

Well yes, I think thats my point. Having this module system is even more general. You can have two completely different packages but also one package with two different versions. As long as the import distinguishes between the two, and you can also export them under different namespaces.

---

<div class="post-metadata">

**Author:** ![jaror](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/jaror/32/3271_2.png) [@jaror](https://discourse.haskell.org/u/jaror)\
**Post date:** [June 20, 2026, 9:13pm UTC](https://discourse.haskell.org/t/using-different-versions-of-the-same-dependency-like-rust/14298/12 "2026-06-20T21:13:26Z")

</div>

The problem is that every breaking change currently requires lock-step upgrades throughout the ecosystem (See the previous thread linked at the top). Temporarily allowing two versions of the same package to be used enables more incremental upgrades.

---

<div class="post-metadata">

**Author:** ![hasufell](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/hasufell/32/1250_2.png) [@hasufell](https://discourse.haskell.org/u/hasufell)\
**Post date:** [June 20, 2026, 9:16pm UTC](https://discourse.haskell.org/t/using-different-versions-of-the-same-dependency-like-rust/14298/13 "2026-06-20T21:16:24Z")

</div>

I’m not convinced this is a good idea:

- can easily blow up binary size… now I have multiple versions of conduit and amazonka in my depgraph?
- makes it harder for the end user to constrain dependencies… I suspect we need to add syntax to cabal.project (constrain a dependency for the whole depgraph or only for a single package)
- probably makes solver errors even more peculiar
- mixing two versions of a package is a potential footgun

We’re trying to solve a social issue with a technical solution again is what I feel. Library maintainers should strive for portability (support multiple major versions of a dependency), but they also need to know which support window makes sense and what versions are actually supported upstream.

All of this requires some form of communication, either automated or coordinated.

Sadly, hackage is not really a collaboration platform.

---

<div class="post-metadata">

**Author:** ![jaror](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/jaror/32/3271_2.png) [@jaror](https://discourse.haskell.org/u/jaror)\
**Post date:** [June 20, 2026, 9:17pm UTC](https://discourse.haskell.org/t/using-different-versions-of-the-same-dependency-like-rust/14298/14 "2026-06-20T21:17:19Z")

</div>

I agree a better module system could be an alternative, but I don’t quite understand your code example. Can you explain it in a bit more detail?

---

<div class="post-metadata">

**Author:** ![chreekat](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/chreekat/32/2669_2.png) [@chreekat](https://discourse.haskell.org/u/chreekat)\
**Post date:** [June 25, 2026, 9:10am UTC](https://discourse.haskell.org/t/using-different-versions-of-the-same-dependency-like-rust/14298/15 "2026-06-25T09:10:40Z")

</div>

> [@jaror](#):
>
> Imagined syntax:
> 
> ```haskell
> build-deps: base
> , http-types ^>= 0.12.5 as old-http-types
> , http-types ^>= 1.0.0 as new-http-types
> 
> ```
> 
> ```haskell
> import "old-http-types" Network.HTTP.Types as Old
> import "new-http-types" Network.HTTP.Types as New
> 
> ```

Not to climb on to a dead horse, but doesn’t backpack/mixins already make this possible? Or does it get disallowed because they’re the same underlying package…

[Edit] seems it _is_ possible: [[RFC] "http-types" breakage / additions / rework - #51 by fendor](https://discourse.haskell.org/t/rfc-http-types-breakage-additions-rework/14286/51)

---

<div class="post-metadata">

**Author:** ![jaror](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/jaror/32/3271_2.png) [@jaror](https://discourse.haskell.org/u/jaror)\
**Post date:** [June 25, 2026, 2:29pm UTC](https://discourse.haskell.org/t/using-different-versions-of-the-same-dependency-like-rust/14298/16 "2026-06-25T14:29:02Z")

</div>

I’m not sure what PR @fendor is referring to. The private dependencies issue mentions mixins, but not how to use them to use the modules of two different versions of a dependency.

---

<div class="post-metadata">

**Author:** ![fendor](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/fendor/32/376_2.png) [@fendor](https://discourse.haskell.org/u/fendor)\
**Post date:** [June 25, 2026, 4:06pm UTC](https://discourse.haskell.org/t/using-different-versions-of-the-same-dependency-like-rust/14298/17 "2026-06-25T16:06:35Z")

</div>

I am referring to this cabal PR [feature: Private Dependencies by alt-romes · Pull Request #9743 · haskell/cabal · GitHub](https://github.com/haskell/cabal/pull/9743)

The solution is mixins, but with new scopes that allows to solve for private dependencies separately.

---

<div class="post-metadata">

**Author:** ![GunpowderGuy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/gunpowderguy/32/4164_2.png) [@GunpowderGuy](https://discourse.haskell.org/u/GunpowderGuy)\
**Post date:** [July 14, 2026, 3:13am UTC](https://discourse.haskell.org/t/using-different-versions-of-the-same-dependency-like-rust/14298/18 "2026-07-14T03:13:33Z")

</div>

I think we should think whether this is a good idea. Rust’s ability to import several versions of a single package provides an easy baseline. But also has problems. Like, multiple versions of a single package can in turn depend on multiple version of sub dependencies, which can result in an explosion of dependencies size

Something i have been exploring in idris2, is making new library versions backwards compatible with old ones. In idris2 you can make a multiple functions with the same name. If a single function needs to be updated to have more or different arguments , you can make a new one with the right ones, then deprecate the old one, remove it later down the line  
There are similar options for data types and whatnot

Haskell does not have function overloading, but it can be emulated by defining a typeclass to emulate a function. When needing to update the arguments of a function , you could instead define a typeclass to emulate an overloaded version of the function. Several versions later, after your library has removed the old function, the new one could be converted to a normal function . There are even options to smooth over this transition. Extreme edge cases would care whether something is a function or typeclass emulating a function, but this could be dealt with

---

<div class="post-metadata">

**Author:** ![Ambrose](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/ambrose/32/5672_2.png) [@Ambrose](https://discourse.haskell.org/u/Ambrose)\
**Post date:** [July 14, 2026, 4:15am UTC](https://discourse.haskell.org/t/using-different-versions-of-the-same-dependency-like-rust/14298/19 "2026-07-14T04:15:32Z")

</div>

the killer feature is if we could allow modules that haven’t changes between versions to be confluent

eh maybe we gotta go further and adopt protobuf esque rules around records

overall maybe we ban this and haskell companies focus on enabling their teams to depend on different versions of things and upgrade at their own pace

just cuz i want `foldMapA` doesn’t mean i should have to rebuild every time someone changes the internal utils package.

---

<div class="post-metadata">

**Author:** ![blamario](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/blamario/32/860_2.png) [@blamario](https://discourse.haskell.org/u/blamario)\
**Post date:** [July 17, 2026, 2:01pm UTC](https://discourse.haskell.org/t/using-different-versions-of-the-same-dependency-like-rust/14298/20 "2026-07-17T14:01:16Z")

</div>

Since we’re brainstorming already…

What if we took the existing `*-compat` semi-solution to the backward compatibility problem and made it an pervasive shim? Suppose there’s a dependency graph `{A -> {B, C}, {B -> D.1}, {C -> D.2}}` where D.1 and D.2 are two versions of D, and there’s a `D-1-shim` library that can act as a full replacement for D.1 while depending on D.2. Already today, we can use `cabal.project` to redirect all `D.1` dependencies to `D-1-shim` (not sure if possible to redirect to Hackage or only to its Git repo?). What’s missing is making this automatic by registering `D-1-shim` as a pervasive redirect, instead of every user having to discover the solution individually.
