<div dir="ltr"><div>That was easy. Thanks. I actually tried putting forall a in front of the line getting the error, but to no avail. Now fixed.<br></div><div><br></div><div>D<br></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 9, 2018 at 1:49 AM Michael Snoyman <<a href="mailto:michael@snoyman.com">michael@snoyman.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div>You need to put a `forall a.` in front of the `Ord a` constraint. To quote the manual on the language extension[1]</div><div><br></div><div>> Enable lexical scoping of type variables explicitly introduced with
<tt class="m_6258519474611134889gmail-docutils m_6258519474611134889gmail-literal"><span class="m_6258519474611134889gmail-pre">forall</span></tt>.</div><div><br></div><div>If it helps, the requirement of forall to be able to refer to the variable was non-obvious to me the first time I tried to use the extension.<br></div><div><br></div><div>[1] <a href="https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#ghc-flag--XScopedTypeVariables" target="_blank">https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#ghc-flag--XScopedTypeVariables</a><br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 9, 2018 at 11:45 AM Dennis Raddle <<a href="mailto:dennis.raddle@gmail.com" target="_blank">dennis.raddle@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>In the following snippet from a program in progress (designed to compute percentile rank for arbitrary lists of values) , I was hoping to declare types of functions within the main function just as a way of helping myself catch type errors. I'm getting the error "Can't match 'a' with 'a1'.... where 'a' is rigid type variable... etc. etc." on the line indicated in the comment below. The usual error I get when I try to do this without ScopedTypeVariables. So, I thought that ScopedTypeVariables was supposed to allow this kind of usage. What am I doing wrong?<br></div><div><br></div><div><br></div><div>{-# LANGUAGE ScopedTypeVariables #-}<br></div><div dir="ltr"><br></div><div dir="ltr">import qualified Data.Map as M<br>import qualified Data.List as L<br>import Data.Map(Map)<br>import Data.Function<br><br>-- <percent at or below> <percent below><br>data PercentileData = PercentileData Double Double <br><br>-- new attempt, October 2018: using new PercentileData construct to<br>-- represent percentile in both ways. (at/below, or below)<br>computePercentile :: Ord a => Map a Double -> Map a PercentileData<br>computePercentile dataIn = error "foo" <br> where<br> pairs :: [(a,Double)] -- THIS IS THE LINE GETTING THE ERROR<br> pairs = L.sortBy (compare `on` snd) $ M.toList dataIn<br><br></div></div>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</blockquote></div>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</blockquote></div>