[Haskell-beginners] "type" declarations: utterly transparent synonyms?

Silent Leaf silent.leaf0 at gmail.com
Fri Jun 3 22:28:46 UTC 2016


Thanks!

Le vendredi 3 juin 2016, Daniel Bergey <bergey at alum.mit.edu> a écrit :
> Yes, it is as you say.  The Haddock documentation will use the type
> synonym if (and only if) you use it in the type of f.  Call sites of f,
> and the result of f, are the same regardless.
>
> For example, this is fine:
>
> f :: t -> t -> t
>
> g :: Int2 t
> g = f
>
> cheers,
> bergey
>
> On 2016-06-03 at 12:44, Silent Leaf <silent.leaf0 at gmail.com> wrote:
>> I'd like to be sure when one defines a type with "type", it truly merely
creates a
>> synonym, and no matter what one could replace the left side by the right
side in the
>> whole program, and vice versa, and it wouldn't change a thing in the
actual meaning,
>> value of the program.
>>
>> Eg if i define:
>> type In2 t = t -> t -> t
>> I can thereafter replace for any type t, any signature like
>> f :: t -> t -> t
>> with
>> f :: In2 t
>> then strictly no consequence other than visual in the source code, by
me, will occur.
>> Thanks!
>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160604/d8dcdd7e/attachment.html>


More information about the Beginners mailing list