You could turn &#39;insertSubTree&#39; into and operator, and shorten &quot;insertLeaf&quot;<br><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">createTree = do</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">    &quot;Fruits&quot; +&gt; do</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                leaf &quot;Apple&quot;</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">                leaf &quot;Mango</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    &quot;Arbitrary&quot; +&gt; do<br>

                   leaf &quot;1&quot;<br>    -- and so on...<br><br><span style="font-family: arial,helvetica,sans-serif;">It&#39;s a little bit more concise.</span><br></span>But I fail to see the use of TreeContext being an instance of Monad.<br>

<br><div class="gmail_quote">2011/3/22 C K Kashyap <span dir="ltr">&lt;<a href="mailto:ckkashyap@gmail.com">ckkashyap@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

Hi,<div>With my &quot;edsl&quot;, one can describe a tree like this -</div><div><br></div><div>import TreeEdsl</div><div>import Data.Tree</div><div><br></div><div>createTree :: TreeContext String ()</div><div>createTree = do</div>


<div><span style="white-space: pre-wrap;">        </span>insertSubTree &quot;Fruits&quot; $ do</div><div><span style="white-space: pre-wrap;">                </span>insertLeaf &quot;Apple&quot;</div><div><span style="white-space: pre-wrap;">                </span>insertLeaf &quot;Mango&quot;</div>


<div><span style="white-space: pre-wrap;">        </span>insertSubTree &quot;Arbitrary&quot; $ do</div><div><span style="white-space: pre-wrap;">                </span>insertSubTree &quot;Numbers&quot; $ do</div>
<div><span style="white-space: pre-wrap;">                        </span>insertLeaf &quot;1&quot;</div><div><span style="white-space: pre-wrap;">                        </span>insertLeaf &quot;2&quot;</div><div><span style="white-space: pre-wrap;">                        </span>insertLeaf &quot;3&quot;</div>


<div><span style="white-space: pre-wrap;">                </span>insertSubTree &quot;Letters&quot; $ do</div><div><span style="white-space: pre-wrap;">                        </span>insertLeaf &quot;A&quot;</div><div><span style="white-space: pre-wrap;">                        </span>insertLeaf &quot;B&quot;</div>


<div><span style="white-space: pre-wrap;">                        </span>insertLeaf &quot;C&quot;</div><div><span style="white-space: pre-wrap;">        </span>return ()</div><div><span style="white-space: pre-wrap;">        </span></div>
<div>main = do</div><div><span style="white-space: pre-wrap;">        </span>tree &lt;- process &quot;root&quot; createTree</div><div><span style="white-space: pre-wrap;">        </span>putStrLn (drawTree (fmap show tree))</div>
<div><span style="white-space: pre-wrap;">        </span>return ()</div><div><br></div><div><br></div><div>and get a tree like this - </div><div><div><br></div><div>&quot;root&quot;</div><div>
|</div><div>+- &quot;Arbitrary&quot;</div><div>|  |</div><div>|  +- &quot;Letters&quot;</div><div>|  |  |</div><div>|  |  +- &quot;C&quot;</div><div>|  |  |</div><div>|  |  +- &quot;B&quot;</div><div>|  |  |</div><div>|  |  `- &quot;A&quot;</div>


<div>|  |</div><div>|  `- &quot;Numbers&quot;</div><div>|     |</div><div>|     +- &quot;3&quot;</div><div>|     |</div><div>|     +- &quot;2&quot;</div><div>|     |</div><div>|     `- &quot;1&quot;</div><div>|</div><div>


`- &quot;Fruits&quot;</div><div>   |</div><div>   +- &quot;Mango&quot;</div><div>   |</div><div>   `- &quot;Apple&quot;</div></div><div><br></div><div> </div><div><div>My code is here </div><div><a href="https://github.com/ckkashyap/LearningPrograms/blob/master/Haskell/edsl/TreeEdsl.hs" target="_blank">https://github.com/ckkashyap/LearningPrograms/blob/master/Haskell/edsl/TreeEdsl.hs</a></div>


</div><div><br></div><div>I&#39;d appreciate your feedback on this. Does this qualify to be a edsl?</div><div><br></div><div>Regards,</div><div>Kashyap</div>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br>