<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>