<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<style id="EHTipGlobalStyle">.EHTipToolTip * {background: inherit;font-family: inherit;font-size: inherit;font-size-adjust: none;font-stretch: normal;line-height: inherit;font-variant: normal;border: 0px;text-transform: inherit;color: inherit;font-style: inherit;text-decoration: inherit;margin: 0px 0px 0px 0px;padding: 0px 0px 0px 0px;float: none;display: inline;cursor: default;}
.EHTipReplacer, .EHTipKey, .EHTipAudio {cursor: pointer;}
.EHTipToolTip hr {margin: 0.4em 0;display: block;border: 1px inset;}
.EHTipTranslation {font-style: normal;}
.EHTipTranslation a {color: #000099;font-style: normal;text-decoration: none;}
.EHTipTranslation a:hover {background: inherit;color: #000000;text-decoration: underline;}
</style>
</head>
<body style="background-color: rgb(255, 255, 255); color: rgb(0, 0,
0);" text="#000000" bgcolor="#FFFFFF">
I was only wondering why doesn't that work.<br>
The two functions were just an example of how I thought
OverloadedLists should/could work.<br>
<br>
I got an answer on irc that ':' constructor is not desugared, but I
expected it is.<br>
Compiler can see when overloading is for "real" list and skip it,
preserving performance.<br>
<br>
<br>
<br>
<blockquote style="border-left: 2px solid #330033 !important;
border-right: 2px solid #330033 !important; padding: 0px 15px 0px
15px; margin: 8px 2px;"
cite="mid:CAHnFXOvRn1ta714A5n=CVWd5bBHqDXxKrSuRLzpcFHC1ALFz=w@mail.gmail.com"
type="cite"><!--[if !IE]><DIV style="border-left: 2px solid #330033; border-right: 2px solid #330033; padding: 0px 15px; margin: 2px 0px;"><![endif]--><span
style="color:#000000;" class="headerSpan">
<div class="moz-cite-prefix">-------- Original Message --------<br>
Subject: Re: [Haskell-cafe] Pattern matching with
OverloadedLists<br>
From: Alejandro Serrano Mena <a class="moz-txt-link-rfc2396E" href="mailto:trupill@gmail.com"><trupill@gmail.com></a><br>
To: <a class="moz-txt-link-abbreviated" href="mailto:vlatko.basic@gmail.com">vlatko.basic@gmail.com</a><br>
Cc: haskell-cafe <a class="moz-txt-link-rfc2396E" href="mailto:Haskell-cafe@haskell.org"><Haskell-cafe@haskell.org></a><br>
Date: 06/11/15 16:38<br>
</div>
<br>
<br>
</span>
<div dir="ltr">You need to write `toList` in both branches:
<div><br>
</div>
<div><span style="font-size:12.8px">f (toList -> ('9':_)) = 1</span><br
style="font-size:12.8px">
<span style="font-size:12.8px">f (toList -> ('1':_)) = 2</span><br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">2015-11-06 16:20 GMT+01:00 Vlatko Basic
<span dir="ltr"><<a moz-do-not-send="true"
href="mailto:vlatko.basic@gmail.com" target="_blank">vlatko.basic@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hello
Cafe,<br>
<br>
wiki for OverloadedLists says that<br>
<br>
g [x,y,z] = ...<br>
<br>
is treated as<br>
<br>
g (toList-> [x,y,z]) =<br>
<br>
<br>
Shouldn't this work? Both 'f's should be treated the same.<br>
<br>
f :: Text -> Int<br>
f (toList -> ('9':_)) = 1 -- OK<br>
f ('1':_) = 2 -- Couldn't match expected
type ‘Text’ with actual type ‘[Char]’<br>
<br>
(OverloadedStrings is also on)<br>
<br>
Am I missing something?<br>
<br>
br,<br>
vlatko<br>
<br>
<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a moz-do-not-send="true"
href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a moz-do-not-send="true"
href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe"
rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
</blockquote>
</div>
<br>
</div>
<!--[if !IE]></DIV><![endif]--></blockquote>
<br>
</body>
</html>