2

Hi There!

Say I have a gigantic multi-node Tree in Haskell where each node contains HTML content of each page.

Using Yesod, the user will access a web page with the URL /myPage and the Handler

getMyPageR :: Handler Html 

will be called.

What I want is the HTML content of the page to be generated by the current tree node.

In the tree, we start off at the root, we extract the HTML content of the current node and show it as the current page. In each page, there's multiple buttons which represents the user's choices. There's one button per child of the current node. Then, depending on the user's choice, the tree will go down one level to the specific child the user chose and new HTML content will appear. The user can then make another choice, the tree again goes down one level and new HTML content appears. So on and so forth.

Essentially, every choice by the user brings the tree down one level until we arrive at a leaf node.

I was thinking of implementing this using Zippers in Haskell so that I can easily travel through the tree and keep Breadcrumbs of where I traveled.

What is a good solution to implement this in Yesod? I would like this good solution to include the use of Zippers.

One solution could be to send the Tree through Sessions using POST/Redirect/GET on the same page, but if the tree is too big, it won't work.

Don't hesitate to ask me to clarity my question if it's not clear enough.

Thanks in advance.

kolam
  • 731
  • 4
  • 17
  • 1
    Can you clarify to what level this interacts with the user? Is each "button-click" on the web page traversing the tree down one level? – Tarrasch Oct 21 '13 at 20:02
  • @Tarrasch Thanks, I clarified my question. – kolam Oct 21 '13 at 23:19
  • Have you thought about the best practice of keeping websites stateless? `getMyPageR :: TreePath -> Handler Html`. Something like `getMyPageR [MoveLeft, MoveLeft, MoveRight]` But here I'm assuming the tree is globally available. Is it? – Tarrasch Oct 22 '13 at 07:33
  • @Tarrash Well, the tree is simply declared in the same file as the getMyPageR Handler, so yeah it's globally available. So you're saying that the best way would be to send the directions in the parameters of the URL? For example, /myPage/"put directions here" . – kolam Oct 22 '13 at 12:28
  • Well. I'm not sure if that's the best way, but one pro is that it's stateless. – Tarrasch Oct 22 '13 at 16:36
  • I would also be interested in a solution to this situation. – Fawar Nov 05 '13 at 01:01

0 Answers0