Implement map function for Tree
jhrcek opened this issue · comments
Jan Hrcek commented
It would be nice if there was a map
function with signature map : (a -> b) -> Tree a -> Tree b
in the module Graph.Tree
. I can create a PR for that if you agree.
Expected implementation would be
map : (a -> b) -> Tree a -> Tree b
map f (MkTree totalSize maybeLabelAndChildren) =
MkTree totalSize <|
Maybe.map
(\( label, children ) -> ( f label, List.map (map f) children ))
maybeLabelAndChildren
Jan Hrcek commented
Closing as the PR implementing this was merged. Thank you.