"type" declarations are not first-class; treat them more like macro expansions. In particular, you cannot make a function polymorphic over a type declaration.
You can make this typecheck using a "data" or "newtype" declaration for Id: newtype Id x = Identity x (or) data Id x = Identity x You do need to wrap/unwrap the "Identity" constructor then. -- ryan On Fri, Jun 6, 2008 at 3:41 PM, Klaus Ostermann <[EMAIL PROTECTED]> 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. > > So, how can I make this work? > > Klaus > ------------ > > type Id a = a > > x :: Id Int > x = undefined > > y :: (a Int) -> (a Int) > y = undefined > > test = y x > > Error: > Couldn't match expected type `a Int' against inferred type `Id Int' > In the first argument of `y', namely `x' > In the expression: y x > In the definition of `test': test = y x _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
