Blog
The OCaml Planet RSS
Articles and videos contributed by both experts, companies and passionate developers from the OCaml community. From in-depth technical articles, project highlights, community news, or insights into Open Source projects, the OCaml Planet RSS feed aggregator has something for everyone.
Source
Keyword
Year
Author
Want your Blog Posts or Videos to Show Here?
To contribute a blog post, or add your RSS feed, check out the Contributing Guide on GitHub.
neocaml 0.1 is finally out! Almost a year after I announced the project, I’m happy to report that it has matured to the point where I feel comfortable calling it ready for action. Even better - neocaml recently landed in MELPA, which means installing it is now as easy as:
One of the first things developers want to do in any language is print out the value of a variable. In languages with dynamic typing or extensive reflection, this is often a trivial, built-in operation. In OCaml, the story is a bit different. Its strong, static type system requires you to be explicit about how to turn a data structure into a string representation.
When I started to play with OCaml I was kind of surprised that there was no id (identity) function that was available out-of-box (in Stdlib module, that’s auto-opened). A quick search led me to the Fun module, which is part of the standard library and is nested under Stdlib.
Today I’m going to cover a very basic topic - conversions between OCaml’s primary numeric types int and float. I guess most of you are wondering if such a basic topic deserves a special treatment, but if you read on I promise that it will be worth it.
These days a lot of programming languages (especially those leaning towards functional programming) offer a pipeline operator (|>), that allows you to feed some data through a “pipeline” of transformation steps.1 Here’s a trivial example in F#: Funny enough, even Ruby has a pipeline operator these days, although it’s not particularly useful there. ↩
OCaml is famous for allow you to do a lot of things like modules. Like really a lot! Advanced features like functors, aside, it’s really common to either alias module names to something shorter or localize open Module_name to a smaller scope:
In my previous article I mentioned that OCaml’s Stdlib leaves a lot to be desire when it comes to regular expressions. One thing I didn’t discuss back then was that the problem is somewhat mitigated by the excellent module Scanf, which makes it easy to parse structured data.
One of the things that bothered me initially in OCaml was the poor support for working in regular expressions in the standard library. Technically speaking, there’s no support for them at all!
If someone had told me a few months ago I’d be playing with .NET again after a 15+ years hiatus I probably would have laughed at this.1 Early on in my career I played with .NET and Java, and even though .NET had done some things better than Java (as it had the opportunity to learn from some early Java mistakes), I quickly settled on Java as it was a truly portable environment.
Every programming language comes with some “batteries” included - mostly in the form of its standard library. That’s typically all of the functionality that’s available out-of-the-box, without the need to install additional libraries.