@@ -45,9 +45,6 @@ exception BotValue
4545(* * Exception raised by a bottomless lattice in place of a bottom value.
4646 Surrounding lattice functors may handle this on their own. *)
4747
48- exception Unsupported of string
49- let unsupported x = raise (Unsupported x)
50-
5148exception Invalid_widen of Pretty. doc
5249
5350let () = Printexc. register_printer (function
@@ -93,10 +90,10 @@ struct
9390 include Base
9491 let leq = equal
9592 let join x y =
96- if equal x y then x else raise ( Unsupported " fake join " )
93+ if equal x y then x else raise TopValue
9794 let widen = join
9895 let meet x y =
99- if equal x y then x else raise ( Unsupported " fake meet " )
96+ if equal x y then x else raise BotValue
10097 let narrow = meet
10198 include NoBotTop
10299
@@ -259,24 +256,36 @@ struct
259256 | (_ , `Top) -> `Top
260257 | (`Bot, x ) -> x
261258 | (x , `Bot) -> x
262- | (`Lifted x , `Lifted y ) -> `Lifted (Base. join x y)
259+ | (`Lifted x , `Lifted y ) ->
260+ try `Lifted (Base. join x y)
261+ with TopValue -> `Top
263262
264263 let meet x y =
265264 match (x,y) with
266265 | (`Bot, _ ) -> `Bot
267266 | (_ , `Bot) -> `Bot
268267 | (`Top, x ) -> x
269268 | (x , `Top) -> x
270- | (`Lifted x , `Lifted y ) -> `Lifted (Base. meet x y)
269+ | (`Lifted x , `Lifted y ) ->
270+ try `Lifted (Base. meet x y)
271+ with BotValue -> `Bot
271272
272273 let widen x y =
273274 match (x,y) with
274- | (`Lifted x , `Lifted y ) -> `Lifted (Base. widen x y)
275+ | (`Lifted x , `Lifted y ) ->
276+ begin
277+ try `Lifted (Base. widen x y)
278+ with TopValue -> `Top
279+ end
275280 | _ -> y
276281
277282 let narrow x y =
278283 match (x,y) with
279- | (`Lifted x , `Lifted y ) -> `Lifted (Base. narrow x y)
284+ | (`Lifted x , `Lifted y ) ->
285+ begin
286+ try `Lifted (Base. narrow x y)
287+ with BotValue -> `Bot
288+ end
280289 | (_ , `Bot) -> `Bot
281290 | (`Top, y ) -> y
282291 | _ -> x
@@ -315,7 +324,7 @@ struct
315324 | (x , `Bot) -> x
316325 | (`Lifted x , `Lifted y ) ->
317326 try `Lifted (Base. join x y)
318- with Uncomparable -> `Top
327+ with Uncomparable | TopValue -> `Top
319328
320329 let meet x y =
321330 match (x,y) with
@@ -325,20 +334,24 @@ struct
325334 | (x , `Top) -> x
326335 | (`Lifted x , `Lifted y ) ->
327336 try `Lifted (Base. meet x y)
328- with Uncomparable -> `Bot
337+ with Uncomparable | BotValue -> `Bot
329338
330339 let widen x y =
331340 match (x,y) with
332341 | (`Lifted x , `Lifted y ) ->
333- (try `Lifted (Base. widen x y)
334- with Uncomparable -> `Top )
342+ begin
343+ try `Lifted (Base. widen x y)
344+ with Uncomparable | TopValue -> `Top
345+ end
335346 | _ -> y
336347
337348 let narrow x y =
338349 match (x,y) with
339350 | (`Lifted x , `Lifted y ) ->
340- (try `Lifted (Base. narrow x y)
341- with Uncomparable -> `Bot )
351+ begin
352+ try `Lifted (Base. narrow x y)
353+ with Uncomparable | BotValue -> `Bot
354+ end
342355 | (_ , `Bot) -> `Bot
343356 | (`Top, y ) -> y
344357 | _ -> x
@@ -378,11 +391,11 @@ struct
378391 | (x , `Bot) -> x
379392 | (`Lifted1 x , `Lifted1 y ) -> begin
380393 try `Lifted1 (Base1. join x y)
381- with Unsupported _ -> `Top
394+ with TopValue -> `Top
382395 end
383396 | (`Lifted2 x , `Lifted2 y ) -> begin
384397 try `Lifted2 (Base2. join x y)
385- with Unsupported _ -> `Top
398+ with TopValue -> `Top
386399 end
387400 | _ -> `Top
388401
@@ -394,11 +407,11 @@ struct
394407 | (x , `Top) -> x
395408 | (`Lifted1 x , `Lifted1 y ) -> begin
396409 try `Lifted1 (Base1. meet x y)
397- with Unsupported _ -> `Bot
410+ with BotValue -> `Bot
398411 end
399412 | (`Lifted2 x , `Lifted2 y ) -> begin
400413 try `Lifted2 (Base2. meet x y)
401- with Unsupported _ -> `Bot
414+ with BotValue -> `Bot
402415 end
403416 | _ -> `Bot
404417
@@ -489,7 +502,9 @@ struct
489502 match (x,y) with
490503 | (`Bot, _ ) -> `Bot
491504 | (_ , `Bot) -> `Bot
492- | (`Lifted x , `Lifted y ) -> `Lifted (Base. meet x y)
505+ | (`Lifted x , `Lifted y ) ->
506+ try `Lifted (Base. meet x y)
507+ with BotValue -> `Bot
493508
494509 let widen x y =
495510 match (x,y) with
@@ -498,7 +513,11 @@ struct
498513
499514 let narrow x y =
500515 match (x,y) with
501- | (`Lifted x , `Lifted y ) -> `Lifted (Base. narrow x y)
516+ | (`Lifted x , `Lifted y ) ->
517+ begin
518+ try `Lifted (Base. narrow x y)
519+ with BotValue -> `Bot
520+ end
502521 | (_ , `Bot) -> `Bot
503522 | _ -> x
504523end
@@ -525,7 +544,9 @@ struct
525544 match (x,y) with
526545 | (`Top, x ) -> `Top
527546 | (x , `Top) -> `Top
528- | (`Lifted x , `Lifted y ) -> `Lifted (Base. join x y)
547+ | (`Lifted x , `Lifted y ) ->
548+ try `Lifted (Base. join x y)
549+ with TopValue -> `Top
529550
530551 let meet x y =
531552 match (x,y) with
@@ -535,7 +556,11 @@ struct
535556
536557 let widen x y =
537558 match (x,y) with
538- | (`Lifted x , `Lifted y ) -> `Lifted (Base. widen x y)
559+ | (`Lifted x , `Lifted y ) ->
560+ begin
561+ try `Lifted (Base. widen x y)
562+ with TopValue -> `Top
563+ end
539564 | _ -> y
540565
541566 let narrow x y =
553578module Liszt (Base : S ) =
554579struct
555580 include Printable. Liszt (Base )
556- let bot () = raise (Unsupported " bot?" )
557- let is_top _ = false
558- let top () = raise (Unsupported " top?" )
559- let is_bot _ = false
581+ include NoBotTop
560582
561583 let leq =
562584 let f acc x y = Base. leq x y && acc in
0 commit comments