alexozer / flitter

A Livesplit-inspired speedrunning split timer for Linux/macOS terminal. Supports global hotkeys.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Be smarter about working with option

alexozer opened this issue · comments

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 >>=