Skip to content

Instantly share code, notes, and snippets.

@mastoj
Created May 25, 2015 11:14
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mastoj/059f8cb24a4ae912be6f to your computer and use it in GitHub Desktop.
Save mastoj/059f8cb24a4ae912be6f to your computer and use it in GitHub Desktop.
module Person =
open System
type PersonState = private { id: Guid; name: string; age: int}
let createPerson id name age = {id = id; name = name; age = age}
let changeName name personState = {personState with name = name}
let changeAge age personState =
// some crazy business rule involving age
{personState with age = age}
module SomeOtherModule =
open System
open Person
// let bjorn = { id=System.Guid.NewGuid(); name="Bjørn Einar"; age=34} // won't compile
let bjorn = createPerson (Guid.NewGuid()) "Bjørn Einar" 34
let changedBjorn = bjorn |> changeName "Bjørn the less(?) confused"
let changedAgedBjorn = changedBjorn |> changeAge 30
@bjartwolf
Copy link

If this does what I think it does I will be very happy and indeed less confused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment