<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
  <id>https://www.baturin.org/atom-ocaml.xml</id>
  <title>Daniil Baturin's blog</title>
  <updated>2020-08-28T00:00:00+00:00</updated>
  <author>
    <name>Daniil Baturin</name>
    <email>daniil+website@baturin.org</email>
  </author>
  <generator uri="https://soupault.app" version="5.0.0">soupault</generator>
  <logo>https://baturin.org/images/favicon.png</logo>
  <subtitle>Posts on OCaml programming</subtitle>
  <entry>
    <id>https://www.baturin.org/blog/lua-ml-embedding-and-projection/</id>
    <title>Embedding and projection in Lua-ML</title>
    <updated>2020-08-28T00:00:00+00:00</updated>
    <content type="html">
    One thing I find odd about many interpreter projects is that they are designed as standalone and can&apos;t be used as embedded
scripting languages. Lua-ML is completely different in that regard: it&apos;s designed as an extension language first and offers
some unique features for that use case, including a reconfigurable runtime library. You can remove modules from its standard library or replace
them with your own implementations. Of course, you can also pass OCaml values to Lua code and take them back in a type-safe manner too.
That aspect isn&apos;t very obvious or well-documented, so in this post we&apos;ll try to uncover it.
    </content>
    <link href="https://www.baturin.org/blog/lua-ml-embedding-and-projection/" rel="alternate"/>
  </entry>
  
  <entry>
    <id>https://www.baturin.org/blog/if-you-think-reasonml-compiles-to-js-you-are-wrong/</id>
    <title>If you think ReasonML compiles to JS, you are wrong</title>
    <updated>2019-09-05T00:00:00+00:00</updated>
    <content type="html">
    In this post we&apos;ll examine what &lt;a href=&quot;https://reasonml.github.io/&quot;&gt;ReasonML&lt;/a&gt; really is and what it compiles to.
Everyone coming from the ML community already knows the truth, but in the JS community, this misconception
seems surprisingly common. It&apos;s not just about giving credit, but about the true potential of the language
that is far greater than that of TypeScript or Elm.
    </content>
    <link href="https://www.baturin.org/blog/if-you-think-reasonml-compiles-to-js-you-are-wrong/" rel="alternate"/>
  </entry>
  
  <entry>
    <id>https://www.baturin.org/blog/declarative-parse-error-reporting-with-menhir/</id>
    <title>Declarative parse error reporting with Menhir</title>
    <updated>2019-08-24T00:00:00+00:00</updated>
    <content type="html">
    Many parsers for custom formats aren&apos;t very user friendly when it comes to error handling.
At best you get the line and column where the error is, at worst a “Parse error”
message is all you get. Can we do better? With right tools, we definitely can and it&apos;s not that hard.
    </content>
    <link href="https://www.baturin.org/blog/declarative-parse-error-reporting-with-menhir/" rel="alternate"/>
  </entry>
  
  <entry>
    <id>https://www.baturin.org/blog/extending-ocaml-programs-with-lua-soupault-got-plugin-support/</id>
    <title>Extending OCaml programs with Lua (soupault got plugin support)</title>
    <updated>2019-08-10T00:00:00+00:00</updated>
    <content type="html">
    Most of the time, when people make extensible programs in typed functional languages,
they make a DSL, not least because it&apos;s much easier to make a DSL in a language with algebraic types
and pattern matching than in one without.&lt;br&gt;
Some use cases really require a general-purpose language though. That&apos;s where things get
more interesting. Commonly used embeddable interpreters such as Lua, Guile, or Chicken are written in C.
It&apos;s possible to make OCaml or Haskell bindings for them and such bindings do exist,
but that&apos;s two high level languages communicating through a low level one.&lt;br&gt;
It would be much better to be able to expose native types to the embedded language in a type-safe and more or less convenient
fashion. Here&apos;s my take at it.
    </content>
    <link href="https://www.baturin.org/blog/extending-ocaml-programs-with-lua-soupault-got-plugin-support/" rel="alternate"/>
  </entry>
  
  <entry>
    <id>https://www.baturin.org/blog/introduction-to-ocaml-part-5-exceptions-lists-and-structural-recursion/</id>
    <title>Introduction to OCaml, part 5: exceptions, lists, and structural recursion</title>
    <updated>2018-08-18T00:00:00+00:00</updated>
    <content type="html">
    In OCaml, exceptions are not objects, and there are no exception hierarchies. It may look unusual now,
