Here's the difference between these two types:<br><br>test1 :: forall a. a -> Int<br>-- The caller of test1 determines the type for test1<br>test2 :: (forall a. a) -> Int<br>-- The internals of test2 determines what type, or types, to instantiate the argument at<br>
<br>Or, to put it another way, since there are no non-bottom objects of type (forall a. a):<br>test1 converts *anything* to an Int.<br>test2 converts *nothing* to an Int<br><br>-- type-correct implementation<br>-- instantiates the (forall a. a) argument at Int<br>
test2 x = x<br><br>-- type error, the caller chose "a" and it is not necessarily Int<br>-- test1 x = x<br><br>-- type-correct implementation: ignore the argument<br>test1 _ = 1<br><br> -- ryan<br><br><div class="gmail_quote">
On Wed, Sep 16, 2009 at 1:04 AM, Cristiano Paris <span dir="ltr"><<a href="mailto:frodo@theshire.org">frodo@theshire.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Tue, Sep 15, 2009 at 11:38 PM, Daniel Fischer<br>
<<a href="mailto:daniel.is.fischer@web.de">daniel.is.fischer@web.de</a>> wrote:<br>
> ...<br>
<div class="im">>> foo :: forall a. a -> a<br>
><br>
> This is exactly the same type as<br>
><br>
> foo :: a -> a<br>
><br>
> (unless you're using ScopedTypeVariables and there's a type variable a in scope), since<br>
> type signatures are implicitly forall'd.<br>
<br>
</div>Yep, perhaps I used the wrong example. What about foo: (forall a. a) -> Int?<br>
<div><div></div><div class="h5"><br>
Cristiano<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br>