Skip to content

Instantly share code, notes, and snippets.

@jlouis
Last active July 20, 2016 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlouis/902f3b8b01d24abaae712b87b5b556bb to your computer and use it in GitHub Desktop.
Save jlouis/902f3b8b01d24abaae712b87b5b556bb to your computer and use it in GitHub Desktop.
#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
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