Skip to content

HelloWorldProjectionFSharp

Yves Reynhout edited this page May 29, 2016 · 2 revisions

Introduction

If you're using F#, a lot of what Projac offers (to C#) is already present in your language. In fact, except when you're targeting a relational store, you don't really need Projac. Obviously, you will still want to take advantage of the techniques presented here.

Step 1 - Messages

Before you can write projections, you need to define the messages you are going to project. Record types are a very common way to define them in F#. For simplicity sake, we'll define our first message as follows.

[<CLIMutable>]
type PeopleWhoSaidHello = { People: string array };

This message captures a list of people, their names, that said hello. Pretty useless in and by itself, but useful enough for a Hello World.

Step 2 - Projection Declaration

Defining a projection in F# is just a matter of defining a function, like so:

Clone this wiki locally