[Haskell-cafe] semantics of type synonym
miguelimo38 at yandex.ru
Tue Dec 29 10:45:16 EST 2009
>> 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.
> Are you saying there is just one type? (not two isomorphic types because
> there is only one of them with two names)
Exactly the same. You can take a term of one of these types and feed it to the function expecting another, and visa versa.
>>> In the case of the function Haskells type system seems to pick up enough
>>>> information to determine that “ww” is a Name.
>> Nope. "ww" is still a [Char] for the compiler. And you do not even check for
>> the type of "ww".
>> :t snd . (\x -> (getName x, x)) $ "ww"
>> ... :: String
> Why are the GHCi commands :t "ww" and :t getName("ww") not a valid type
> pbrowne wrote:
>> 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:
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe