File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,20 @@ let map v f = match v with Nothing -> Nothing | _ -> f v
8383
8484let ( let + ) = map
8585
86+ let default_of_type = function
87+ | Ty. Ty_bool -> False
88+ | Ty_int -> Int 0
89+ | Ty_real -> Real 0.0
90+ | Ty_str -> Str " "
91+ | Ty_bitv m -> Bitv (Bitvector. make Z. zero m)
92+ | Ty_fp 32 -> Num (F32 0l )
93+ | Ty_fp 64 -> Num (F64 0L )
94+ | Ty_list -> List []
95+ | Ty_unit -> Unit
96+ | Ty_none -> Nothing
97+ | (Ty_fp _ | Ty_app | Ty_regexp | Ty_roundingMode ) as ty ->
98+ Fmt. failwith " No default value for type %a" Ty. pp ty
99+
86100let rec pp fmt = function
87101 | True -> Fmt. string fmt " true"
88102 | False -> Fmt. string fmt " false"
Original file line number Diff line number Diff line change @@ -47,6 +47,9 @@ val map : t -> (t -> t) -> t
4747(* * [let+ v f] is a convenience operator for applying [f] to [v]. *)
4848val ( let + ) : t -> (t -> t) -> t
4949
50+ (* * [default_of_type ty] returns the default value for type [ty]. *)
51+ val default_of_type : Ty .t -> t
52+
5053(* * {1 Pretty Printing} *)
5154
5255(* * [pp fmt v] pretty-prints the value [v] using the formatter [fmt]. *)
You can’t perform that action at this time.
0 commit comments