VL – a F# DSL for the Layout of IOS Controls

Starting with IOS 6 Apple added Auto Layout – a language for specifying constraints on the layout of IOS controls. With Auto Layout one can express the height, width, sequence, spacing, margins, anchoring / docking, etc. of controls, as constraints.

Auto Layout constraints can be expressed in an untyped way as strings or one can use the underlying API. While feasible for Objective-C code, these approaches become awkward for other languages such as F#.

The VL DSL is meant to easily create IOS layouts in code in a strongly typed manner. The DSL makes use of F# Algebraic Data Types (Discriminated Unions), pattern matching and operator overloading. (Note that at the time of writing this post Xamarin has announced Xamarin.Forms which may make VL redundant).

Auto Layout :       H:| -10-[ctrl1]-[ctrl2]-10-|
VL                :       H [ !- 10. ; @! ctrl1 ; sp ; @! ctrl2;  !- 10. ]

The two constraints are equivalent; they layout two controls horizontally with 10 point margins at the left and right edges and a standard space in between.

Continue reading

Xamarin F# – Experience Report

For the past few months I have been working on an Android application that collects automotive CAN bus data – ultimately for analysis with BigData technologies such as Hadoop. I have already described some aspects of this project here and here. Thus far close to 2 Terabytes of data has been already collected.

In this post I would like to recount my experience of using F# with Xamarin for a real-world mobile application.

Continue reading

OpenXC based Android App

Recently launched an OpenXC (http://www.openxcplatform.com) based app for internal use. The app connects to the OpenXC dongle and collects CAN data for analytics. It is interesting to note that daily capture is in 100 megabyte range (depending on the vehicle and how long it is driven). The app is based on the Xamarin platform and written entirely in F# (also see this post). Here are some screen shots:

Message Rate


Message Frequency Histogram


Talking to your car – with OpenXC, Android, Xamarin & F#

Virtually all vehicles today operate an internal network called the CAN bus. Different modules (or ECUs – electronic control units) in the car communicate with each other via this network (e.g. engine, transmission, dashboard, etc.). In this post I reference a CAN bus reader built with F# and Xamarin.Android based on the OpenXC platform (http://openxcplatform.com/).

Update: Also see this post.

Continue reading

FAKE Script for ClickOnce Packaging of F# Apps

ClickOnce is very useful technology for delivering applications. Applications are published to the server but run on the client. If a new version is published to the server, the clients can easily upgrade to the new version via a single click. Such applications are sometimes called ‘smart clients’ because they fall somewhere between traditional rich clients and web applications.

In this post I share a build script for packaging F# projects for ClickOnce deployment.

Continue reading