<div class="gmail_quote">On 30 December 2010 17:23, Markus Läll <span dir="ltr"><<a href="mailto:markus.l2ll@gmail.com">markus.l2ll@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Yes, they are in the global scope, and from what I gather: they are just regular functions, created by special syntax.<br><br>There are a few obvious solutions (some of which you might have thought yourself :-):<br> - rename the accessor or the other function, or<br>
- put the data declaration or the other function in another module and import qualified, or<br> - write a typeclass with a 'name' function and fit the non-accessor function 'name' somehow into that...<br>
<br>I think the best approach is the modular one, but this really depends on what you are doing.<br><br></blockquote><div><br></div><div>Okay looks like name mangling with the datatypes name is in order then. Something like :-</div>
<div><br></div><div><font face="'courier new', monospace"> data Test </font></div><div><font face="'courier new', monospace"> = Test {</font></div><div><font face="'courier new', monospace"> testName :: String,</font></div>
<div><font face="'courier new', monospace"> testValue :: Int</font></div><div><font face="'courier new', monospace"> }</font></div><div> </div><div>Thanks,</div><div><br></div><div>Aaron</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">--<br>Markus Läll<br><br><div class="gmail_quote"><div><div></div><div class="h5">On Thu, Dec 30, 2010 at 7:01 PM, Aaron Gray <span dir="ltr"><<a href="mailto:aaronngray.lists@gmail.com" target="_blank">aaronngray.lists@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex"><div><div></div><div class="h5">Given a Haskell "record type" :-<div><br></div>
<div><div><font face="'courier new', monospace"> data Test </font></div>
<div><font face="'courier new', monospace"> = Test {</font></div>
<div><font face="'courier new', monospace"> name :: String,</font></div><div><font face="'courier new', monospace"> value :: Int</font></div>
<div><font face="'courier new', monospace"> }</font></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace"> test = Test {</font></div>
<div><font face="'courier new', monospace"> name = "test",</font></div><div><font face="'courier new', monospace"> <span style="white-space:pre-wrap">        </span> value = 1</font></div>
<div><font face="'courier new', monospace"> }</font></div><div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace"> main :: IO ()</font></div>
<div><font face="'courier new', monospace"> main = do</font></div><div><font face="'courier new', monospace"> putStrLn (name test)</font></div><div>
<br></div><div>Are "name" and "value" in the global name space, as the following gives an error "Multiple declarations of `name'" :-</div><div><br></div><div><font face="'courier new', monospace"> name :: String -> String</font></div>
<div><font face="'courier new', monospace"> name s = s</font></div></div><div><br></div><div>Is there any way round this ?</div><div><br></div><div>Many thanks in advance,</div><div><br>
</div><div>Aaron</div><div><br></div>
<br></div></div>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br>
</blockquote></div><br>