Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Haskell: haskell.lib.composable init and switch #142940

Merged

Conversation

expipiplus1
Copy link
Contributor

@expipiplus1 expipiplus1 commented Oct 26, 2021

Supersedes #100732

Basically, makes the drv argument to everything in haskell.lib the last argument. Some discussion in the above PR

@Gabriella439
Copy link
Contributor

I think my main suggestion would be to split this into at least two pull requests:

  • One pull request to introduce the composable versions of the functions
  • Another pull request to switch existing uses over to the new version

@Profpatsch
Copy link
Member

Also take into account lib.pipe, which makes code like this possible:

lib.pipe drv [
 hlib.doCheck
 (drv: hlib.removeConfigureFlag drv "flag")
 …
]

@Profpatsch
Copy link
Member

This will make the nesting problem cause of the flipped arguments less problematic.

@maralorn
Copy link
Member

I think that we all agree that this is the right way to go. The question is can we go in this direction and if so, how? Infinitely maintaining two versions of the library would be very unsatisfying.

@Profpatsch
Copy link
Member

I don’t think it’s so big an annoyance that breaking all backwards compat is justified, and maybe not even big enough to split the ecosystem even further? I don’t see any good way to solve this initial misdesign now that so much code depends on it :(

@maralorn
Copy link
Member

Well in a world where markUnbroken and unmarkBroken both already exist, I think there is room to argue that a few more functions won’t really hurt?

@expipiplus1 expipiplus1 mentioned this pull request Nov 5, 2021
12 tasks
@expipiplus1
Copy link
Contributor Author

expipiplus1 commented Nov 5, 2021

I think my main suggestion would be to split this into at least two pull requests:

Done: #144705

This will make the nesting problem cause of the flipped arguments less problematic.

Was this referring to the use of lib.pipe to make using the current functions nicer, or the fact that this change itself solves the nasty nesting problem? I agree with both, but the neatest solution overall IMO is lib.pipe with these flipped functions.

@expipiplus1 expipiplus1 force-pushed the haskell-lib-composable branch from 3ba7d3b to 9d6968b Compare November 5, 2021 06:38
@expipiplus1 expipiplus1 changed the title Haskell: Init haskell.lib.composable Haskell: haskell.lib.composable init and switch Nov 5, 2021
@expipiplus1
Copy link
Contributor Author

expipiplus1 commented Nov 5, 2021

hahah, I just noticed that lib.pipe itself has the weird argument order where the element being transformed comes first...

edit, this is actually explained in the commit message for pipe:

`pipe` is a useful operator for creating pipelines of functions.

It works around the usual problem of e.g. string operations becoming
deeply nested functions.

In principle, there are four different ways this function could be
written:

pipe val [ f1 .. fn ]
pipe val [ fn .. f1 ]
compose [ f1 .. fn ] val
compose [ fn .. f1 ] val

The third and fourth form mirror composition of functions, they would
be the same as e.g. `(f1 << f2 << f3 .. << fn) val`.
However, it is not clear which direction the list should have (as one
can see in the second form, which is the most absurd.

In order not to confuse users, we decide for the most “intuitive”
form, which mirrors the way unix pipes work (thus the name `pipe`).
The flow of data goes from left to right.

@expipiplus1 expipiplus1 force-pushed the haskell-lib-composable branch from 9d6968b to 0ecc307 Compare November 5, 2021 06:51
@expipiplus1
Copy link
Contributor Author

I don’t think it’s so big an annoyance that breaking all backwards compat is justified, and maybe not even big enough to split the ecosystem even further? I don’t see any good way to solve this initial misdesign now that so much code depends on it :(

well, the previous functions are still available under .lib. I definitely prefer the case of having both sets in nixpkgs than just the old ones. In terms of eventually removing and replacing the old set (i.e. having haskell.lib = haskell.lib.composable) maybe that's something we can tackle down the line, or just leave forever.

I suppose I was definitely aiming for replacing the old set when putting the deprecation warning in, but I'd be very happy to compromise that away.

@expipiplus1 expipiplus1 force-pushed the haskell-lib-composable branch from 0ecc307 to 6079de0 Compare November 5, 2021 07:01
Copy link
Member

@Profpatsch Profpatsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m okay with the change in general, but I have some changes I would like to see:

  • don’t deprecate the old module functions
  • call it .compose instead of composable (just less typing and same content)
  • Define everything in compose in terms of the old definitions, don’t duplicate any implementation as it does right now (single source of truth).
  • Maybe add some documentation to the non-compose module header and the nixpkgs haskell documentation that compose is preferred.

Other than that I’m looking forward to using these functions in the future.

@expipiplus1 expipiplus1 force-pushed the haskell-lib-composable branch 2 times, most recently from 7b23391 to bca5918 Compare November 5, 2021 12:25
@expipiplus1
Copy link
Contributor Author

* don’t deprecate the old module functions

* call it `.compose` instead of `composable` (just less typing and same content)

* Maybe add some documentation to the non-compose module header and the nixpkgs haskell documentation that `compose` is preferred.

done done done, NixOS/cabal2nix#528

* Define everything in `compose` in terms of the old definitions, don’t duplicate any implementation as it does right now (single source of truth).

The old lib has always been defined in terms of compose, I hope this is OK.

Other than that I’m looking forward to using these functions in the future.

Me too!

@Profpatsch
Copy link
Member

The old lib has always been defined in terms of compose, I hope this is OK.

Ah, I didn’t see that. It has the disadvantage that the history gets a bit mangled, but personally I don’t care which way around it is.

Copy link
Member

@Profpatsch Profpatsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The next step will be to update https://haskell4nix.readthedocs.io/ to use compose in all examples. But due to the fact that it’s not “in tune” with the rest of the manual, that can’t be done in this repository.

cc @sternenseemann

No changes in derivations for pkgs.haskellPackages
@expipiplus1 expipiplus1 force-pushed the haskell-lib-composable branch from 03a4d2f to 15ae25f Compare November 7, 2021 12:41
@expipiplus1 expipiplus1 merged commit 30a71d9 into NixOS:haskell-updates Nov 7, 2021
@expipiplus1 expipiplus1 deleted the haskell-lib-composable branch November 8, 2021 02:05
Gabriella439 added a commit that referenced this pull request Dec 11, 2021
The derivation for the GHCJS `vector` package broke in #142940 due to
introducing the line of code that this change deletes.

The offending line appears to have been unintentionally added and
causes an evaluation failure for two separate reason :

* The argument order is wrong

  The change in #142940 switched the `haskellLib` utilities to flip
  their argument order, but the `appendPatch` in the offending line
  has the original argument order

* The patch file referenced by the offending line does not exist

The correct fix is to delete the line, because the patch is not
necessary.  The default version of the `vector` package is `0.12.3.1`,
which already includes the fix from that patch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants