[Haskell-cafe] Type synonyms considered harmful?

Carl Eyeinsky eyeinsky9 at gmail.com
Mon Jan 19 12:27:16 UTC 2015

I agree with Stefan -- type synonyms are really useful in developing
project by yourself (or a small team), where you are the one both using and
generating the synonyms, and no-one else needs to care. Then, the simple
Age = Int is still very meaningful for yourself in both documenting and
directing the writing.

But in a public library, finding out that a type X is actually 'Either z'
kind of blocks the way -- you don't know how to operate with X until you
become to know what it really is.. And then you have to memorize this for
the future to stay productive, which is not very easy if there are many
libraries that you're using. (But on the other hand if X equals something
else and more complex, that you don't know, then the synonym I think
becomes more useful again.)

On Mon, Jan 19, 2015 at 11:16 AM, Stefan Kersten <sk at k-hornz.de> wrote:

> On 19/01/2015 01:02, Christopher Done wrote:
> > I personally really dislike type synonyms, 9 times out of 10 I would
> > prefer to just read a full type than the obscured synonym which hides
> > useful structure from me.
> i find type synonyms mostly useful during prototyping, i.e. when what I
> want is actually a newtype for safer interfaces but I don't want to
> bother with wrapping/unwrapping or figuring out how to derive instances;
> this is especially true for monad transformer stacks. later, after the
> code has settled a bit, it's straight forward, if tedious, to change the
> type to a newtype and fix the resulting type errors.
> sk
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

Carl Eyeinsky
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20150119/8cfa6517/attachment.html>

More information about the Haskell-Cafe mailing list