If you add an instance of IsString to handle leaf construction you can get it down to
You could turn 'insertSubTree' into and operator, and shorten "insertLeaf"
createTree = do
"Fruits" +> do
leaf "Apple"
leaf "Mango
"Arbitrary" +> do
leaf "1"
-- and so on...
It's a little bit more concise.
But I fail to see the use of TreeContext being an instance of Monad.
2011/3/22 C K Kashyap <ckkashyap@gmail.com>_______________________________________________Hi,With my "edsl", one can describe a tree like this -import TreeEdslimport Data.TreecreateTree :: TreeContext String ()createTree = doinsertSubTree "Fruits" $ doinsertLeaf "Apple"insertLeaf "Mango"insertSubTree "Arbitrary" $ doinsertSubTree "Numbers" $ doinsertLeaf "1"insertLeaf "2"insertLeaf "3"insertSubTree "Letters" $ doinsertLeaf "A"insertLeaf "B"insertLeaf "C"return ()main = dotree <- process "root" createTreeputStrLn (drawTree (fmap show tree))return ()and get a tree like this -"root"|+- "Arbitrary"| || +- "Letters"| | || | +- "C"| | || | +- "B"| | || | `- "A"| || `- "Numbers"| || +- "3"| || +- "2"| || `- "1"|`- "Fruits"|+- "Mango"|`- "Apple"I'd appreciate your feedback on this. Does this qualify to be a edsl?Regards,Kashyap
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe