[Haskell-cafe] semantics of type synonym

Miguel Mitrofanov miguelimo38 at yandex.ru
Tue Dec 29 09:57:08 EST 2009

pbrowne wrote:
> Hi,
> I am studying the underlying semantics behind Haskell and to what degree
> those semantics are actually implemented. I need to clarify what a *type
> synonym* actual means in relation to Haskell's logic (or formal
> semantics). I used the following type synonym:
> type Name = String
> getName(n) = n
> I checked the types with two tests:
> -- test 1
> :t "ww"
> "ww" :: [Char]
> -- test 2
> :t getName("ww")
> getName("ww") :: Name
> Obviously I get two different types.

Wrong. You get exactly the same type, it's just that GHCi detected that you have a fancy name for this type, so it gives you that name. It's not type system, it's just GHCi.

> In the case of the function Haskells type system seems to pick up enough
> information to determine that “ww” is a Name.
> But I am not sure what is happening with the literal "ww" in the first test.
> Pat
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list