## Monadic DSL

I am not convinced that Monadic Html DSL's are better from a market perspective, given the popularity of Html DSL libraries that don't have it. However, there is also quite a lot of advantages, such as `guard`

and other Monadic techniques, as well as **indentation enforcement**.

But since this is just a different trade off, I think we should support it as an alternative DSL. I did a little exploration inspired by `lucid`

and it's pretty promising imho.

```
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE ExtendedDefaultRules #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
module Shpadoinkle.Html.Monad where
import Control.Applicative
import Data.Text
import Prelude hiding (div)
import Shpadoinkle
import Shpadoinkle.Html.Event
import Shpadoinkle.Html.Property
default (Text)
data HtmlT m a x = HtmlT { unHtmlT :: [Html m a], slott :: x }
deriving (Functor, Traversable, Foldable)
instance Applicative (HtmlT m a) where
pure = HtmlT mempty
HtmlT xs fa <*> HtmlT ys a = HtmlT (xs <> ys) (fa a)
instance Monad (HtmlT m a) where
HtmlT xs a >>= f = let HtmlT ys a' = f a in HtmlT (xs <> ys) a'
instance Semigroup (HtmlT m a ()) where
(<>) = liftA2 (<>)
instance Monoid (HtmlT m a ()) where
mempty = pure mempty
type HtmlM m a = HtmlT m a ()
div :: [(Text, Prop m a)] -> HtmlM m a -> HtmlM m a
div ps (HtmlT cs x) = HtmlT [h "div" ps cs] x
text' :: Text -> HtmlM m a
text' s = HtmlT [text s] ()
counter :: Int -> HtmlM m Int
counter x =
div [ className "foo" ] do
text' $ "wat" <> pack (show x)
div [ onClick (+ 1) ] do
text' "oh no!"
```