import "JavaBuiltin" as Java importJava "org.simantics.scl.runtime.unification.UTag" where data UTag a t @JavaName "" uTag :: Integer -> (t -> a) -> (a -> t) -> UTag a t importJava "java.lang.Object" where data Unifiable a uId :: a -> Unifiable a uId = Java.unsafeCoerce importJava "org.simantics.scl.runtime.unification.UCons" where @JavaName "" uCons :: UTag a t -> t -> Unifiable a importJava "org.simantics.scl.runtime.unification.UPending" where @JavaName "" uPending :: ( a) -> Unifiable a importJava "org.simantics.scl.runtime.unification.UVar" where @JavaName "" uVar :: Unifiable a importJava "org.simantics.scl.runtime.unification.Unification" where unify :: Unifiable a -> Unifiable a -> () extractWithDefault :: ( a) -> Unifiable a -> a class Default a where createDefault :: a instance Default () where createDefault = () instance (Default a, Default b) => Default (a, b) where createDefault = (createDefault, createDefault) instance (Default a, Default b, Default c) => Default (a, b, c) where createDefault = (createDefault, createDefault, createDefault) instance Default Double where createDefault = fail "Double type has no default value." instance Default Integer where createDefault = fail "Integer type has no default value." @inline extract :: Default a => Unifiable a -> a extract u = extractWithDefault createDefault u importJava "gnu.trove.map.hash.THashMap" where data UMap a b @JavaName "" createUMap :: UMap a b importJava "org.simantics.scl.runtime.unification.UMapUtils" where @JavaName put putUMap :: UMap a b -> a -> Unifiable b -> () @JavaName put putUMapC :: UMap a b -> a -> b -> () @JavaName get getUMapWithDefault :: ( b) -> UMap a b -> a -> b getUMap :: Default b => UMap a b -> a -> b getUMap = getUMapWithDefault createDefault