package querty

Build not yet checked
  1. Overview
  2. Docs
A simple build system for incremental and demand-driven computations

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.2.0.tar.gz
md5=572518804039bfafdf114a6c6f859250
sha512=0d839b2cba35a5489c5d1bc778d1bcd32d0d932ce9eb76bbbcdf365a96069691ca9cb0997cb73c3add99f621dca637eb4c49835661bdac0f8db8f421a4b4adc1

Description

A typesafe query based build system inspired by Salsa and Rock

README

Querty

A query based build system inspired by Rock.

Example

module CalculatorQueries = struct
  type (_, _) t =
    | Source : (int, Querty.input) t
    | Squared : (int, Querty.derived) t
    | SquaredDoubled : (int, Querty.derived) t

  let rank : type a k. (a, k) t -> int = function
    | Source -> 0
    | Squared -> 1
    | SquaredDoubled -> 3

  let compare : type a b k1 k2. (a, k1) t -> (b, k2) t -> (a, b) Querty.Order.t
      =
   fun x y ->
    let open Querty.Order in
    match (x, y) with
    | Source, Source -> Eq
    | Squared, Squared -> Eq
    | SquaredDoubled, SquaredDoubled -> Eq
    | _ -> if rank x < rank y then Lt else Gt

  let values_equal : type a k. (a, k) t -> a -> a -> bool =
   fun key a b -> match key with Source | Squared | SquaredDoubled -> a = b
end

module Engine = Querty.Make (CalculatorQueries)

let rules : type a. (a, Querty.derived) CalculatorQueries.t -> a =
 fun q ->
  match q with
  | Squared ->
      let source = Engine.read Source in
      source * source
  | SquaredDoubled ->
      let squared = Engine.fetch Squared in
      squared * 2

let run () =
  let a = Engine.fetch Squared in
  let b = Engine.fetch SquaredDoubled in
  (a, b)

let () =
  let db = Engine.init ~rules in
  Engine.set_input db Source 10;
  match Engine.run db run with
  | Ok (a, b) -> Printf.printf "squared: %d\nsquared & doubled: %d\n" a b
  | Error (Cycle _) -> print_endline "cycle error"
  | Error (MissingInput _) -> print_endline "missing input error"

Dependencies (3)

  1. gmap
  2. ocaml >= "5.5.0"
  3. dune >= "3.24"

Dev Dependencies (4)

  1. odoc with-doc
  2. alcotest with-test
  3. qcheck-alcotest with-test
  4. qcheck-core with-test

Optional Dependencies

None

Used by

None

Conflicts

None

Build status

This version of querty was published after the check.ci.ocaml.org run of against opam-repository 8d8d144, so it has no build results yet. check.ci runs about once a week.