Free applicatives, the handle pattern, and remote systems

(exploring-better-ways.bellroy.com)

88 points | by _jackdk_ 21 hours ago ago

34 comments

  • rich_sasha 20 hours ago

    Bellroy, the maker of quirky travel accessories and wallets, has a software stack written in Haskell?? TIL

    • titanomachy 19 hours ago

      The second-to-last post[0] talks about how they decided to migrate their stack from Ruby on Rails to Haskell, and are now in the seventh (!) year of that migration.

      [0] https://exploring-better-ways.bellroy.com/designing-for-the-...

      • internet_points 16 hours ago

        My first thought was: does that mean they've been actively migrating for seven years, or just "we migrated the most important stuff and can't see any strong business reasons to move some of these microservices that do their job just fine"? But reading the post, it seems the main reason is they no longer understand all the Ruby code!

        • bobbylarrybobby 10 hours ago

          I thought this couldn't be correct, but... nope:

          > We adopted a pragmatic approach: maintain the Ruby code but only port functionality to Haskell when we could add meaningful value in the process. This meant our Ruby codebase gradually became legacy code, maintained but not actively developed. This transition — which we expected to take a couple of years — has now stretched into its seventh year. > > Here’s where the Clean Architecture approach began to work against us. As we hired more Haskell-focused developers and our institutional knowledge of Ruby faded, those carefully crafted abstraction layers became archaeological puzzles. Reverse-engineering what a piece of code actually did — especially complex, multi-step operations with side effects — became a nightmare.

      • oncallthrow 18 hours ago

        Seems like an insane choice to me

        • bobnamob 18 hours ago

          They're based in Collingwood, any Australian would tell you that an n year Haskel rewrite is the most normal thing about them

          • rswail 12 hours ago

            Speaking as someone from there (Collingwood), we're proudly weird.

            • pklausler 7 hours ago

              Hello from Portland, Oregon!

        • cosmic_quanta 12 hours ago

          I'd love to hear more about why you think this is insane.

    • spiffytech 13 hours ago

      I'm very happy with my Bellroy Card Sleeve wallet. You know, just in case anyone's checking the comments on a functional programming article for wallet recs. As one does.

      • PaulHoule 9 hours ago

        My Bellroy wallet is great too.

    • leohonexus 13 hours ago

      And they even use Nix, to add to the craziness.

      [0] https://flox.dev/nixinthewild/nix-in-the-wild-bellroy/

      • cosmic_quanta 12 hours ago

        Nix isn't so exotic anymore. Every company for which I interviewed about a year ago used Nix

        • YuukiRey 11 hours ago

          And every person I met today had a parrot on their shoulder. Doesn't really mean it applies to the general public (here meaning most developers out there).

          I'd say <1% of all developers world wide have even heard of Nix.

          • ameliaquining 6 hours ago

            It is used in production much, much more widely than Haskell is, though it remains far from the most common way to do builds or deployments.

    • nikita2206 13 hours ago

      Also was surprised to see their logo on the blog website.

      I have had one of their cardholders for 10 years now, it is incredible how durable and practical that thing is.

    • riwsky 17 hours ago

      So is Costar, the horoscope app, of all things

      • rich_sasha 16 hours ago

        At least the product is pretty esoteric too.

    • chaboud 13 hours ago

      I thought this was a joke about two things having the same name… nope!

      One funny thing about software is that beautiful things can emerge from the most unexpected places. I appreciate that there are folks out there with the bravery to share their journey.

    • throwthrow0987 14 hours ago

      They must be making a lot of money!

  • tinyspacewizard 11 hours ago

    Weird feeling knowing that an ecommerce / wallet store has employees with more advanced programming knowledge than most financial institutions.

  • Joker_vD 9 hours ago

    > We want to build a structure that is essentially a syntax tree of the operations we want to perform.

    A-a-and so we went from programming in Haskell to creating a new DSL, with an interpreter for it in Haskell, and programming in that DSL. Which kinda begs a question: you already have a perfectly serviceable programming language (i.e. Haskell) at hand; why not just use it?

    • _jackdk_ 3 minutes ago

      This is a really good question. If you write all the queries directly in Haskell, you get an IO action which you can't inspect: all you can do is execute it and see what it does. It might make requests, it might repeat requests it didn't need to make, it could do literally anything else.

      Other programming traditions also have this pattern of inventing minilanguages and interpreters for them; regular expressions are by far the most successful example. You could hand-roll string matching by writing your matching functions by hand, but it's often much easier to ask a regex library to run an interpreter over a string describing the pattern to match.

      In Haskell, it's really cheap to invent data structures, so using the same language to describe the work is quite convenient. Laziness also means you almost never materialise the entire intermediate "work to be done" structure - you build little bits as the interpreter demands them. So it doesn't feel as heavyweight as an eDSL in some other language.

    • lkey 8 hours ago

      Creating specialized and constrained DSLs is a common and useful pattern for folks that write Haskell (or really any FP lang that has ADTs).

      • cryptonector 6 hours ago

        jq was originally a Haskell-coded, in-Haskell DSL.

    • marcosdumay 8 hours ago

      I don't understand your complain. Haskell is entirely aimed at creating those small languages and interpreting them. While at the same time the compiler they have in hand implements a DSL for describing imperative programs that do not allow the kind of analysis the author is doing.

      What exactly you expected them do write?

      • cryptonector 6 hours ago

        Eh, Haskell is not "entirely" aimed at creating DSLs.

        • marcosdumay 5 hours ago

          Ok, it's not entirely.

          It's just its main differentiator. But there's way more to the language.

    • kqr 8 hours ago

      That's what I also don't quite get. I would build it as the parsing step mapped directly over the query. I suppose their approach lets them build a tree of operations but I'm skeptical it provides all that much benefit.

  • vjerancrnjak 10 hours ago

    A recurring problem, somehow making it very easy to write code that deals with 1 thing from start. When time comes , somehow hard to write code that deals with N things.

    I wonder how different the code would look if it was just written to deal with N things from the start.

    I’m also not sure how far this code can go, if I have queries that depend on responses of preceding queries , how will my runAp_ give me this? It probably won’t.

    always wondered where are http frameworks that just give me a batch of requests to deal with from the start.

  • munchler 5 hours ago

    I love me some functional programming, and spend most of days happily immersed in F#, but when I see Haskell programmers casually discussing the lengths they’ll go to to avoid side-effects, I am always in awe. It’s like overhearing monks in the Middle Ages talking about their favorite techniques for copying the Bible by hand.

  • ksec 17 hours ago

    I am really really surprised Bellroy could afford to hire developers for their own store. I guess they are now much bigger than I thought? I watch them grow from an unknown brand that focus on slimming your wallet in the early 10s, to now I bump into people who have actually heard of used it. Or at least seen the online ads. Pretty amazing.

    I remember Gwyneth Paltrow said something along the line moving away from Shopify was the biggest mistake she made with her online shop. I think that was before Pandemic and Shopify have improved a lot since then.

    Which makes me wonder if it make sense for Bellroy to continue their path.

    • fwlr 12 hours ago

      I believe this is a case of “developers who went into the wallet business”, actually.

  • farhanhubble 12 hours ago

    I have loved their bags and mobile cases for their aesthetics and their website too and now the blog!