[Haskell-cafe] difference between type and newtype
ndmitchell at gmail.com
Fri Aug 25 15:33:35 EDT 2006
> (2,5) whose type is "T a"
No, try expanding the type synonyms:
mkT :: a -> T a
mkT :: a -> Z -> (a, Z)
mkT :: a -> Int -> (a, Int)
The type of (2,5) is (a, Int), or in this specific case (Int, Int).
> they return the same stuff with different types. Onle myT will return a
> type of type "T a".
The type T is only a type alias, everywhere you can see T you can
rewrite it. If mkT1 is applied to one argument, which is an Int, then
you have a type T as a result.
For example, the type of "Test" is all of FilePath, [Char], String -
all at the same time, since they are aliases for each other.
More information about the Haskell-Cafe