<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
<div class="moz-cite-prefix">Den 2017-11-24 kl. 20:04, skrev Quentin
Liu:<br>
</div>
<blockquote type="cite"
cite="mid:5fdec6dc-aeb8-4083-9782-114c0c1c8b6c@Spark">
<title></title>
<div name="messageBodySection" style="font-size: 14px;
font-family: -apple-system, BlinkMacSystemFont, sans-serif;">
<div><br>
</div>
<div>
<blockquote type="cite" style="margin: 5px 5px; padding-left:
10px; border-left: thin solid #1abc9c;">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin: 5px;
padding-left: 10px; border-left-width: thin;
border-left-style: solid; border-left-color:
rgb(230, 126, 34);">
<div name="messageBodySection" style="font-family:
-apple-system, BlinkMacSystemFont, sans-serif;">Yes,
you could pass the function a list of strings as
well. A string is just a list of Chars. The type
signature `a` does not restrict the range of types
you could pass to the function.</div>
</blockquote>
<div> </div>
<div>That seem strange to me. Wouldn't that mean that
i could write the declaration of myOrderFunc as
`myOrderFunc :: a -> a -> Ordering` as well?
GHCI give me an error on this though so obviously
it's wrong. I just don't see why. Why cannot a
represent [b]?</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
<div name="messageSignatureSection"><br>
<div class="matchFont">Could you copy and paste the error
message here? <br>
</div>
</div>
</blockquote>
Sure, the error i get follows<br>
```<br>
exercises.hs:33:13:<br>
Couldn't match expected type ‘[b0]’ with actual type ‘a’<br>
‘a’ is a rigid type variable bound by<br>
the type signature for myOrderFunc :: a -> a ->
Ordering<br>
at exercises.hs:31:16<br>
Relevant bindings include<br>
y :: a (bound at exercises.hs:32:15)<br>
x :: a (bound at exercises.hs:32:13)<br>
myOrderFunc :: a -> a -> Ordering (bound at
exercises.hs:32:1)<br>
In the first argument of ‘myLen’, namely ‘x’<br>
In the first argument of ‘(<)’, namely ‘myLen x’<br>
Failed, modules loaded: none.<br>
```<br>
Attaching the updated exercises.hs for reference.<br>
<br>
I'm still not very good at interpreting Haskell's error messages,
they are quite cryptic to me. My interpretation/guess of the above
is that my `a` is too 'wide' or how you express it. Haskell seem to
expect some form of list. Most likely since i want a length and
lists are perhaps everything in Haskell that can produce a length.
I've hardly scratched the surface of what i imagine is Haskell so i
cannot say anything for sure yet.<br>
<br>
<blockquote type="cite"
cite="mid:5fdec6dc-aeb8-4083-9782-114c0c1c8b6c@Spark">
<div name="messageSignatureSection">
<div class="matchFont"><br style="font-size: 14px; font-family:
-apple-system, BlinkMacSystemFont, sans-serif;">
</div>
The way I use to think about type signature is, when you trying
to substitute type variables such as `a`, substitute it into a
concrete type that you are working with. <br>
</div>
</blockquote>
I'm having a hard time understanding your way of thinking about type
signatures. Could you perhaps elaborate a bit more on it?<br>
<br>
// Patrik<br>
</body>
</html>