Live data from Hacker News

OCaml as my primary language

xvw.lol

271–280 of 296 posts

Re: OCaml as my primary language

#271
post #225

Earlier quoted context omitted.

Haskeller here! > The idea that the example program could use pattern matching to bind to either test values or production ones is interesting, but I can’t conceptualize what that would look like with the verbal description alone. The article appears to have described the free monad + interpreter pattern, that is, each business-logic statement doesn't execute the action (as a verb), but instead constructs it as a nou…

Thanks for the detailed reply, that’s very cool! This looks great, very usable way to do DI. Do you use Haskell professionally? If so, is this sort of DI style common?

I am not a Haskell expert, nor an expert in effect systems, but, AFAIU, what mrkeen has provided is an analogous pattern in Haskell -- where effects are represented via the free monad with an interpreter -- and not an account of what is described in the article.

In OCaml we can (and do) also manage effects via monadic style. However, we don't have ad hoc polymorphism (e.g., no typeclasses), so that aspect of the dependency injection must go thru the more verbose (but more explicit, and IMO, easier to reason about) route of parametric modules.

The point in the article is that effect handlers allow direct-style code with custom effects, which enable a kind of "dependency injection" which actually looks and feels much more like just specifying different contexts within which to run the same program. If you are very used to doing everything in Haskell's monadic style, you may not really notice the difference, until you try to compose the handlers.

Here is an example I've put together to show what the author is talking about in practice: https://gist.github.com/shonfeder/a87d7d92626be06d17d2e795c6...

Re: OCaml as my primary language

#272
post #223
post #216

Earlier quoted context omitted.

I'd say the Modula-2 inspired module system is a very valuable asset compared to today's Rust. The only contact with OCaml I had was that I wrote a bug report to a university professor because I wanted his tool to process one of my files, but the file was larger than OCaml's int type could handle. That itself wasn't the problem - he wrote it wasn't straight forward to fix it. (This is a bug of the type "couldn't have…

It is more the other way around ML predates Modula-2, and the module system like ideas were already present in Mesa and UCSD Pascal. :)

It's been a while since I used UCSD Pascal (in high school, on Apple II boxes with an extra hardware card), so I don't recall the details of the module system there but I'm pretty sure it did not back then permit separate compilation of definitions and implementation files as Modula-2 did (.def and .mod in Modula-2, respectively).

I also saw some ML/SML at uni in the early 1990s but no mention of modules then (this is not to say you are wrong, but I question how visible any work in that space was that may have existed). Now Mesa I never got my hands on, nor do I know anyone that did.

Modula-2 was popular e.g. on the Atari ST 520 series, I still have the handbook on my bookshelf next to me (the vendor of the compiler I had was called "Application Systems Heidelberg", founded in Germany in 1985 they now seem to have gone into gaming). This was a decent 32-bit compiler, and with 1 MB RAM you could write great applications when C compilers at the time were still insufficient in their ability to provide proper type checking support (pre-ANSI/ISO standardization).

Reddit has a discussion on Modula-2 and its family tree here: https://www.reddit.com/r/programming/comments/1cuam2p/what_e...

Re: OCaml as my primary language

#273
post #247

Earlier quoted context omitted.

What if you do "opam update" before?

I already do: https://github.com/gradbench/gradbench/blob/0276272d0df5be19... And the CI build doesn't use Docker caching, so no shenanigans there.

Actually, I did an "opam update" (after my comment that stated there was "3.7.0") and "opam show dune --all-versions" no longer shows "3.7.0". :|

It shows:

  all-versions         1.6.3  1.9.3  1.11.4  2.3.0  2.4.0  2.5.1  2.6.1  2.7.1
                       2.9.3  3.5.0  3.6.2  3.10.0  3.12.1  3.12.2  3.15.3
                       3.17.2  3.18.2  3.19.0  3.19.1
You are right! So I suppose it is either 3.6.2 or 3.10.0. Can you use either of these versions?

