]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.db/scl/Simantics/DB.scl
Sync git svn branch with SVN repository r33219.
[simantics/platform.git] / bundles / org.simantics.scl.db / scl / Simantics / DB.scl
index ac50e3e73525dab3bd2f5afb71c59a0ab97800ed..02396067875b83abb5c4fc25e44b4841bb7e47e6 100644 (file)
@@ -455,4 +455,28 @@ lift2Write f x y = syncWrite (\_ -> f x y)
 \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