Skip to content

Instantly share code, notes, and snippets.

module Age =
type Age = private Age of int
let create (age : int) : Age option =
if age < 0 then None else Some (Age age)
module Application =
let invalidAge = Age.create -1 // none
let validAge = Age.create 10 // some
@dsshep
dsshep / records.cs
Last active March 16, 2020 13:59
Record like functionality in C#
// In F# if we have a record and instance:
type RecordOne = {
PropOne: string
PropTwo: int
}
let recordOne = { PropOne = "PropOne"; PropTwo = 1 }
// it can then be updated as so: