Hi all,<div><br class="webkit-block-placeholder"></div><div>I&#39;m try to write some function in TH that I don&#39;t even know if it is possible.</div><div><br>&nbsp;</div><div>Consider the example from the tutorials</div><div>
<br class="webkit-block-placeholder"></div><div><span class="Apple-style-span" style="font-family: Times; font-size: 16px; "><p class="Code" style="margin-top: 0cm; margin-right: 0cm; margin-left: 0cm; margin-bottom: 0.0001pt; font-family: Lucida Console; ">
<span lang="EN-US"><font class="Apple-style-span" size="1"><span class="Apple-style-span" style="font-size: small;">sel 1 2 = [| \(x,_) -&gt; x |]</span></font></span></p><p class="Code" style="margin-top: 0cm; margin-right: 0cm; margin-left: 0cm; margin-bottom: 0.0001pt; font-family: Lucida Console; ">
<span lang="EN-US"><font class="Apple-style-span" size="1"><span class="Apple-style-span" style="font-size: small;">sel 2 2 = [| \(_,x) -&gt; x |]</span></font></span></p><p class="Code" style="margin-top: 0cm; margin-right: 0cm; margin-left: 0cm; margin-bottom: 0.0001pt; font-family: Lucida Console; ">
<font class="Apple-style-span" size="1"><span class="Apple-style-span" style="font-size: small;"><br class="webkit-block-placeholder"></span></font></p><p class="Code" style="margin-top: 0cm; margin-right: 0cm; margin-left: 0cm; margin-bottom: 0.0001pt; font-family: Lucida Console; ">
<font class="Apple-style-span" size="1"><span class="Apple-style-span" style="font-size: small;">If I want to write some function that will dynamically create a selection function according to its arguments and do something with it.
</span></font></p><p class="Code" style="margin-top: 0cm; margin-right: 0cm; margin-left: 0cm; margin-bottom: 0.0001pt; font-size: 12pt; font-family: Lucida Console; "><br></p></span></div><div><div><div><div>fsel :: Int -&gt; Int -&gt; x
</div><div>fsel x y = $(sel x y) ...</div><div><br class="webkit-block-placeholder"></div><div>Imagine a stupid case for</div><div><br class="webkit-block-placeholder"></div><div><div>fsel :: Int -&gt; Int -&gt; Int</div>
<div>fsel x y = $(sel x y) (x,y)</div></div></div><div><br class="webkit-block-placeholder"></div><div>The compiler complains that</div><div><br class="webkit-block-placeholder"></div><div><div>GHC stage restriction: `x&#39;
</div><div>&nbsp;&nbsp; &nbsp; &nbsp;is used in a top-level splice, and must be imported, not defined locally</div><div>&nbsp;&nbsp; &nbsp;In the first argument of `sel&#39;, namely `x&#39;</div><div>&nbsp;&nbsp; &nbsp;In the expression: $[splice](sel x y) (x, y)</div><div>
&nbsp;&nbsp; &nbsp;In the definition of `fsel&#39;: fsel x y = $[splice](sel x y) (x, y)</div><br class="webkit-block-placeholder"></div><div>what, indeed, makes sense.</div><div><br class="webkit-block-placeholder"></div></div><div>However, is there a possible way to generate Haskell functions from TH without having to instanciate its arguments?
</div><div><div><div><br class="webkit-block-placeholder"></div><div>Thanks,</div><div>hugo</div></div><div><br class="webkit-block-placeholder"></div></div><div><br class="webkit-block-placeholder"></div></div><div><br class="webkit-block-placeholder">
</div><div><br>&nbsp;</div>