1 import "JavaBuiltin" as Java
3 importJava "org.simantics.scl.runtime.unification.UTag" where
7 uTag :: Integer -> (t -> <Proc> a) -> (a -> t) -> UTag a t
9 importJava "java.lang.Object" where
12 uId :: a -> Unifiable a
13 uId = Java.unsafeCoerce
15 importJava "org.simantics.scl.runtime.unification.UCons" where
17 uCons :: UTag a t -> t -> Unifiable a
19 importJava "org.simantics.scl.runtime.unification.UPending" where
21 uPending :: (<Proc> a) -> Unifiable a
23 importJava "org.simantics.scl.runtime.unification.UVar" where
25 uVar :: <Proc> Unifiable a
27 importJava "org.simantics.scl.runtime.unification.Unification" where
28 unify :: Unifiable a -> Unifiable a -> <Proc> ()
29 extractWithDefault :: (<Proc> a) -> Unifiable a -> <Proc> a
32 createDefault :: <Proc> a
34 instance Default () where
37 instance (Default a, Default b) => Default (a, b) where
38 createDefault = (createDefault, createDefault)
40 instance (Default a, Default b, Default c) => Default (a, b, c) where
41 createDefault = (createDefault, createDefault, createDefault)
43 instance Default Double where
44 createDefault = fail "Double type has no default value."
46 instance Default Integer where
47 createDefault = fail "Integer type has no default value."
50 extract :: Default a => Unifiable a -> <Proc> a
51 extract u = extractWithDefault createDefault u
53 importJava "gnu.trove.map.hash.THashMap" where
57 createUMap :: <Proc> UMap a b
59 importJava "org.simantics.scl.runtime.unification.UMapUtils" where
61 putUMap :: UMap a b -> a -> Unifiable b -> <Proc> ()
63 putUMapC :: UMap a b -> a -> b -> <Proc> ()
65 getUMapWithDefault :: (<Proc> b) -> UMap a b -> a -> <Proc> b
67 getUMap :: Default b => UMap a b -> a -> <Proc> b
68 getUMap = getUMapWithDefault createDefault