4 ms·
"Oh, you _also_ need to print something? Lets stack a few monad transformers..." "But remember that you need the TemplateExplicative and NullUnderstanding comp
by c00lio 3y ago
"Oh, you _also_ need to print something? Lets stack a few monad transformers..."
"But remember that you need the TemplateExplicative and NullUnderstanding compiler extensions!"
- ykonstant 3y ago>NullUnderstanding compiler extension brilliant! lol
- epgui 3y agoIs brilliant the best word? :P
- momentoftop 3y agoYou're thinking of Haskell. F# was modelled after OCaml, which doesn't attract monad transformer stacks, and doesn't have a zoo of compiler extensions.
- seanhunter 3y agoI haven’t used it for some time but OCaml certainly used to have a zoo of incompatible compiler extensions. Circa 2008 or so I once hit on the brilliant idea of using protobufs to get two mutually incompatible halves of an ocaml program to talk to one another only to find that required yet another compiler extension to work.
- momentoftop 3y agoAre you thinking of preprocessors? Back then, it would have been via Camlp4 and Camlp5.
- seanhunter 3y agoAah yes I am
- ReleaseCandidat 3y agoWell, they aren't actually compiler extensions but pre processor extensions (PPX). 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 https://ocaml.org/docs/metaprogramming http://ocamlverse.net/content/metaprogramming.html http://ocamlverse.net/content/metaprogramming.html
- jackmott42 3y agoYou have to add extra syntax to do very normal things like have more than one expression in a function.
- colanderman 3y agoAs someone who's coded OCaml for 20 years, I have no idea what you're referring to. `let x in y`? `x; y`? `x, y`? Those are all in the base language.
- tombert 3y agoI'm pretty sure F# was modeled on both. There are some definite "Haskell-isms" in F#; if nothing else, monads are typically done in something more or less equivalent to the `do` notation (an `async` or `seq` block), for example. 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.
- ReleaseCandidat 3y agoHere is the "official" history of F#: https://fsharp.org/history/hopl-draft-1.pdf https://fsharp.org/history/hopl-draft-1.pdf 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)
- thesz 3y agoYou can use eventlog traces, from Debug.Trace [1]. You can (traceEvent $ "look: " ++show bazinga) everywhere you need and then stare at the log to your heart content. [1] https://hackage.haskell.org/package/base-4.18.0.0/docs/Debug-Trace.html#g:2 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.
- scotty79 3y agoI can't tell if you are trying to defend those languages or just piling up absurdities on the previous post in the style of "yes, and ..." improv.
- thesz 3y agoI am trying to offer counterpoint to what seems to me as an unjust critique from a person who, at first sight, does not know much about Haskell. 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.
- c00lio 3y agoNot everything is tracing and debugging, sometimes you really need to output intermediate results for "normal", "production" purposes. One could still abuse Debug::Trace, but that would really be ugly. 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...
- thesz 3y agoWith eventlog you have lightweight profiling and logging tool for "normal", "production" purposes. You can correlate different metrics of your program with your messages. This is not an abuse of Debug.Trace (notice the dot), it is normal state of affairs, regularly used and RTS is optimized for that use case. 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. [1] https://hackage.haskell.org/package/QuickCheck https://hackage.haskell.org/package/QuickCheck
- frozenlettuce 3y ago"now just sprinkle some `map . sequence . map`'s here and there and you are done. who said this was difficult?"