Andy Gill wrote/a ecrit/skrev:
> I've got a stylistic question about Haskell.
> What's the best way to add optional arguments to a
> embedded DSL?
>
> For example, say I've got an library of HTML combinators.
> To represent
>
> <H1>This is a Header</H1>
>
> you might write
>
> h1 (stringToHtml "This is a Header")
>
> The types of the functions are
>
> h1 :: Html -> Html
> stringToHtml :: String -> Html
Please make that an instance operator, such that you don't have to
litter the name space, eg.
h1 :: HTML -> HTML
class HTMLable a where
html :: a -> HTML
> Looks OK, but what about if you want this header
> right aligned? I can see three ways.
....
> (2) Combinators that take arguments have different names.
> So you might have
>
> h1 :: Html -> Html
> h1' :: [HtmlAttr] -> Html -> Html
IIRC this is what TkGofer used. Works nice in practice and is
_simple_!
Say, are you making a better version of LibCGI? We could use a
maintained, unified, and more complete library.
Regards,
Tommy