[Haskell-cafe] Looking for feedback on my attempt at a tree construction edsl

C K Kashyap ckkashyap at gmail.com
Tue Mar 22 17:29:40 CET 2011


Hi,
With my "edsl", one can describe a tree like this -

import TreeEdsl
import Data.Tree

createTree :: TreeContext String ()
createTree = do
insertSubTree "Fruits" $ do
insertLeaf "Apple"
insertLeaf "Mango"
insertSubTree "Arbitrary" $ do
insertSubTree "Numbers" $ do
insertLeaf "1"
insertLeaf "2"
insertLeaf "3"
insertSubTree "Letters" $ do
insertLeaf "A"
insertLeaf "B"
insertLeaf "C"
return ()
main = do
tree <- process "root" createTree
putStrLn (drawTree (fmap show tree))
return ()


and get a tree like this -

"root"
|
+- "Arbitrary"
|  |
|  +- "Letters"
|  |  |
|  |  +- "C"
|  |  |
|  |  +- "B"
|  |  |
|  |  `- "A"
|  |
|  `- "Numbers"
|     |
|     +- "3"
|     |
|     +- "2"
|     |
|     `- "1"
|
`- "Fruits"
   |
   +- "Mango"
   |
   `- "Apple"


My code is here
https://github.com/ckkashyap/LearningPrograms/blob/master/Haskell/edsl/TreeEdsl.hs

I'd appreciate your feedback on this. Does this qualify to be a edsl?

Regards,
Kashyap
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110322/6e83ba0c/attachment.htm>


More information about the Haskell-Cafe mailing list