but in fact exceptions predate the rise of object oriented languages and it&apos;s more in line with original
implementations. The advantage is that they are very lightweight.
    </content>
    <link href="https://www.baturin.org/blog/introduction-to-ocaml-part-5-exceptions-lists-and-structural-recursion/" rel="alternate"/>
  </entry>
  
  <entry>
    <id>https://www.baturin.org/blog/introduction-to-ocaml-part-4-higher-order-functions-parametric-polymorphism-and-algebraic-data-types/</id>
    <title>Introduction to OCaml, part 4: higher order functions, parametric polymorphism and algebraic data types</title>
    <updated>2018-08-12T00:00:00+00:00</updated>
    <content type="html">
    So far we have only worked with functions that take value of a single type known beforehand.
However, we have already seen functions whose types were left without explanation, such as
&lt;code&gt;let hello _ = print_endline &quot;hello world&quot;&lt;/code&gt; that we used to demonstrate the wildcard pattern.
&lt;br&gt;
What is its type? If you enter it into the REPL, you will see that it&apos;s &lt;code&gt;&apos;a -&amp;gt; unit&lt;/code&gt;.
What does the mysterious &apos;a mean? Simply put, it&apos;s a placeholder for any type.
Essentially, a variable for types —a &lt;em&gt;type variable&lt;/em&gt;.
    </content>
    <link href="https://www.baturin.org/blog/introduction-to-ocaml-part-4-higher-order-functions-parametric-polymorphism-and-algebraic-data-types/" rel="alternate"/>
  </entry>
  
  <entry>
    <id>https://www.baturin.org/blog/introduction-to-ocaml-part-3/</id>
    <title>Introduction to OCaml, part 3</title>
    <updated>2018-08-08T00:00:00+00:00</updated>
    <content type="html">
    This should have been covered earlier, but better late than even later.
In this chapter we&apos;ll learn about booleans and conditional expressions.
    </content>
    <link href="https://www.baturin.org/blog/introduction-to-ocaml-part-3/" rel="alternate"/>
  </entry>
  
  <entry>
    <id>https://www.baturin.org/blog/introduction-to-ocaml-part-2/</id>
    <title>Introduction to OCaml, part 2</title>
    <updated>2018-08-07T00:00:00+00:00</updated>
    <content type="html">
    In the previous chapter we&apos;ve learnt how to use variables and arithmetic functions.
Now it&apos;s time to learn how to make our own functions.
    </content>
    <link href="https://www.baturin.org/blog/introduction-to-ocaml-part-2/" rel="alternate"/>
  </entry>
  
  <entry>
    <id>https://www.baturin.org/blog/introduction-to-ocaml/</id>
    <title>Introduction to OCaml</title>
    <updated>2018-08-06T00:00:00+00:00</updated>
    <content type="html">
    This post series started as a response to requests from some friends curious about OCaml.
There are quite a few nice books already, but I realized that if I just recommend them any one of those
books, it still will leave me with quite a few things to explain in depth, or force me to recommend another
just to learn about that part. So I thought I may as well write something that hopefully will allow
a person who already knows how to program in some other language get started with writing OCaml programs
and continue learning on their own and find their own sources.
    </content>
    <link href="https://www.baturin.org/blog/introduction-to-ocaml/" rel="alternate"/>
  </entry>
  
  <entry>
    <id>https://www.baturin.org/blog/implementing-sets-with-functions-alone/</id>
    <title>Implementing sets with functions alone</title>
    <updated>2018-04-12T00:00:00+00:00</updated>
    <content type="html">
    Implementation of sets using nothing but functions would be one of the first tricks in the
“100 Fun Things to Do With Functions and Closures” book if that book existed.
It may not be very practical, but it may help people get into the functional mindset.
We&apos;ll use &lt;a href=&quot;http://ocaml.org&quot;&gt;OCaml&lt;/a&gt; for demonstration.
    </content>
    <link href="https://www.baturin.org/blog/implementing-sets-with-functions-alone/" rel="alternate"/>
  </entry>
  
  <entry>
    <id>https://www.baturin.org/blog/duck-typing/</id>
    <title>Duck typing</title>
    <updated>2018-02-21T00:00:00+00:00</updated>
    <content type="html">
    So called “duck typing” is often poorly explained and thus often misunderstood.
Its name and the adage associated with it (“if it walks like a duck and quacks like a duck,
then it is a duck”) don&apos;t do it any favors either.
    </content>
    <link href="https://www.baturin.org/blog/duck-typing/" rel="alternate"/>
  </entry>
  
</feed>