Last active
February 18, 2025 17:59
-
-
Save tjdevries/19b968cf07a6681d25bec2612f080fd5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module User = struct | |
type t = [ `user of string ] | |
let t user = `user "teej_dv" | |
let get (l : [> t ] list) : string = | |
Core.List.find_map l ~f:(function | |
| `user s -> Some s | |
| _ -> None) | |
|> Core.Option.value_exn | |
;; | |
end | |
(* would be written like, i think you can actually generate from this haha, but i would have to check *) | |
module%context User = [`user of string] | |
module Log = struct | |
type t = [ `log of string -> unit ] | |
let t log = `log print_endline | |
end | |
(* this is the expanded result *) | |
let ctx : [ User.t | Log.t ] list = [ User.t "teej_dv"; Log.t print_endline ] | |
(* with ppx, not yet written *) | |
let%context ctx = [ User.t "teej_dv"; Log.t print_endline ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment