3 ms·
well how'd we define return :: a -> m a in the jQuery monad? First I thought return = jQuery but $(".yo") :: [HTMLElement] isnt return ".
by arianvanp 14y ago
well how'd we define
return :: a -> m a
in the jQuery monad?
First I thought
return = jQuery
but
$(".yo") :: [HTMLElement]
isnt
return ".yo" :: JQuery String
I'd probably model it like this:
(|>) = flip ($)
jQuery "selector" |> css "color" "red" |> filter someSelector |> css "color" "blue"
which would turn into:
css "color" "blue" (filter someSelector (css "color "red" (jQuery "selector")))
class Selector a where
instance Selector Text where
instance Selector HtmlElement where
jQuery :: Selector a -> JQuery
css :: Text -> Text -> JQuery -> JQuery
filter :: Selector a -> JQuery -> JQuery