Stream: software unscripted podcast

Topic: S1E91 Comparing F#, Elm, and Haskell with Michael Newton


view this post on Zulip Zellyn Hunter (May 14 2024 at 20:09):

Fascinating conversation. Listening to the various ways people plumb state through things made me wonder how one would idiomatically and cleanly implement threading common state that we see in our production code:

Presumably one would grab these from the platform and then pass them around explicitly? At work, our Java code loves hiding things in TLS (Thread-Local Storage), whereas our Go code uses the context.Context to pass things around (more, but not completely) explicitly.

I'm a Go programmer by preference, but I can't help wishing there were some way to pass context around that was both explicit and didn't use up a function parameter.

…and yes, hiding stuff in TLS in Java causes all the fun you might expect when passing control via ThreadPool/ExecutorService

view this post on Zulip Eli Dowling (May 14 2024 at 22:48):

Hey, I can give one idea:

For just some random function I would just pass it in: 

\traceContext, otherAgrs-> ...rest

But I would probably try to use the upcoming module params feature https://docs.google.com/document/d/110MwQi7Dpo1Y69ECFXyyvDWzF4OYv1BLojIm08qDTvg/edit?usp=drivesdk:

One way might be to create a Logger module which takes a traceContext when it is instantiated 

import  Logger { traceContext }

Import MyModule {Logger}

MyModule.myLoggedFunc

Last updated: Jul 06 2025 at 12:14 UTC