'construct a binary tree from string in haskell

how do I construct from string representation of binary tree a binary tree ? I already wrote a function that takes a string representation and converts it to a list of all the characters (so if I have a 2digits or more number it will recognise it )

for example :

"3(4,3(,2(1,2)))" -> 

Just [Value 3,LPar,Value 4,Comma,Value 3,LPar,Comma,Value 2,LPar,Value 1,Comma,Value 2,RPar,RPar,RPar] -> 

Node (Leaf 4) 3 (Node Empty 3 (Node (Leaf 1) 2 (Leaf 2)))

I have seen some implementation in python but they are not helpful since there are no commas in those implementations



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source