[web-devel] Yesod question: renaming widget functions

Matt Brown matt at softmechanics.net
Mon Oct 25 07:50:24 CEST 2010


I prefer the new names as well, and don't think code breakage would be
a problem.  I say it's worth it.

-matt

On Sun, Oct 24, 2010 at 12:58 AM, Michael Snoyman <michael at snoyman.com> wrote:
> Hey all,
>
> I have a general rule of thumb: if I get confused about how I named
> things, I probably named them badly. For example, addStyle takes a
> Cassius value as an argument, while addStylesheet takes a route to a
> CSS file. On the other hand, addScript takes a route to a Javascript
> file, and addJavascript takes a Julius value. There's also addBody,
> which takes a Hamlet.
>
> And there's no addWidget, which is fine (it would just be id), except
> that it looks wrong and can lead to confusing type errors with the new
> polymorphic Hamlet. For example:
>
>    defaultLayout $ do
>        setTitle "Widget test"
>        [$hamlet|This is a widget|]
>
> works fine, but:
>
>    defaultLayout $ do
>        [$hamlet|This is a widget|]
>        setTitle "Widget test"
>
> confuses the compiler. I'm considering some renamings for Yesod 0.6
> which will cause breakage, so I wanted your opinions if the changes
> are worth it, or if you have any better ideas. Here's what I'm
> thinking:
>
> addCassius :: Cassius -> Widget
> addJulius :: Julius -> Widget
> addHamlet :: Hamlet -> Widget
> addHtml :: Html -> Widget
> addHamletHead :: Hamlet -> Widget
> addHtmlHead :: Html -> Widget
> addWidget :: Widget -> Widget
> addStylesheet :: Route -> Widget
> addScript :: Route -> Widget
>
> And with the new polymorphic hamlet, I don't think wrapWidget and
> extractWidget are generally necessary. Nonetheless, I think I'd like
> to leave extractWidget, in case there is some use case I'm not
> thinking of. I think it's safe to remove wrapWidget, as it's easy to
> express it in terms of extractWidget.
>
> Thoughts?
>
> Michael
> _______________________________________________
> web-devel mailing list
> web-devel at haskell.org
> http://www.haskell.org/mailman/listinfo/web-devel
>


More information about the web-devel mailing list