Re: Stylistic question about Haskell optional arguments

1999-08-18 Thread Carl R. Witty
Paul Hudak <[EMAIL PROTECTED]> writes: > > Carl> I'm afraid this doesn't work. There are two problems: > > Carl> 1) You need a constructor above: > > >> h1 (stringToHtml "This is a Header" (H1Args { align = Right})) > > Carl> or > > >> H1 { align = Right, html = stringToHtml "This is a Header" }

Re: Stylistic question about Haskell optional arguments

1999-08-18 Thread Paul Hudak
> Carl> I'm afraid this doesn't work. There are two problems: > Carl> 1) You need a constructor above: > >> h1 (stringToHtml "This is a Header" (H1Args { align = Right})) > Carl> or > >> H1 { align = Right, html = stringToHtml "This is a Header" } and Marko replied: > h1 (stringToHtml "This is a

Re: Stylistic question about Haskell optional arguments

1999-08-18 Thread Marko Schuetz
Carl, > "Carl" == Carl R Witty <[EMAIL PROTECTED]> writes: Carl> Paul Hudak <[EMAIL PROTECTED]> writes: >> One alternative is to use labelled fields. In your example, if Html >> were an algebraic datatype such as: >> >> > data Html = Type1 { align = Align, ... } >> > | Type2 { al

Re: Stylistic question about Haskell optional arguments

1999-08-17 Thread Carl R. Witty
Paul Hudak <[EMAIL PROTECTED]> writes: > 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 | C

Re: Stylistic question about Haskell optional arguments

1999-08-17 Thread Keith Wansbrough
> I've got a stylistic question about Haskell. > What's the best way to add optional arguments to a > embedded DSL? > [..] > -- > (1) Combinators takes a list of attributes. >Now we have > >h1 :: [HtmlAttr] -> Html -> Html > >and might

Stylistic question about Haskell optional arguments

1999-08-16 Thread Tommy Thorn
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 > > This is a Header > > you might write > > h1 (strin

Re: Stylistic question about Haskell optional arguments

1999-08-16 Thread Paul Hudak
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"] (stringToH

Re: Stylistic question about Haskell optional arguments

1999-08-16 Thread Andy Gill
Paul Hudak wrote: > > 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 ins

Stylistic question about Haskell optional arguments

1999-08-16 Thread Andy Gill
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 This is a Header you might write h1 (stringToHtml "This is a Header") The types of the functions