Your alternative really is:

  $ opam pin add dune https://github.com/ocaml/dune/releases/download/3.7.0/dune-3.7.0.tbz
If you really must need "3.7.0".

Just FWIW, maybe it might work the way you wanted it to if you do not update the registry; worth a try. It should be able to fetch the correct tarball.

Re: OCaml as my primary language

#274
post #92

ocaml is one of my favourite languages too, but I've found myself being drawn towards rust for my latest project due to its major superpower - you can write a rust library that looks like a c library from the outside, and can be called from other languages via their existing c ffi mechanisms. I feel like by writing the library in ocaml I would have a better experience developing it, but be giving up on that free inte…

You can call OCaml code like a C library: https://ocaml.org/manual/5.3/intfc.html#s%3Ac-callback

have to admit, I've never tried that! I should explore it more.

Re: OCaml as my primary language

#275
post #7

OCaml is a great language without great tooling. Desperately needs a good LSP implementation to run breakpoints and other debugging tools on VSCode or other LSP-aware IDEs. I know there ARE tools available but there isn't great support for them and they don't work well

Indeed, efforts should be made in terms of DAP ( https://microsoft.github.io/debug-adapter-protocol// ), extending the following experimentation: https://lambdafoo.com/posts/2024-03-25-ocaml-debugging-with-... . However, I find the assertion about tooling a bit exaggerated, don't you?

Using DAP with VSCode and OCaml's bytecode debugger (https://github.com/hackwaly/ocamlearlybird) works reasonably well already. My blog post above can be modified to work with VSCode, but I'm primarily an Emacs user. The main issue with Emacs and DAP is the DAP modes are not very polished.

The missing piece for OCaml is debugging native code, the compiler doesn't emit enough DWARF information and debuggers like LLDB or GDB, need to be modified to understand OCaml's DWARF information. Even there DAP with LLDB/GDB works, it's just the debugger doesn't have enough information to work well. You end up working with debugging assembly or C (if it's parts of the runtime). I've written up a PR documenting native debugging here https://github.com/ocaml/ocaml/pull/13747.

Re: OCaml as my primary language

#276

Earlier quoted context omitted.

> I feel if OCaml had got its act together around about 2010 with multicore and a few other annoyances[1] OCaml had its act together. It was significantly nicer than Python when I used it professionally in 2010. Just look at what JaneStreet achieved with it. The main impediment to OCaml was always that it was not American nor mainly developed from the US. People like to believe there is some technical merit to langua…

Python, PHP, Ruby: all not American though, right? Do you mean those only got hockey stick growth when they happened to get picked up by the USA ? But then couldn’t the same have happened for ocaml? And if so: why didn’t it, as it supposedly did for the others Not to mention Linux I guess

Von Rossum moved to the US and Python actually got US government funding pretty early. Lerdorf did PHP in Canada so America. Ruby is kind of the exception being Japanese but it’s pretty niche - nearly as much as Ocaml - and is mostly popular for Rails which was started from Denmark but by someone working for, you guessed it, a US company. Torvald announced Linux on a US usenet list and moved to California soon after.

Ocaml difference is that the core development is done by INRIA, a French public institution and the people in charge had zero interest in moving to the US or chasing the US market.

It’s funny because Ocaml became a bit more popular when people from the UK (Cambridge, JaneStreet) started doing more outreach.

Re: OCaml as my primary language

#277
post #145

Question about terminology: Is it common to call higher-order function types "exponential types" as the article does? I know what higher-order functions are, but am having trouble grasping why the types would be called "exponential".

ackfoobar has already given a good reason why function types are called exponential, but there is an even deeper reason: function types interact algebraically the same way as exponents. The type A → (B → C) is isomorphic to (A × B) → C (via currying). This is analogous to the rule (cᵇ)ᵃ = cᵇ˙ᵃ. The type (A + B) → C is isomorphic to (A → C) × (B → C) (a function with a case expression can be replaced with a pair of fu…

Since the cardinalities match the algebra, it's no surprise that identities translate, but seeing them still brings a smile to my face.

The correspondence can be pushed much further - to differentiation!

https://codewords.recurse.com/issues/three/algebra-and-calcu...

Re: OCaml as my primary language

#278

Earlier quoted context omitted.

"I feel if OCaml had got its act together ..." The great thing is we have choice. We have a huge number of ways to express ideas and ... do them! I might draw a parallel with the number of spoken languages extent in the UK (only ~65M people). You are probably familiar with English. There are rather a lot more languages here. Irish, Scottish, Welsh - these are the thriving Brythonic languages (and they probably have s…

It's weird to see someone from the UK champion the Irish language as a choice as if they didn't try to systematically wipe it from the face of the earth for quite a long period of time. Choice is good of course so do keep up the good work.

My grandad's family on my dad's side was driven out of Dublin by some folks who went on to set their house on fire, back in the day. They were warned off by a maid and legged it to England. A few generations earlier, on the same line, my ancestors were German immigrants to London.

I will upvote your comment nonetheless. I see it has been DVd which I don't like to see - we all have our views.

Re: OCaml as my primary language

#279

Earlier quoted context omitted.

"I feel if OCaml had got its act together ..." The great thing is we have choice. We have a huge number of ways to express ideas and ... do them! I might draw a parallel with the number of spoken languages extent in the UK (only ~65M people). You are probably familiar with English. There are rather a lot more languages here. Irish, Scottish, Welsh - these are the thriving Brythonic languages (and they probably have s…

From the gedcom wiki page it doesnt seem that bad. At least the data format itself. But it seems like its very easy to screw up working with it.

GEDCOM was developed by the Mormons and was not really designed to encompass the rich diversity of human relationships. You can seriously overload the notes fields!

Genealogy is really hard but it is important to not get too bogged down with formality and get the data stashed in one form or another. Genealogy "facts" decay with a horribly short half life. It is also important to accept all "facts" as is and not try to interpret them too much - that's something else.

I'm 55 years old and have memories dealing with my grandad on my mother's side who was born in 1901. So, within reason, I can record some second hand facts going back to very early C20. My parents were born 1942/3. etc etc. However, the gold standard is written evidence of a fact.

I think that genealogy really needs to discover systems like Elastic/Open Search and not try to coerce the data to a fixed schema.

Everyone thinks their family tree is a tree. No it really isn't - it's a thicket!

I have a relative that my uncle found from Padstow in Cornwall in C16 - her first born was probably a bastard fathered by the local squire's son. There's a soldier from WWI whom the family "knowledge" from around two generations ago was convinced he was a deserter. It turns out he was honorably discharged and emigrated to Canada. On of my G^5 dad died from septicemia after punching a window in a drunken pub brawl.

All of the above has documentary evidence, expect for the desertion thing, which turned out to be bollocks. Oh there is a good chance of a mass-murderer back in C18 near Devizes, Wiltshire!

This is where IT gets really interesting. How on earth do you go about genealogy data? You are sure to piss off someone(s) who want to wear the rose tinted specs and if you think modern politics are a bit challenging, why not try to deal with politics across centuries and the random weirdness that is your own family 8)

Re: OCaml as my primary language

#280

Earlier quoted context omitted.

It's weird to see someone from the UK champion the Irish language as a choice as if they didn't try to systematically wipe it from the face of the earth for quite a long period of time. Choice is good of course so do keep up the good work.

My grandad's family on my dad's side was driven out of Dublin by some folks who went on to set their house on fire, back in the day. They were warned off by a maid and legged it to England. A few generations earlier, on the same line, my ancestors were German immigrants to London. I will upvote your comment nonetheless. I see it has been DVd which I don't like to see - we all have our views.

Incidentally. "WN" is quite well documented. Was there something similar in Ireland, before independence?

https://en.wikipedia.org/wiki/Welsh_Not

Post reply on HN