Skip to content

Commit

Permalink
ush - vpunch - add curly bracket surrounded arg support (fixes #41) (#42
Browse files Browse the repository at this point in the history
)

* ush - vpunch - add curly bracket surrounded arg support (fixes #41)

* kxc-api1 - worklogger informative-summary - add ?warnings

* kxclib - add MonadOps.{mlift,mwrap,do_cond,do_if}

* ush - check for warnings when punching start entries (fixes #39)

* ush web - wlstat - add warnings section (fixes #38)

* kxc-api1 - worklogger informative-summary - add ?outputForRelevantPersonnelOnly
  • Loading branch information
haochenx authored Apr 20, 2024
1 parent c120d35 commit 663a98b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
13 changes: 13 additions & 0 deletions classic/kxclib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,11 @@ module type MonadOpsS = sig
(** monadic version of {!constant} *)
val returning : 'a -> 'b -> 'a t

val mlift : ('a -> 'b) -> ('a -> 'b t)
val mwrap : ('a -> 'b) -> ('a t -> 'b t)
val do_cond : bool -> ('a -> 'b t) -> ('a -> 'b t) -> 'a -> 'b t
val do_if : bool -> ('a -> unit t) -> 'a -> unit t

val sequence_list : 'a t list -> 'a list t

(** monadic binding version of {!sequence_list} *)
Expand Down Expand Up @@ -432,6 +437,14 @@ module MonadOps(M : sig

let returning x = fun _ -> return x

let mlift = fun f x -> f x |> return

let mwrap = fun f m -> m >>= mlift f

let do_cond = fun c f1 f2 -> (if c then f1 else f2)

let do_if = fun c f -> do_cond c f (returning ())

let sequence_list ms =
List.fold_left (fun acc m ->
acc >>= fun acc ->
Expand Down
15 changes: 15 additions & 0 deletions intf/kxclib.mli
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,21 @@ module type MonadOpsS = sig
(** monadic version of {!constant} *)
val returning : 'a -> 'b -> 'a t

val mlift : ('a -> 'b) -> ('a -> 'b t)

val mwrap : ('a -> 'b) -> ('a t -> 'b t)

(** [m >>= do_cond cond f_true f_false] performs [f_true] or [f_false]
on value enclosed in [m],
respectively when [cond] is [true] or [false];
functionally equiv. to [fun c f1 f2 -> if c then f1 else f2] but
return type of [f1] and [f2] is restricted to [_ t] *)
val do_cond : bool -> ('a -> 'b t) -> ('a -> 'b t) -> 'a -> 'b t

(** [m >>= do_if cond f] is equiv. to [m >>= do_cond cond f (returning ())] *)
val do_if : bool -> ('a -> unit t) -> 'a -> unit t

val sequence_list : 'a t list -> 'a list t

(** monadic binding version of {!sequence_list} *)
Expand Down

0 comments on commit 663a98b

Please sign in to comment.