[Haskell-cafe] Implicit newtype unwrapping

Max Bolingbroke batterseapower at hotmail.com
Thu Dec 3 02:40:13 EST 2009


2009/12/3 Gregory Crosswhite <gcross at phys.washington.edu>:
> But it seems to me like the whole point of using "newtype" is because you *don't* want your new type to be used everywhere that the old type can be used;  otherwise you would just use "type" to create an alias.  The only convincing exception I have heard to this (as you helpfully explained to me) is that one might be forced to use newtype to make a piece of code use a different instance declaration for a type.

You might also be forced to use a newtype because you need to use it
recursively - i.e. you need an alternative to equirecursive types. I
hit this quite often when building datatype using
fixpoints-of-a-functor and regularly wish for the ability to write:

type Fix f = f (Fix f)

Cheers,
Max


More information about the Haskell-Cafe mailing list