[Haskell-cafe] A voyage of undiscovery
andrewcoppin at btinternet.com
Thu Jul 16 15:40:14 EDT 2009
Robert Greayer wrote:
> f0 _ = (foo True, foo 'x') where foo = id
> is well-typed.
Really? That actually works? How interesting... This suggests to me that
where-clauses also do strange things to the type system.
> f1 foo = (foo True, foo 'x')
> requires 'foo' to be polymorphic in its first argument. This does
> require a higher rank type, which can't be inferred:
> You could type f1 as
> f1 :: (forall a . a -> a) -> (Bool, Char)
> and apply it to 'id'.
> Or you could type it as something like:
> f1 :: (forall a . a -> ()) -> ((),())
> and apply it to 'const ()'
...all of which is beyond Haskell-98, which is what I am limiting myself
to at present.
(Actually, even that is a lie. I don't have type-classes yet...)
More information about the Haskell-Cafe