[clean-list] Re: Converting Haskell to Clean
Clean Support
clean@cs.kun.nl
Thu, 10 Jan 2002 10:49:43 +0100
Sally wrote (in comp.lang.functional and on the Clean
Discussion list):
> Haskell code to translate to Clean:
> [..]
> data HtmlElement
> = HtmlString String
> | HtmlTag { -- tag with internal markup
> markupTag :: String,
> markupAttrs :: [HtmlAttr],
> markupContent :: Html
> }
> [..]
> My interpretation of this coding in Clean:
>
> :: HtmlElement = HtmlString
> | HtmlTag
>
> :: HtmlTag = {
> markupTag :: String,
> markupAttrs :: [HtmlAttr],
> markupContent :: Html
> }
>
> Is this correct ? Can anyone adapt this code ?
That should be
:: HtmlElement = HtmlString String
| HtmlTag HtmlTag
The first HtmlTag is the name of a constructor, the second the
name of the record type. If you find this confusing, you can
also write
:: HtmlElement = HtmlString
| HtmlTag HtmlTagRecord
:: HtmlTagRecord = ...
In Clean the record type has to be named, which is why you need
an extra definition.
Cheers,
Ronny Wichers Schreur