Logic programming in Scala, part 3: unification and state
In this post I want to build on the backtracking logic monad we covered last time by adding unification, yielding an embedded DSL for Prolog-style logic programming.PrologHere is a small Prolog...
View ArticleLogic programming in Scala, part 2: backtracking
In the previous post we saw how to write computations in a logic monad, where a “value” is a choice among alternatives, and operating on a value means operating on all the alternatives.Our first...
View ArticleLogic programming in Scala, part 1
I got a new job where I am hacking some Scala. I thought I would learn something by translating some functional code into Scala, and a friend had recently pointed me to Kiselyov et al.’s Backtracking,...
View ArticleThree uses for a binary heap
Lately I have been interviewing for jobs, so doing a lot of whiteboard programming, and binary heaps keep arising in the solutions to these interview problems. There is nothing new or remarkable about...
View ArticleReading Camlp4, part 11: syntax extensions
In this final (?) post in my series on Camlp4, I want at last to cover syntax extensions. A nontrivial syntax extension involves almost all the topics we have previously covered, so it seems fitting...
View Articleocamljs 0.3
I am happy to announce version 0.3 of ocamljs. Ocamljs is a system for compiling OCaml to Javascript. It includes a Javascript back-end for the OCaml compiler, as well as several support libraries,...
View ArticleMixing monadic and direct-style code with delimited continuations
The Lwt library is a really nice way to write concurrent programs. A big downside, however, is that you can’t use direct-style libraries with it. Suppose we’re writing an XMPP server, and we want to...
View ArticleReading Camlp4, part 10: custom lexers
As a final modification to our running JSON quotation example, I want to repair a problem noted in the first post—that the default lexer does not match the JSON spec—and in doing so demonstrate the use...
View ArticleReading Camlp4, part 9: implementing antiquotations
In this post I want to complicate the JSON quotation library from the previous post by adding antiquotations.AST with antiquotationsIn order to support antiquotations we will need to make some changes...
View ArticleReading Camlp4, part 8: implementing quotations
The Camlp4 system of quotations and antiquotations is an awesome tool for producing and consuming OCaml ASTs. In this post (and the following one) we will see how to provide this facility for other...
View ArticleReading Camlp4, part 7: revised syntax
As we have seen, Camlp4 contains an alternative syntax for OCaml, the “revised” syntax, which attempts to correct some infelicities of the original syntax, and to make it easier to parse and...
View ArticleReading Camlp4, part 6: parsing
In this post I want to discuss Camlp4’s stream parsers and grammars. Since the OCaml parsers in Camlp4 (which we touched on previously) use them, it’s necessary to understand them in order to write...
View ArticleHow froc works
.post img { border: none; } I am happy to announce the release of version 0.2 of the froc library for functional reactive programming in OCaml. There are a number of improvements:better event model:...
View Articleorpc 0.3
I am happy to announce version 0.3 of orpc, a tool for generating RPC bindings from OCaml signatures. Orpc can generate ONC RPC stubs for use with Ocamlnet (in place of ocamlrpcgen), and it can also...
View ArticleUpdated backtrace patch
I’ve updated my backtracepatch to work with OCaml 3.11.x as well as 3.10.x. The patch providesaccess to backtraces from within a program (this is already provided in stock 3.11.x)backtraces for...
View ArticleInside OCaml objects
In the ocamljs project I wanted to implement the OCaml object system in a way that is interoperable with Javascript objects. Mainly I wanted to be able to call Javascript methods with the OCaml method...
View ArticleReading Camlp4, part 5: filters
Hey, long time no see!It is high time to get back to Camlp4, so I would like to pick up the thread by covering Camlp4 filters. We have previously considered the parsing and pretty-printing facilities...
View ArticleLwt and Concurrent ML
Programming concurrent systems with threads and locks is famously, even fabulously, error-prone. With Lwt's cooperative threads you don't have to worry so much about protecting data structures against...
View ArticleSudoku in ocamljs, part 3: functional reactive programming
In part 1 and part 2 of this series, we made a simple Sudoku game and connected it to a game server. In this final installment I want to revisit how we check that a board satisfies the Sudoku rules....
View ArticleSudoku in ocamljs, part 2: RPC over HTTP
Last time we made a simple user interface for Sudoku with the Dom module of ocamljs. It isn't a very fun game though since there are no pre-filled numbers to constrain the board. So let's add a button...
View Article