"graph"\r
"org.simantics.db.WriteGraph"\r
\r
-importJava "org.simantics.databoard.type.Datatype" where\r
- data Datatype\r
- @JavaName toString\r
- showDatatype :: Datatype -> String\r
-\r
-instance Show Datatype where\r
- show = showDatatype\r
-\r
-importJava "org.simantics.databoard.Bindings" where\r
- @JavaName getBinding \r
- datatypeBinding :: Datatype -> Binding Dynamic\r
-\r
-importJava "org.simantics.databoard.binding.mutable.Variant" where\r
- @JavaName "<init>"\r
- createVariant_ :: Binding Dynamic -> Dynamic -> Variant\r
- @JavaName "type"\r
- variantDatatype :: Variant -> Datatype\r
-\r
-createVariant :: Datatype -> Dynamic -> Variant\r
-createVariant dt v = createVariant_ (datatypeBinding dt) v\r
-\r
-importJava "org.simantics.databoard.Datatypes" where\r
- @JavaName translate\r
- translateDatatype :: String -> Datatype\r
-\r
importJava "org.simantics.db.Resource" where\r
"A resource is a node in a semantic graph."\r
data Resource\r
\r
@inline\r
lift3Write :: (a -> b -> c -> <WriteGraph,Proc> d) -> (a -> b -> c -> <Proc> d)\r
-lift3Write f x y z = syncWrite (\_ -> f x y z)
\ No newline at end of file
+lift3Write f x y z = syncWrite (\_ -> f x y z)\r
+\r
+"""\r
+Returns a child Browsable of the specified parent that has that is the child\r
+of the specified parent with the specified name path.\r
+"""\r
+childWithPath :: Browsable a => a -> [String] -> <ReadGraph> a\r
+childWithPath parent path = \r
+ foldl (\r name -> match possibleChild r name with\r
+ Just c -> c\r
+ Nothing -> fail ("Didn't find " + name + ".") \r
+ ) \r
+ parent path\r
+\r
+"""\r
+Like `childWithPath` but returns Maybe a which will be `Nothing` if no child\r
+was found.\r
+"""\r
+possibleChildWithPath :: Browsable a => a -> [String] -> <ReadGraph> Maybe a\r
+possibleChildWithPath parent path = \r
+ foldl (\r name -> match r with\r
+ Just c -> possibleChild c name\r
+ Nothing -> Nothing \r
+ ) \r
+ (Just parent) path\r