[clean-list] Re: Synonym types as instances
Brian Rogoff
bpr@artisan.com
Fri, 24 Jan 2003 08:36:39 -0800
It was for exactly this reason that I asked some similar questions last
summer, under the subject of
Re: More translation questions (Was Re: [clean-list] translation of Haskell
newtype?)
Here is John's helpful reply:
John van Groningen writes:
> Brian Rogoff wrote:
> > [... how to translate Haskell's newtype into Clean? ..]
> The Clean compiler does not optimise this special case (a type with a
> single strict unary constructor). However the compiler attempts to optimise
> a record with a single (strict) field, by unboxing such a record if it
> appears as a strict field in (another) record, or as a strict argument of
> a constructor.
> Strict arguments and results of functions are also unboxed for records.
>
> So it is better to translate newtype into a record with a strict field,
> instead of a constructor.
>
> If you prefer to use a constructor like syntax, you could use a macro:
>
> NewType a :== {new_type=a}
--
-- Brian