Skip to content

Instantly share code, notes, and snippets.

@serefarikan
Forked from daxfohl/addChild.fs
Created October 10, 2020 08:34
Show Gist options
  • Save serefarikan/91ab342f263e5f2078812dc02bbc9bf3 to your computer and use it in GitHub Desktop.
Save serefarikan/91ab342f263e5f2078812dc02bbc9bf3 to your computer and use it in GitHub Desktop.
let addChild updateNode addNode value parent =
match withNewChild value parent with
| None -> async.Return None
| Some (newParent, child) as path ->
async { do! addNode child
do! updateNode newParent
return Some child }
let addChildById getNode updateNode addNode logAction value parentId =
async { let! parent = getNode parentId
let! childOpt = addChild updateNode addNode value parent
match childOpt with
| None -> return None
| Some child ->
let action = AddNode { value = value; nodeId = nodeId; leafId = child.id }
do! logAction action
return Some child.id }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment