Thanks, it did!<br><br>(For the record, here is a paraphrase of what first <br>confused me -- undefined was not the problem).<br>
<br>
> enumerateMethodNames :: [String]<br>
> enumerateMethodNames = map fst methodsNoConstr <br>
> --enumerateMethodNames = map fst methodsConstr <br>
> <br>
> methodsConstr :: (Ord a) => [(String, [a] -> Int)] <br>
> methodsConstr = [ ("method", methodConstr )]<br>
> where methodConstr :: (Ord a) => [a] -> Int<br>
> methodConstr xs = length . sort $ xs <br>
> <br>
> <br>
> methodsNoConstr :: [(String, [a] -> Int)] <br>
> methodsNoConstr = [ ("method", methodNoConstr )]<br>
> where methodNoConstr :: [a] -> Int<br>
> methodNoConstr = length<br>
> <br>
><br>
> --First enumerateMethodNames works as expected, second does not compile.<br><br><div class="gmail_quote">2010/3/4 Ryan Ingram <span dir="ltr"><<a href="mailto:ryani.spam@gmail.com">ryani.spam@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Perhaps this thought exercise will make things clear:<br>
<br>
> class Show a => Foo a where<br>
> toFoo :: String -> a<br>
<br>
> foos :: (Foo a) => [(String, a)]<br>
> foos = map (\f -> (show f, f)) [toFoo "a", toFoo "b", toFoo "c"]<br>
<br>
> data Foo1 = Foo1<br>
> instance Show Foo1 where show _ = "1"<br>
> instance Foo Foo1 where toFoo _ = Foo1<br>
> data Foo2 = Foo2<br>
> instance Show Foo2 where show _ = "2"<br>
> instance Foo Foo2 where toFoo _ = Foo2<br>
<br>
> exercise :: [String]<br>
> exercise = map fst foos<br>
<br>
Exercise for the reader: what should the contents of "exercise" be?<br>
<br>
Keep in mind that your question is exactly the same as this one, from<br>
the compiler's point of view.<br>
<font color="#888888"><br>
-- ryan<br>
</font><div><div></div><div class="h5"><br>
On Wed, Mar 3, 2010 at 10:48 PM, Marcus Uneson <<a href="mailto:marcus.uneson@gmail.com">marcus.uneson@gmail.com</a>> wrote:<br>
> Thanks. I realize there are many ways to make it compile.<br>
> However, I am trying to understand the mechanism behind --<br>
> why does the first example compile and what constraints does<br>
> enumerateMethodNames add on a (which it does not inspect)?<br>
</div></div></blockquote></div><br>