title: What type is this lambda's parameter?
body: <p>I was experimenting with functional programming, and I wrote this. </p>
  
  <pre><code>[=](auto p) { 
      return [=](auto q) { 
          return p(q)(p); 
      }; 
  })
  </code></pre>
  
  <p>I started wondering how this is possible, what is the type of p?</p>
  
  <p>So, I wrote something like this.</p>
  
  <pre><code>template&lt;class Type&gt;
  using LambdaType = std::function&lt;std::function&lt;Type(Type)&gt;(Type)&gt;;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>[=](LambdaType&lt;int&gt; p) {
      return [=](LambdaType&lt;int&gt; q) {
          return p(q)(p);
      };
  }
  </code></pre>
  
  <p>When compiling it, the compiler would give me errors.</p>
  
  <pre><code>error C2664: 'std::function&lt;Type (int)&gt; std::_Func_class&lt;_Ret,int&gt;::operator ()(int) const': cannot convert argument 1 from 'std::function&lt;std::function&lt;Type (int)&gt; (int)&gt;' to 'int'
  error C2664: 'main::&lt;lambda_cec7eb77d9cd29f3c40710200090f154&gt;::()::&lt;lambda_b8db28542cb51159223ad8d89c63d794&gt;::()::&lt;lambda_224126017af42fcee190e88f299089fc&gt;::()::&lt;lambda_415db9fd88f1008b25af42ccb33b1c77&gt; main::&lt;lambda_cec7eb77d9cd29f3c40710200090f154&gt;::()::&lt;lambda_b8db28542cb51159223ad8d89c63d794&gt;::()::&lt;lambda_224126017af42fcee190e88f299089fc&gt;::operator ()(std::function&lt;std::function&lt;Type (std::function&lt;std::function&lt;int (int)&gt; (int)&gt;)&gt; (std::function&lt;std::function&lt;int (int)&gt; (int)&gt;)&gt;) const': cannot convert argument 1 from 'main::&lt;lambda_cec7eb77d9cd29f3c40710200090f154&gt;::()::&lt;lambda_b8db28542cb51159223ad8d89c63d794&gt;::()::&lt;lambda_fa72c454c823301ba6dfa9cba6f558e0&gt;' to 'std::function&lt;std::function&lt;Type (std::function&lt;std::function&lt;int (int)&gt; (int)&gt;)&gt; (std::function&lt;std::function&lt;int (int)&gt; (int)&gt;)&gt;'
  </code></pre>
  
  <p>But that's when I realized that p only takes in ints, but p needs to be a <code>LambdaType&lt;LambdaType&lt;int&gt;&gt;</code> to take in q
  but when you change p to a <code>LambdaType&lt;LambdaType&lt;int&gt;&gt;</code>, then p only takes in <code>LambdaType&lt;int&gt;</code> but p is not a <code>LambdaType&lt;int&gt;</code>, and it needs to be a <code>LambdaType&lt;LambdaType&lt;LambdaType&lt;int&gt;&gt;&gt;</code> to take in p.</p>
  
  <p>So, what type is p?</p>
  
  <p>Oh by the way, this is my first question on stackoverflow</p>