[Haskell-beginners] "type" declarations: utterly transparent synonyms?
Daniel Bergey
bergey at alum.mit.edu
Fri Jun 3 18:01:00 UTC 2016
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
More information about the Beginners
mailing list