Oh, hi!
yes, that’s me. I don’t think “getting there” first is an accomplishment really, and I am only happy to see someone working on the same problem. I have actually started working on PubGrub, only one day a week, in June. The commits only reach September because at some point I decided to start from scratch.
This was the first project where I made serious use of Claude from the start, and I have to say it had turned in a long journey. I also used it to understand the algorithm, and write tests but also to understand the more general context of answer set programming and CDNL<sup>[1]</sup>. I wasn’t very familiar with the subject and I don’t think I could have pulled this off without the assistance.
@brandonchinn178 I love how crystal clear your implementation is, but I think we have solved quite different problems. From the start, I wanted to see if PubGrub could be used to do the same dependency-version solving that cabal-install does, and, in that case, whether it could offer better failure messages. To be able to compare apples to apples, my implementation had to at least account for pre-existing vs source packages and flags. Everything I could find about PubGrub only used version ranges, so I was in uncharted territory.
Dealing with pre-existing/source packages I thought wasn’t going to be too hard in theory since predicates over a sum-type are products of predicates (e.g. Either a b -> Bool ~ (a -> Bool, b -> Bool); but choosing the right representation for the terms wasn’t obvious. The dependencies of pre-installed packages are exact and do not use versions, so it’s easier to model a version range directly as a set.
Dealing with flags instead was a huge problem for me, and I am still not quite sure if I got it right<sup>[2]</sup>. The problem was how to represent flags. They can be separate variables or they can be buried into the version variable. If they are separate variables, they cannot be completely independent from the version, because tasty +unix does not quite make sense if the chosen version of tasty does not declare the unix flag. If they are buried into the version, then ordinary version ranges are no longer expressive enough, and a naive extension is not closed under the set operations required by PubGrub. I must have spent two months on this.
Eventually I decided that I could not work to understand PubGrub and to extend it at the same time so I decided to split the general algorithm from anything that has to do with cabal. In my pubgrub the solver is polymorphic over a Domain v, whose variables have type in ValueOf v, and whose sets ( SetOf v) are constrained to have a set algebra SetOps. The specialisation of this to cabal packages lives in a different package pubgrub-cabal.
If you are keen to know how pubgrub compares to cabal-install’s solver, I invite you to look at the benchmark and the showcase. This is an example:
No solution for aeson ==2.3.1.0 and hlint ==3.10: base is
pinned to 4.21.2.0 (installed).
No version of deriving-aeson suits hlint >=3.4.1 unless aeson >=1.3 && <2.3.
Because deriving-aeson >=0.2 && <0.2.4 depends on aeson >=1.3 && <1.5 and
deriving-aeson >=0.2.4 && <0.2.5 depends on aeson >=1.4.7.0 && <1.5,
deriving-aeson >=0.2 && <0.2.5 requires aeson >=1.3 && <1.5.
And because deriving-aeson >=0.2.5 && <0.2.7 depends on aeson >=1.4.7.0 && <1.6
and deriving-aeson >=0.2.7 && <0.2.8 depends on base >=4.12 && <4.16,
deriving-aeson >=0.2 && <0.2.8 requires aeson >=1.3 && <1.6 or
base >=4.12 && <4.16.
And because deriving-aeson >=0.2.8 && <0.2.9 depends on aeson >=1.4.7.0 && <2.2
and base is pinned to 4.21.2.0 (installed), deriving-aeson >=0.2 && <0.2.9
requires aeson >=1.3 && <2.2.
And because deriving-aeson >=0.2.9 depends on aeson >=1.4.7.0 && <2.3 and
hlint >=3.4.1 depends on deriving-aeson >=0.2, hlint >=3.4.1 requires
aeson >=1.3 && <2.3.
So, because aeson ==2.3.1.0 and hlint ==3.10 are requested, version solving
failed.
I took a break but I am not quite done with the package I think.
Thanks @hasufell, I will not be discouraged. @brandonchinn178 has been very gentle with his words but I wasn’t quite expecting the first discussion about my package to be on “whether we should ignore it”. With respect to the documentation, the Haskell community has always been so welcoming of packages with no documentation, that it surprises me a little to receive criticism when my package even has a tutorial . Jokes aside, I know the documentation is not great, I still have work to do to improve it.
@brandonchinn178 I would love to exchange ideas on PubGrub. It makes me happy to read that you intend to use it. Please report any issue or feedback! Also don’t forget the code is also yours under the BSD-3 license. Read it, copy it, steal it. I genuinely hope you can get some value out of it in one way or another.