package miaou-core

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file navigation.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
(*****************************************************************************)
(*                                                                           *)
(* SPDX-License-Identifier: MIT                                              *)
(* Copyright (c) 2025 Nomadic Labs <contact@nomadic-labs.com>                *)
(*                                                                           *)
(*****************************************************************************)

(** Page state wrapper with navigation support.
    Pages work with ['a pstate] instead of raw state, enabling
    framework-managed navigation without boilerplate. *)

type nav = Goto of string | Back | Quit

type 'a t = {s : 'a; nav : nav option}

let make s = {s; nav = None}

let goto page ps = {ps with nav = Some (Goto page)}

let back ps = {ps with nav = Some Back}

let quit ps = {ps with nav = Some Quit}

let pending ps = ps.nav

let update f ps = {ps with s = f ps.s}