"But remember that you need the TemplateExplicative and NullUnderstanding compiler extensions!"
"But remember that you need the TemplateExplicative and NullUnderstanding compiler extensions!"
[1] https://hackage.haskell.org/package/base-4.18.0.0/docs/Debug...
No need for extensions, just compile and run your program slightly differently. That's the power of declarative languages.
I also object to that "everywhere". It is far easier to just dump an extra 'print' line somewhere inside a for-loop than into a `foldl (*) 1 $ map (+ 3) [17, 11, 19, 23]`. And that is an easy one...
I develop with Haskell professionally. That foldl example of yours is pretty rare and usually dealt with the QuickCheck [1], mother of all other quickchecks. Usually, the trace will be outside of the foldl application, but you can have it there in the foldl argument, of course.
The "correct" answer to `foldl` would be `scanl` and printing the result of it.
https://hackage.haskell.org/package/base-4.18.0.0/docs/Prelu...
In my opinion, eventlog traces make much better logging than almost anything I've seen.
Right now, developing with C++, I miss the power of Haskell's RTS.
Haskell's (GHC's) Eventlog is nice, but a binary format and not comparable to text output.
So actually not everywhere. And QuickCheck does something else entirely.
The foldl example of yours should be split into a property checking and controlling for expected properties of the input. The first part is done via quickcheck and second part usually is done with assertions and/or traces.
But nothing preclude you from having your trace there, inside foldl argument. This is clearly wrong place to have it, but still you can have it there.
So I repeat, you can have your traceEvents everywhere.
Also, a link to a useful library is not a bad thing for anyone curious about Haskell. Thus, there's a bit of education there.
If it looks like improv, I am here every evening till Friday.
And I would really like if OCaml would have had the possibility to add the needed PPXs names to the source file (like Haskell's compiler extensions). So as to not have to read the Dune (or whatever build system is used) file to get to know where `foo%bar` or `[@@foo]` is coming from and what is doing. But at least the usage of `ppxlib` nowadays should make PPXs "compose" aka. not stamping on each other's feet.
https://ocaml.org/docs/metaprogramming http://ocamlverse.net/content/metaprogramming.html
The syntax superficially looks a lot like OCaml, but it doesn't do the cool stuff with OCaml functors and modules; you write it a lot more like Haskell most of the time.
Don Syme began with a port of Haskell to .Net, but SPJ convinced him that this is a bad idea, so he did choose OCaml. ("The Decision to Create F#", Page 9)
brilliant! lol