-
-
Save jlouis/902f3b8b01d24abaae712b87b5b556bb 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
#require "core";; | |
#require "ppx_fields_conv";; | |
#use "z.ml";; | |
type t = { tag : bool; } | |
val tag : t -> bool = <fun> | |
module Fields : | |
sig | |
val names : string list | |
val tag : ([< `Read | `Set_and_create ], t, bool) Field.t_with_perm | |
val make_creator : | |
tag:(([< `Read | `Set_and_create ], t, bool) Field.t_with_perm -> | |
'a -> ('b -> bool) * 'c) -> | |
'a -> ('b -> t) * 'c | |
val create : tag:bool -> t | |
val map : | |
tag:(([< `Read | `Set_and_create ], t, bool) Field.t_with_perm -> bool) -> | |
t | |
val iter : | |
tag:(([< `Read | `Set_and_create ], t, bool) Field.t_with_perm -> unit) -> | |
unit | |
val fold : | |
init:'a -> | |
tag:('a -> | |
([< `Read | `Set_and_create ], t, bool) Field.t_with_perm -> 'b) -> | |
'b | |
val map_poly : ([< `Read | `Set_and_create ], t, 'a) Field.user -> 'a list | |
val for_all : | |
tag:(([< `Read | `Set_and_create ], t, bool) Field.t_with_perm -> bool) -> | |
bool | |
val exists : | |
tag:(([< `Read | `Set_and_create ], t, bool) Field.t_with_perm -> bool) -> | |
bool | |
val to_list : | |
tag:(([< `Read | `Set_and_create ], t, bool) Field.t_with_perm -> 'a) -> | |
'a list | |
module Direct : | |
sig | |
val iter : | |
t -> | |
tag:(([< `Read | `Set_and_create ], t, bool) Field.t_with_perm -> | |
t -> bool -> 'a) -> | |
'a | |
val fold : | |
t -> | |
init:'a -> | |
tag:('a -> | |
([< `Read | `Set_and_create ], t, bool) Field.t_with_perm -> | |
t -> bool -> 'b) -> | |
'b | |
val for_all : | |
t -> | |
tag:(([< `Read | `Set_and_create ], t, bool) Field.t_with_perm -> | |
t -> bool -> bool) -> | |
bool | |
val exists : | |
t -> | |
tag:(([< `Read | `Set_and_create ], t, bool) Field.t_with_perm -> | |
t -> bool -> bool) -> | |
bool | |
val to_list : | |
t -> | |
tag:(([< `Read | `Set_and_create ], t, bool) Field.t_with_perm -> | |
t -> bool -> 'a) -> | |
'a list | |
val map : | |
t -> | |
tag:(([< `Read | `Set_and_create ], t, bool) Field.t_with_perm -> | |
t -> bool -> bool) -> | |
t | |
val set_all_mutable_fields : 'a -> unit | |
end | |
end | |
type foo = Bar of int | Quux of t | |
let x = Quux { tag = true };; | |
val x : foo = Quux {tag = true} | |
tag x | |
Error: This expression has type foo but an expression was expected of type t | |
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
open Core.Std | |
type t = { tag : bool } [@@deriving fields] | |
type foo = Bar of int | |
| Quux of t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment