News for hackers. Stuff that matters.
Re:‘Woof’, a pure Scala 3 logging library by the_af on Saturday December 18, 2021 @02:10PM (#29607530)
Where did you read "category theory" in that article?

I'm not familiar with Woof but it looks like an attempt at writing a pure logging lib. What is wrong with that?

Re:‘Woof’, a pure Scala 3 logging library by macpete42 on Saturday December 18, 2021 @02:50PM (#29607904)
the so called "purity" is achieved by using a higher kinded type and the cats IO monad. it's like adding "1+1" with a "mathematical-calculation-monoid-combine-factory-builder-singleton-locator-evaluator-pattern". I remember keeping it simple as an ultimate goal but maybe I am just too for this FP peeing contest? why is it such a frickin' deal to log a message somewhere?
Re:‘Woof’, a pure Scala 3 logging library by the_af on Saturday December 18, 2021 @03:36PM (#29608256)
> why is it such a frickin' deal to log a message somewhere?

Need I remind you of the Log4J debacle? It's definitely a big deal.

Whether this is the right approach is another matter.

PS: trust me, you don't need to read on category theory to use or understand monoids, which at the level they are used in Scala and Haskell code, they are trivial to understand.

Re:‘Woof’, a pure Scala 3 logging library by doikor on Saturday December 18, 2021 @03:05PM (#29608030)
> I remember keeping it simple as an ultimate goal but maybe I am just too for this FP peeing contest? why is it such a frickin' deal to log a message somewhere?

Don't know about others but for me it is about being able to easily verify that my logging is setup correctly.

Once you write your logging to some monad (the library we use does not require it to be IO) testing it becomes trivial with a WriterT monad where it just write your logs into some list/buffer and check that what was logged in various cases was actually what you wanted.

We do the same with tracing checking that spans are created as we wanted and the tags/logs on the spans are setup correctly.

Re:‘Woof’, a pure Scala 3 logging library by macpete42 on Saturday December 18, 2021 @03:42PM (#29608326)
Why would I verify logging which itself is a verification instrument? And, seriously, how hard is it to emit a diagnostic message so I need a test for that to get it right?
Re:‘Woof’, a pure Scala 3 logging library by doikor on Saturday December 18, 2021 @04:05PM (#29608490)
If you have some rare (rare as in it happens once every few months or something like that) error and you need logging about it. Also testing it ensures nobody by mistake removes that bit of logging by accident.
Re:‘Woof’, a pure Scala 3 logging library by macpete42 on Saturday December 18, 2021 @04:35PM (#29608756)
code reviews would probably be a better fit to prevent that.
Re:‘Woof’, a pure Scala 3 logging library by the_af on Saturday December 18, 2021 @04:44PM (#29608827)
Code reviews are useful, but I've never seen them used as an argument against writing tests.
Re:‘Woof’, a pure Scala 3 logging library by the_af on Saturday December 18, 2021 @04:09PM (#29608529)
There are tests of tests, why wouldn't there exist techniques for the verification of logging?
Re:‘Woof’, a pure Scala 3 logging library by AheadOfTime295 on Saturday December 18, 2021 @04:47PM (#29608856)
Monads got a facelift in Scala 3 with braceless syntax, aka significant indentation

https://dotty.epfl.ch/docs/reference/other-new-features/inde...

Re:‘Woof’, a pure Scala 3 logging library by jghn on Saturday December 18, 2021 @02:51PM (#29607920)
It's using IO monads
Re:‘Woof’, a pure Scala 3 logging library by the_af on Saturday December 18, 2021 @03:41PM (#29608308)
But it doesn't need to. The overall solution, I mean. See another comment in this section mentioning they follow a similar approach but NOT using the IO monad.

Also: you don't need to know category theory to use the IO monad.