
7 Jun
2008
7 Jun
'08
4:41 a.m.
On Fri, Jun 06, 2008 at 03:41:07PM -0700, Klaus Ostermann wrote:
Why does the code below not pass the type checker?
If I could explictly parameterize y with the type constructor Id (as e.g. in System F), then 'y Id' should have the type Int -> Int and hence "y Id x" should be OK, but with Haskell's implicit type parameters it does not work.
The type of 'Id' is expanded to simply 'Int', and 'Int' does not unify with 'm a' for any type constructor 'm': Haskell's type level functions are always unevaluated (type synonyms don't count: they are always expanded). So, if you wanted to to this, you'd need to do newtype Id a = Id a Of course, now your values need to be tagged as well. Edsko