<div dir="ltr"><div>><span style="font-size:12.8px">Do you mind explaining the invalid monad instance of Lucid and how it would impact a library user?</span><br></div><div><span style="font-size:12.8px">To my knowledge lucid uses a monad instance that follow the monad laws (what I meant by "valid") fine.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">It's blaze that's (somewhat) infamous for having an invalid monad instance. It used to be the case that (>>=) in blaze called 'error' -- the Monad instance was to just use (>>) = mappend. Looking now, the implementation has changed and my knowledge was out-of-date. I think it still violates the monad laws, but I don't know if as a user of blaze you'd ever be able to actually observe this, if that makes any sense.</span></div><div><br></div><div>For some fun discussions on this see:</div><div><span style="font-size:12.8px">- <a href="https://stackoverflow.com/questions/6399648/what-happens-to-you-if-you-break-the-monad-laws">https://stackoverflow.com/questions/6399648/what-happens-to-you-if-you-break-the-monad-laws</a></span><br></div><div><span style="font-size:12.8px">- <a href="https://www.reddit.com/r/haskell/comments/16iakr/what_happens_when_a_monad_violates_monadic_laws/">https://www.reddit.com/r/haskell/comments/16iakr/what_happens_when_a_monad_violates_monadic_laws/</a></span><br></div><div><br></div><div>How invalid monads <i>can</i> impact users is better explored in the SO question.</div><div><br></div>><span style="font-size:12.8px">Also, I'm assuming one shouldn't call the `compile` function each time a page needs to be rendered, right? Should one put the results of the `compile` function in a top-level Map and use those to get the speed gains?</span><div><span style="font-size:12.8px">The idea is to only compile a template once, ever. If you need to compile a template every time a page is rendered (though I can't actually think of a case where you would), you should probably just skip the middle-man, and use lucid (or blaze). It's not horribly slow, but you'd miss out on the benefits of nice-html by doing this.</span></div><div><br></div><div>Cheers</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 26, 2017 at 11:51 PM, Saurabh Nanda <span dir="ltr"><<a href="mailto:saurabhnanda@gmail.com" target="_blank">saurabhnanda@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thank you for putting comparisons and benchmarks, upfront.<div><br></div><div>Do you mind explaining the invalid monad instance of Lucid and how it would impact a library user?</div><div><br></div><div>Also, I'm assuming one shouldn't call the `compile` function each time a page needs to be rendered, right? Should one put the results of the `compile` function in a top-level Map and use those to get the speed gains?</div><div><br></div><div>Side comment, the use of `dynamic` makes it look similar to reflex `dyn*` API.</div><div><br></div><div>-- Saurabh.</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Thu, Oct 26, 2017 at 4:15 PM, Mike Ledger <span dir="ltr"><<a href="mailto:eleventynine@gmail.com" target="_blank">eleventynine@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">Hi Haskell-Cafe,<div><br></div><div>I've been working on and off on a HTML templating library that is slightly novel for a few months. </div><div><br></div><div>Here's the good parts:</div><div>* it's faster than lucid and blaze</div><div>* it has a valid monad instance</div><div>* it has another valid monad instance, that is slightly different!</div><div>* it paramaterises templates by the data they require</div><div>* the HTML5 combinators don't rely on any highly overloaded/overlapping typeclasses; type errors in nice-html templates tend to be nice monomorphic type mismatches</div><div><br></div><div>To achieve this, it has a distinct compilation phase (at runtime) for templates. This means the actual rendering function does very little beyond concatenate Text and escape dynamic input. It also severely restricts usage to the built-in combinators available -- at least, for dynamic data -- and can make writing a nice-html template difficult, though littering _ throughout type signatures helps.</div><div><br></div><div>Check it out!</div><div><br></div><div>Benchmark results, a README, and an example: <a href="https://github.com/TransportEngineering/nice-html" target="_blank">https://github.com/TransportEn<wbr>gineering/nice-html</a></div><div>Hackage: <a href="https://hackage.haskell.org/package/nice-html" target="_blank">https://hackage.haskell.org/pa<wbr>ckage/nice-html</a><br></div><div><br></div><div><div>The only thing on the roadmap right now is to have some nice :-) way to assign JavaScript event handlers to Markup. This is something that I really appreciate when using React.js, so my eventual aim is for nice-html to be like a (more) server-side version of React. Right now, you can keep track of element ids with `Text.Html.Writer.note`, but it's neither a very good nor very useful interface.</div></div><div><br></div><div>Cheers,</div><div>Mike</div></div>
<br></div></div>______________________________<wbr>_________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/haskell-caf<wbr>e</a><br>
Only members subscribed via the mailman list are allowed to post.<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="m_-260716151712569023gmail_signature" data-smartmail="gmail_signature"><a href="http://www.saurabhnanda.com" target="_blank">http://www.saurabhnanda.com</a></div>
</font></span></div>
</blockquote></div><br></div>