haskellihp

How to use forEach with multiple traversables?


I am not able to find a way where I can use forEach with multiple traversables meaning a function that is fn :: _ -> _ -> Html rather than just fn :: _ -> Html and I don't think the documentation shows a way.

I have tried: {forEach traversable1 (fn traversable2)}, this doesn't really work, but it does for a non-traversable. I also tried something similar to this, so let tvsbl :: ([_], [_]) ... {forEach tsbl fn}, that hasn't worked either.


Solution

  • You could use zip:

    [hsx|
        {forEach (zip traversable1 traversable2) renderBoth}
    |]
        where
            renderBoth item1 item2 = [hsx|
                <i>{item1}</i>
            |]