1. 3

    I disabled this when I got my first iPhone because it sometimes falsely triggered and haven’t re-enabled it since. Just last week I wanted to undo something I messed up and didn’t even remember that this was a thing at all, thinking there just isn’t undo on iOS (unless you attach a keyboard), which was very frustrating.

    Slightly off-topic, but this leads me to one of my common workflows for text, which is copying on iOS, using the synchronised clipboard to paste into emacs on MacOS, edit my text there, and then copy it back onto my phone to use it, which, while quite ridiculous, just works.

    1. 5

      I find it interesting that the author uses AST rewriting to convert |. I’ve seen approaches in the past which just use a filler object (like foo | into | bar, into being the filler) which has a special __or__ method that does the piping.

      I personally have experimented with a simple function just called pype() which also does some magic to avoid the need for lambda functions, see here.

      EDIT: I did a quick writeup of my solution.

      1. 7

        I always just reduced the value over the reverse of callables. It made higher order stuff, particularly data transforms, a lot easier to read. The code I used at my last job is open sourced here (the thread() function): https://github.com/curiosity/yunobuiltin/blob/develop/yunobuiltin.py#L444

        We used pipeline() more than thread(), which takes only callables (no value) and returns a callables. It is functional composition with the order reversed such that the callables are applied from left to right.

        The nice advantage of using the ast is that you can get much closer to Clojure’s -> and friends. By working from a compiler hook (the ast transformer), you wouldn’t need to use partial/rpartial/lambda as much. The downside is that it is quite a bit more complicated than a one liner.

        1. 2

          That is very nice and clean, though I don’t really like lambdas in Python, they feel super verbose for what they are. I wish there was Haskell-style partial application.

        2. 6

          I’d considered that approach as well, but I wanted to avoid needing a wrapper for the leftmost expression and I also wanted to avoid needing to partially apply functions.

          Take the 3rd example from the post:

          Users.find_all() | group_by_category(max=5) | print()
          

          without transforming the ast that’d have to look something like:

          pipe(Users.find_all()) | partial(group_by_category, max=5) | print
          
        1. 5

          I’m Robin and I mostly write about functional programming and software engineering as a profession:

          Link: https://sulami.github.io / https://sulami.gitlab.io

          1. 2

            I nearly posted this as an ‘ask’: Slack is not good for $WORK’s use case because it does not have an on-premise option. What on-premise alternatives are people using/would you recommend?

            1. 4

              I’ve used Mattermost before, which AFAIK has an on-prem version - just as a user, not setup or admin so I can’t speak to that end.

              1. 6

                I’ve heard rumblings about Zulip being a decent option too. I haven’t used it myself though.

                1. 2

                  Same, actually. It does look very interesting, I’d be highly interested in whether anyone has any experience with it?

                  1. 1

                    Zulip looks pretty solid, thanks for mentioning it. We may give it a try…

                  2. 2

                    We’ve used mattermost for a few years now, it’s pretty easy to setup and maintain, you basically just replace the go binary every 30 days with the new version. We just recently moved to the integrated version with Gitlab, and now Gitlab handles it for us, even easier now, since Gitlab is just a system package you upgrade.

                    1. 2

                      A lot of people have said Mattermost, might be a good drop-in replacement. According to the orange site they’re considering dropping a “welcome from Hipchat” introductory offer, which is probably a smart move.

                      1. 2

                        IIRC mattermost is open core. I’ve heard good things about zulip. Personally, I like matrix, which federates and bridges

                      2. 3

                        Matrix is fairly nice to use. I had some issues hosting it though.

                      1. 2

                        I’ve done a quite small (47 LOC) Haskell solution for this a couple of years ago. Turns out solving Sudokus is quite simple. Blogpost/Code. The basis is just going over the whole grid, pruning possibilities per field, filling in the ones with just one possible solution. Rinse and repeat until you’re done. Very fun exercise to learn a new language as well.

                        1. 3

                          Um, resolving single candidates is not enough to solve most Sudoku puzzles.

                          1. 2

                            Yeah generally on “hard” boards you’ll have to randomly pick a value for a couple, then do a DFS on that choice and subsequent choices.

                            1. 2

                              Depends on the level of inference one is willing to implement.

                              Full inference for each row/column/square individually plus something called shaving/singleton arc consistency/several other names which means to do the hypothesis test for each square/value pair “If this square was assigned this value, would that lead to an inconsistency?” is enough to solve all 9x9 Sudokus without search empirically. For details, see Sudoku as a Constraint Problem by Helmut Simonis.

                              1. 1

                                That just sounds hugely frustrating. I usually just solve them by elimination, but I don’t really do super hard ones.