One alternative is to use labelled fields. In your example, if Html
were an algebraic datatype such as:
> data Html = Type1 { align = Align, ... }
> | Type2 { align = Align, ... }
> | ...
> data Align = Left | Right | Center
then instead of:
> h1 [align "right"] (stringToHtml "This is a Header")
you could write:
> h1 (stringToHtml "This is a Header" { align = Right})
or whatever, and you don't have the problem of dangling []'s,
since stringToHtml would preesumably provide a default allignment,
and it is legal to have the same label in different constructors.
-Paul
- Stylistic question about Haskell optional arguments Andy Gill
- Stylistic question about Haskell optional arguments Tommy Thorn
- Re: Stylistic question about Haskell optional argume... Paul Hudak
- Re: Stylistic question about Haskell optional argume... Andy Gill
- Re: Stylistic question about Haskell optional argume... Keith Wansbrough
- Re: Stylistic question about Haskell optional argume... Carl R. Witty
- Re: Stylistic question about Haskell optional argume... Marko Schuetz
- Re: Stylistic question about Haskell optional argume... Paul Hudak
- Re: Stylistic question about Haskell optional argume... Carl R. Witty
