<div>With the changes to ScopedTypeVariables in GHC you can&#39;t pick up the type from the return type of your function directly, so you&#39;ll need either a combinator to do the work or to pass the type in question in as an argument to a helper function.<br>
</div>
<div><span class="hs-definition">normalize</span> <span class="hs-keyglyph">::</span> <span class="hs-layout">(</span><span class="hs-conid">Modular</span> <span class="hs-varid">s</span> <span class="hs-varid">a</span><span class="hs-layout">,</span> <span class="hs-conid">Integral</span> <span class="hs-varid">a</span><span class="hs-layout">)</span> <span class="hs-keyglyph">=&gt;</span> <span class="hs-varid">a</span> <span class="hs-keyglyph">-&gt;</span> <span class="hs-layout">(M s a</span><span class="hs-layout">)</span><br>
<a name="line-30"></a><span class="hs-definition">normalize</span> <span class="hs-keyglyph">=</span> <span class="hs-varid">normalize&#39;</span> <span class="hs-varid">undefined</span> <span class="hs-keyword">where</span><br>
<a name="line-31"></a>    <span class="hs-varid">normalize&#39;</span> <span class="hs-keyglyph">::</span> <span class="hs-layout">(</span><span class="hs-conid">Modular</span> <span class="hs-varid">s</span> <span class="hs-varid">a</span><span class="hs-layout">,</span> <span class="hs-conid">Integral</span> <span class="hs-varid">a</span><span class="hs-layout">)</span> <span class="hs-keyglyph">=&gt;</span> <span class="hs-varid">s</span> <span class="hs-keyglyph">-&gt;</span> <span class="hs-varid">a</span> <span class="hs-keyglyph">-&gt;</span> <span class="hs-layout">(M s a</span><span class="hs-layout">)</span><br>
<a name="line-32"></a>    <span class="hs-varid">normalize&#39;</span> <span class="hs-varid">s</span> <span class="hs-varid">a</span> <span class="hs-keyglyph">=</span> <span class="hs-conid">M</span> <span class="hs-layout">(</span><span class="hs-varid">a</span> <span class="hs-varop">`mod`</span> <span class="hs-varid">modulus</span> <span class="hs-varid">s</span><span class="hs-layout">)</span><br>
</div>
<div>
<div>There is an implementation of the reflection code with minor modifications to work with the modern version of GHC&#39;s ScopedTypeVariables in hackage as &#39;reflection&#39; and a minimalist implementation of modular arithmetic from the same paper (if not yet including the residue number system based optimizations) available in &#39;monoids&#39; as Data.Ring.ModularArithmetic. Both have only been fleshed out as far as I&#39;ve needed them for other purposes, but should be usable.</div>
</div>
<div> </div>
<div>-Edward Kmett</div>
<div> </div>
<div class="gmail_quote">On Thu, Apr 2, 2009 at 11:59 AM, Henry Laxen <span dir="ltr">&lt;<a href="mailto:nadine.and.henry@pobox.com">nadine.and.henry@pobox.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Dear Group,<br><br>I&#39;m trying to read the paper:<br>&quot;Functional Pearl: Implicit Configurations&quot;<br>
at <a href="http://www.cs.rutgers.edu/~ccshan/prepose/" target="_blank">http://www.cs.rutgers.edu/~ccshan/prepose/</a><br>and when running the code in prepose.lhs I get:<br>../haskell/prepose.lhs:707:0: Parse error in pattern<br>
which is pointing at:<br>normalize a :: M s a = M (mod a (modulus (undefined :: s)))<br><br>The paper says it uses lexically scoped type variables.  I tried reading about<br>them at:<br><a href="http://www.haskell.org/ghc/docs/latest/html/users_guide/other-type-extensions.html#scoped-type-variables" target="_blank">http://www.haskell.org/ghc/docs/latest/html/users_guide/other-type-extensions.html#scoped-type-variables</a><br>
<br>so I added -XScopedTypeVariables to my OPTIONS but I still get the same error<br>message.  I would really like to play with the code in the paper, but I&#39;m stuck<br>at this point.  Any pointers would be appreciated.<br>
Best wishes,<br>Henry Laxen<br><br><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>
</blockquote></div><br>