Hi all,<div><br class="webkit-block-placeholder"></div><div>I'm try to write some function in TH that I don't even know if it is possible.</div><div><br> </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,_) -> 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) -> 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 -> Int -> 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 -> Int -> 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'
</div><div> is used in a top-level splice, and must be imported, not defined locally</div><div> In the first argument of `sel', namely `x'</div><div> In the expression: $[splice](sel x y) (x, y)</div><div>
In the definition of `fsel': 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> </div>