Hi Iavor,<div><br></div><div>Thank you for your response.<br><div><br>On Wed, Jan 25, 2012 at 17:50, Iavor Diatchki wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div>On Wed, Jan 25, 2012 at 7:21 AM, Thijs Alkemade wrote:<br>
&gt; Also, we have a confusing problem when type checking a module. Above,<br>
&gt; we showed the result of &quot;:t map __ __&quot; in ghci. However, if we put &quot;f<br>
&gt; = map __ __&quot; in a module, we get:<br>
&gt;<br>
&gt; tcRnModule: [(f.hs:1:9-10, GHC.Prim.Any * -&gt; b),<br>
&gt; (f.hs:1:12-13, [GHC.Prim.Any *])]<br>
&gt;<br>
&gt; If I read GHC.Prim.Any * as forall a. a, then this is not correct: the<br>
&gt; GHC.Prim.Any * in both holes should have the same type. We assume it<br>
&gt; shows up because the type that should be there does not occur in the<br>
&gt; type signature of f (as it&#39;s just [b]), but so far we&#39;ve been unable<br>
&gt; to figure out why this behavior is different in interactive mode. Does<br>
&gt; someone have an idea about what to do to avoid the introduction of<br>
&gt; these GHC.Prim.Any * types?<br>
<br>
</div>The type `Any` is just an ordinary monomorphic type, (e.g., like<br>
Int`).  It is used to stand in for types that &quot;do not matter&quot; and may<br>
be thought of a special case of defaulting (i.e. resolving type<br>
ambiguity be selecting concrete types).  How it is used  is probably<br>
best illustrated with an example (you&#39;ve found one, but I&#39;ll use a<br>
slightly simpler one).  Consider the expression `null []`.  It clearly<br>
has the type Bool, because `null` takes a list and returns a Bool, and<br>
`[]` is a list.  However, there is nothing that forces the list<br>
elements to be of one type or another, so we cannot infer the full<br>
type of `[]`---in some sense, the expression `null []` is of type<br>
`forall a. Bool` where `a` is the type of the list elements.<br>
Inferring this type would not be useful because we have no way to<br>
specify what the `a` should be, and furthermore, it does not matter!<br>
So, whenever GHC infers a type `forall a. P =&gt; t` where `a` does not<br>
appear in `P` or `t`, it knows that the `a` does not matter, so t<br>
simply defaults it to `Any`.<br></blockquote><div><br></div><div>I believe the problem here is that GHC is inferring that a type does not matter (and thus defaults) when, actually, we want it to matter.</div><div><br></div>


<div>So, imagine this...</div><div><br></div><div><div>Prelude&gt; :t map (__ :: forall a . a) (__ :: forall b . b)</div></div><div><br></div><div>... and trying to find out the types to which &#39;a&#39; and &#39;b&#39; are instantiated. I don&#39;t think the types should be Any thanks to the constraints imposed by &#39;map&#39;.</div>


<div><br></div><div>Regards,<br>Sean</div></div></div></div>