aliases:DisambiguateTypes.environment ->
universe:DisambiguateTypes.multiple_environment option ->
'a -> 'b)
- ~(drop_aliases: 'b -> 'b)
+ ~(drop_aliases: ?minimize_instances:bool -> 'b -> 'b)
~(drop_aliases_and_clear_diff: 'b -> 'b)
(thing: 'a)
=
if use_mono_aliases && not instances then
drop_aliases res
else if user_asked then
- drop_aliases res (* one shot aliases *)
+ drop_aliases ~minimize_instances:true res (* one shot aliases *)
else
drop_aliases_and_clear_diff res
in
aliases:DisambiguateTypes.environment ->
universe:DisambiguateTypes.multiple_environment option ->
'a -> 'b * bool) ->
- drop_aliases:('b * bool -> 'b * bool) ->
+ drop_aliases:(?minimize_instances:bool -> 'b * bool -> 'b * bool) ->
drop_aliases_and_clear_diff:('b * bool -> 'b * bool) -> 'a -> 'b * bool
}
~drop_aliases_and_clear_diff) thing
}
-let drop_aliases (choices, user_asked) =
- (List.map (fun (d, a, b, c) -> d, a, b, c) choices),
+let drop_aliases ?(minimize_instances=false) (choices, user_asked) =
+ let module D = DisambiguateTypes in
+ let minimize d =
+ if not minimize_instances then
+ d
+ else
+ let rec aux =
+ function
+ [] -> []
+ | (D.Symbol (s,n),((descr,_) as ci)) as he::tl when n > 0 ->
+ if
+ List.for_all
+ (function
+ (D.Symbol (s2,_),(descr2,_)) -> s2 <> s || descr = descr2
+ | _ -> true
+ ) d
+ then
+ (D.Symbol (s,0),ci)::(aux tl)
+ else
+ he::(aux tl)
+ | (D.Num n,((descr,_) as ci)) as he::tl when n > 0 ->
+ if
+ List.for_all
+ (function (D.Num _,(descr2,_)) -> descr = descr2 | _ -> true) d
+ then
+ (D.Num 0,ci)::(aux tl)
+ else
+ he::(aux tl)
+ | he::tl -> he::(aux tl)
+ in
+ aux d
+ in
+ (List.map (fun (d, a, b, c) -> minimize d, a, b, c) choices),
user_asked
let drop_aliases_and_clear_diff (choices, user_asked) =