@@ -229,14 +229,25 @@ module Level = struct
229229 let pr prl s =
230230 hov 1 (str" {" ++ prlist_with_sep spc prl (elements s) ++ str" }" )
231231
232+
233+ module Huniverse_set =
234+ Hashcons. Make (
235+ struct
236+ type nonrec t = t
237+ let hashcons s =
238+ fold (fun x (h ,acc ) ->
239+ let hx, x = hcons x in
240+ Hashset.Combine. combine h hx, add x acc)
241+ s
242+ (0 ,empty)
243+ let eq s s' = Map.Set. equal s s'
244+ end )
245+
246+ let hcons = Hashcons. simple_hcons Huniverse_set. generate Huniverse_set. hcons ()
232247 end
233248
234249end
235250
236- type universe_level = Level .t
237-
238- type universe_set = Level.Set .t
239-
240251(* An algebraic universe [universe] is either a universe variable
241252 [Level.t] or a formal universe known to be greater than some
242253 universe variables and strictly greater than some (other) universe
@@ -444,6 +455,11 @@ let pr_constraint_type op =
444455 | Eq -> " = "
445456 in str op_str
446457
458+ let hash_constraint_type = function
459+ | Lt -> 0
460+ | Le -> 1
461+ | Eq -> 2
462+
447463module UConstraintOrd =
448464struct
449465 type t = univ_constraint
@@ -456,23 +472,6 @@ struct
456472 else Level. compare v v'
457473end
458474
459- module Constraints =
460- struct
461- module S = Set. Make (UConstraintOrd )
462- include S
463-
464- let pr prl c =
465- v 0 (prlist_with_sep spc (fun (u1 ,op ,u2 ) ->
466- hov 0 (prl u1 ++ pr_constraint_type op ++ prl u2))
467- (elements c))
468-
469- end
470-
471- let hash_constraint_type = function
472- | Lt -> 0
473- | Le -> 1
474- | Eq -> 2
475-
476475module Hconstraint =
477476 Hashcons. Make (
478477 struct
@@ -487,13 +486,23 @@ module Hconstraint =
487486
488487let hcons_constraint = Hashcons. simple_hcons Hconstraint. generate Hconstraint. hcons ()
489488
490- module Hconstraints = CSet. Hashcons ( UConstraintOrd )( struct
491- type t = UConstraintOrd .t
492- let hcons = hcons_constraint
493- end )
489+ module Constraints =
490+ struct
491+ module S = Set. Make ( UConstraintOrd )
492+ include S
494493
495- let hcons_constraints = Hashcons. simple_hcons Hconstraints. generate Hconstraints. hcons ()
494+ let pr prl c =
495+ v 0 (prlist_with_sep spc (fun (u1 ,op ,u2 ) ->
496+ hov 0 (prl u1 ++ pr_constraint_type op ++ prl u2))
497+ (elements c))
496498
499+ module Hconstraints = CSet. Hashcons (UConstraintOrd )(struct
500+ type t = UConstraintOrd .t
501+ let hcons = hcons_constraint
502+ end )
503+
504+ let hcons = Hashcons. simple_hcons Hconstraints. generate Hconstraints. hcons ()
505+ end
497506
498507(* * A value with universe constraints. *)
499508type 'a constrained = 'a * Constraints .t
@@ -533,7 +542,7 @@ let univ_level_rem u v min =
533542(* * A universe level substitution, note that no algebraic universes are
534543 involved *)
535544
536- type universe_level_subst = universe_level Level.Map .t
545+ type universe_level_subst = Level .t Level.Map .t
537546
538547(* * A set of universes with universe constraints.
539548 We linearize the set to a list after typechecking.
@@ -542,7 +551,7 @@ type universe_level_subst = universe_level Level.Map.t
542551
543552module ContextSet =
544553struct
545- type t = universe_set constrained
554+ type t = Level.Set .t constrained
546555
547556 let empty = (Level.Set. empty, Constraints. empty)
548557 let is_empty (univs , cst ) = Level.Set. is_empty univs && Constraints. is_empty cst
@@ -579,12 +588,16 @@ struct
579588 let levels (univs , _cst ) = univs
580589
581590 let size (univs ,_ ) = Level.Set. cardinal univs
582- end
583591
584- type universe_context_set = ContextSet .t
592+ let hcons (v ,c ) =
593+ let hv, v = Level.Set. hcons v in
594+ let hc, c = Constraints. hcons c in
595+ Hashset.Combine. combine hv hc, (v, c)
596+
597+ end
585598
586599(* * A value in a universe context (resp. context set). *)
587- type 'a in_universe_context_set = 'a * universe_context_set
600+ type 'a in_universe_context_set = 'a * ContextSet .t
588601
589602(* * Substitutions. *)
590603
@@ -617,31 +630,5 @@ let subst_univs_level_constraints subst csts =
617630
618631(* * Pretty-printing *)
619632
620- let pr_universe_context_set = ContextSet. pr
621-
622633let pr_universe_level_subst prl =
623634 Level.Map. pr prl (fun u -> str" := " ++ prl u ++ spc () )
624-
625- module Huniverse_set =
626- Hashcons. Make (
627- struct
628- type t = universe_set
629- let hashcons s =
630- Level.Set. fold (fun x (h ,acc ) ->
631- let hx, x = Level. hcons x in
632- Hashset.Combine. combine h hx, Level.Set. add x acc)
633- s
634- (0 ,Level.Set. empty)
635- let eq s s' =
636- Level.Set. equal s s'
637- end )
638-
639- let hcons_universe_set =
640- Hashcons. simple_hcons Huniverse_set. generate Huniverse_set. hcons ()
641-
642- let hcons_universe_context_set (v , c ) =
643- let hv, v = hcons_universe_set v in
644- let hc, c = hcons_constraints c in
645- Hashset.Combine. combine hv hc, (v, c)
646-
647- let hcons_univ x = Universe. hcons x
0 commit comments