"type" declarations: utterly transparent synonyms?

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!

it seems so.. different synonyms with similar "content" are substituted / matched without errors: data D = S String | I Int deriving (Eq,Ord) type A = D type B = D compiler "won't mind" if Set A is replaced with Set B

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
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@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

Thanks!
Le vendredi 3 juin 2016, Daniel Bergey
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
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@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
participants (3)
-
Daniel Bergey
-
Imants Cekusins
-
Silent Leaf