1 (* Copyright (C) 1999-2005 Henry Cejtin, Matthew Fluet, Suresh
2 * Jagannathan, and Stephen Weeks.
4 * MLton is released under a BSD-style license.
5 * See the file MLton-LICENSE for details.
7 (*-------------------------------------------------------------------*)
9 (*-------------------------------------------------------------------*)
11 functor Type (): TYPE =
22 exception Incompatible
24 fun combineSet(EmptySet, EmptySet) = EmptySet
25 | combineSet(EmptySet, Set t) = Set t
26 | combineSet(Set t, EmptySet) = Set t
27 | combineSet(Set t, Set t') = Set(combineElt(t, t'))
28 and combineElt(Base, Base) = Base
29 | combineElt(Pair(t, t1), Pair(t', t1')) =
30 Pair(combineElt(t, t'), combineElt(t1, t1'))
31 | combineElt(EltSet t, EltSet t') = EltSet(combineSet(t, t'))
32 | combineElt _ = raise Incompatible
34 fun combineToCompat combine a =
35 (combine a ; true) handle Incompatible => false
40 val combine = combineSet
41 val areCompatible = combineToCompat combine
47 val combine = combineElt
48 val areCompatible = combineToCompat combine
51 fun combineSetElt(EmptySet, t) = Set t
52 | combineSetElt(Set t, t') = Set(Elt.combine(t, t'))
54 val areCompatibleSetElt = combineToCompat combineSetElt
58 structure Type = Type()