diff options
author | Rodolphe Lepigre <rodolphe.lepigre@inria.fr> | 2018-12-13 19:56:39 +0100 |
---|---|---|
committer | Gabriel Scherer <gabriel.scherer@gmail.com> | 2020-01-28 11:39:52 +0100 |
commit | beb750b5eece198e002d7c4f54fe0b5a8dfef05f (patch) | |
tree | 74ab06db6b689e1cabb2f8f924f66776d7c305e4 /typing/types.ml | |
parent | 20b62c83864142f035ccfb799bc57d44e43e928e (diff) | |
download | ocaml-beb750b5eece198e002d7c4f54fe0b5a8dfef05f.tar.gz |
typedecl_separability: interfaces and basic definitions, implementations missing
Diffstat (limited to 'typing/types.ml')
-rw-r--r-- | typing/types.ml | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/typing/types.ml b/typing/types.ml index 3bd25556e5..53bd7c961f 100644 --- a/typing/types.ml +++ b/typing/types.ml @@ -136,6 +136,32 @@ module Variance = struct let get_lower v = (mem Pos v, mem Neg v, mem Inv v, mem Inj v) end +module Separability = struct + type t = Ind | Sep | Deepsep + type signature = t list + let eq (m1 : t) m2 = (m1 = m2) + let rank = function + | Ind -> 0 + | Sep -> 1 + | Deepsep -> 2 + let compare m1 m2 = compare (rank m1) (rank m2) + let max m1 m2 = if rank m1 >= rank m2 then m1 else m2 + + let print ppf = function + | Ind -> Format.fprintf ppf "Ind" + | Sep -> Format.fprintf ppf "Sep" + | Deepsep -> Format.fprintf ppf "Deepsep" + + let print_signature ppf modes = + let pp_sep ppf () = Format.fprintf ppf ",@," in + Format.fprintf ppf "@[(%a)@]" + (Format.pp_print_list ~pp_sep print) modes + + let default_signature ~arity = + let default_mode = if Config.flat_float_array then Deepsep else Ind in + List.init arity (fun _ -> default_mode) +end + (* Type definitions *) type type_declaration = |