Created
February 22, 2024 09:13
-
-
Save stijnmoreels/bc644c772af10521f16c3d568e987357 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A lens that provides the name of the guest. | |
let name_ : ResultLens<Guest, string> = | |
(fun g -> Ok g.Name), (fun n _ -> Guest.create n) | |
// A lens on the guest list that provides the individual guests on the list. | |
let guests_ : ResultLens<GuestList, Guest list> = | |
(fun (GuestList xs) -> Ok xs), fun xs _ -> GuestList.create xs | |
// A lens that points to a single guest on the guest list. | |
let guest_ name : ResultLens<GuestList, Guest> = | |
guests_ >=> List.single_ (fun { Name = n } -> n = name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment