alexozer / flitter

A LiveSplit-inspired speedrunning split timer for Linux/macOS terminal. Supports global hotkeys.
MIT License
132 stars 11 forks source link

Be smarter about working with option #9

Closed alexozer closed 5 years ago

alexozer commented 5 years ago

We could use some of Core's facilities to make working with optional types more sane.

Some examples:

Option.map timer.comparison ~f:Archived_run.splits |> Option.bind ~f:(fun comp -> List.nth comp split_num) |> Option.bind ~f:Split.time
Option.merge (List.nth seg_durations i |> Option.join) (List.nth old_durations i |> Option.join) ~f:Time_ns.Span.min )
open Core
open Option.Let_syntax

let some_ten =
    let%map unpacked_option = Some 5 in
    unpacked_option * 2

Or >>| and >>=

alexozer commented 5 years ago

10