<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
On 03/24/2013 12:24 PM, Emmanuel Touzery wrote:
<blockquote
 cite="mid:CAC42Re=+sMEHUASJSYPLRZxa5oqLu7UKptPR0_riRxNadYbyvw@mail.gmail.com"
 type="cite">
  <div dir="ltr">
  <div>
  <div>But then since the library is using (..) that would mean
everything is exported?<br>
  <br>
  </div>
  </div>
  </div>
</blockquote>
It only means that those fields are exported from that specific
module.&nbsp; Downstream modules that use Network.Http.Types internally may
or may not re-export everything.<br>
<br>
Your example below doesn't import Network.Http.Types; it imports
Network.Http.Client.&nbsp; If you look at the source for Network.Http.Client
you will see that it does not re-export everything it imported from
Network.Http.Types:<br>
<br>
<a class="moz-txt-link-freetext" href="http://hackage.haskell.org/packages/archive/http-streams/0.4.0.0/doc/html/src/Network-Http-Client.html">http://hackage.haskell.org/packages/archive/http-streams/0.4.0.0/doc/html/src/Network-Http-Client.html</a><br>
<br>
When you import Network.Http.Client, `ghc` only uses whatever is in the
export list of Network.Http.Client.<br>
<blockquote
 cite="mid:CAC42Re=+sMEHUASJSYPLRZxa5oqLu7UKptPR0_riRxNadYbyvw@mail.gmail.com"
 type="cite">
  <div dir="ltr">
  <div>For instance testing on the Request data:<br>
  <br>
  <a moz-do-not-send="true"
 href="http://hackage.haskell.org/packages/archive/http-streams/0.4.0.0/doc/html/src/Network-Http-Types.html#Request">http://hackage.haskell.org/packages/archive/http-streams/0.4.0.0/doc/html/src/Network-Http-Types.html#Request</a><br>
  <pre><span class="">module</span> <span class="">Network</span><span
 class="">.</span><span class="">Http</span><span class="">.</span><span
 class="">Types</span> <span class="">(</span>
<a moz-do-not-send="true" name="line-17"></a>    <span class="">Request</span><span
 class="">(</span><span class="">..</span><span class="">)</span><span
 class="">,</span></pre>
  <pre><span class="">data</span> <span class="">Request</span>
<a moz-do-not-send="true" name="line-112"></a>    <span class="">=</span> <span
 class="">Request</span> <span class="">{</span>
<a moz-do-not-send="true" name="line-113"></a>        <span class="">qMethod</span>  <span
 class="">::</span> <span class="">!</span><span class="">Method</span><span
 class="">,</span>
<a moz-do-not-send="true" name="line-114"></a>        <span class="">qHost</span>    <span
 class="">::</span>  <span class="">Maybe</span> <span class="">ByteString</span><span
 class="">,</span>
<a moz-do-not-send="true" name="line-115"></a>        <span class="">qPath</span>    <span
 class="">::</span> <span class="">!</span><span class="">ByteString</span><span
 class="">,</span>
<a moz-do-not-send="true" name="line-116"></a>        <span class="">qBody</span>    <span
 class="">::</span> <span class="">!</span><span class="">EntityBody</span><span
 class="">,</span>
<a moz-do-not-send="true" name="line-117"></a>        <span class="">qExpect</span>  <span
 class="">::</span> <span class="">!</span><span class="">ExpectMode</span><span
 class="">,</span>
<a moz-do-not-send="true" name="line-118"></a>        <span class="">qHeaders</span> <span
 class="">::</span> <span class="">!</span><span class="">Headers</span>
<a moz-do-not-send="true" name="line-119"></a>    <span class="">}</span></pre>
  <br>
----<br>
{-# LANGUAGE OverloadedStrings #-}<br>
  <br>
import Network.Http.Client<br>
  <br>
main = do<br>
&nbsp;&nbsp;&nbsp; q &lt;- buildRequest $ do<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; http GET "/"<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; setAccept "text/html"<br>
  <br>
&nbsp;&nbsp;&nbsp; print q<br>
&nbsp;&nbsp;&nbsp; print $ qMethod q<br>
  <br>
---<br>
  <br>
test-hs.hs:11:17: Not in scope: `qMethod'<br>
  <br>
  </div>
With regards to what Daniel wrote, I realize my email was confusing.
When I was talking about warnings I was talking of another problem
entirely, that i probably should not have mentioned in this context.<br>
In that other context I had data declarations for types that I would
instanciate only from Data.Aeson parsing from JSON. I would then only
use pattern matching on the instances, never call the "accessor
functions" by themselves, then I get a warning that they're unused
which annoys me. But it's quite unrelated to this mail...<br>
  <br>
Emmanuel<br>
  <div><br>
  </div>
  </div>
  <div class="gmail_extra"><br>
  <br>
  <div class="gmail_quote">On Sun, Mar 24, 2013 at 6:34 PM, Gabriel
Gonzalez <span dir="ltr">&lt;<a moz-do-not-send="true"
 href="mailto:gabriel439@gmail.com" target="_blank">gabriel439@gmail.com</a>&gt;</span>
wrote:<br>
  <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
    <div bgcolor="#ffffff" text="#000000">
    <tt>Assume you have the following type:<br>
    <br>
data Type = T { field1 :: String, field2 :: Double }<br>
    <br>
... and you want to export the type `Type` and the acessors `field1`
and `field2`, but not the constructor `T`, then you would write:<br>
    <br>
module MyModule (<br>
&nbsp;&nbsp;&nbsp; Type(field1, field2)<br>
&nbsp;&nbsp;&nbsp; ) where<br>
    <br>
Another way to do this is like so:<br>
    <br>
module MyModule (<br>
&nbsp;&nbsp;&nbsp; Type,<br>
&nbsp;&nbsp;&nbsp; field1,<br>
&nbsp;&nbsp;&nbsp; field2<br>
&nbsp;&nbsp;&nbsp; ) where<br>
    <br>
That's perfectly legal, too.<br>
    <br>
Normally, when you write something like:<br>
    <br>
module MyModule (<br>
&nbsp;&nbsp;&nbsp; Type(..)<br>
&nbsp;&nbsp;&nbsp; ) where<br>
    <br>
the ".." expands out to:<br>
    <br>
module MyModule (<br>
&nbsp;&nbsp;&nbsp; Type(T, field1, field2)<br>
&nbsp;&nbsp;&nbsp; ) where<br>
    <br>
All the first solution does is just leave out the T constructor from
those exports.
    <div>
    <div class="h5"><br>
    <br>
On 03/24/2013 09:14 AM, Emmanuel Touzery wrote:</div>
    </div>
    </tt>
    <blockquote type="cite">
      <div>
      <div class="h5">
      <div dir="ltr">
      <div><tt>hi,<br>
      <br>
&nbsp;i was looking at the response type in http-streams:<br>
      <a moz-do-not-send="true"
 href="http://hackage.haskell.org/packages/archive/http-streams/0.4.0.0/doc/html/Network-Http-Client.html#t:Response"
 target="_blank">http://hackage.haskell.org/packages/archive/http-streams/0.4.0.0/doc/html/Network-Http-Client.html#t:Response</a><br>
      <br>
&nbsp;I'm used that simply the data type and all its "members" are visible --<br>
the functions to access its contents. But in this case on the HTML<br>
documentation the response type looks like it has no members. And the<br>
author has defined like "public accessors" later in the code:<br>
      <br>
getStatusCode :: Response -&gt; StatusCode<br>
getStatusCode = pStatusCode<br>
      <br>
So I'm not even sure how he achieved that the members are not visible,<br>
the data are exported with (..) as is usually done... And the other
thing is why<br>
would you do that.. You could name the member getStatusCode in the first<br>
place, but then it might increase encapsulation to hide it (depending
on how he<br>
managed to hide the members).. But did you then make<br>
it impossible to deconstruct a Response through pattern matching? That<br>
sounds like a minus... Although pattern matching on a data with 6 fields<br>
is always going to be a pain and decreasing the chances for modifying<br>
the data type without breaking compatibility.<br>
      <br>
      </tt></div>
      <div><tt>These "members" are also causing me problems in other
situations, for instance I have some cases when I use a data type only
a few times and with -Wall the compiler tells me I don't use the
accessor; in fact I read that value from the data, but through pattern
matching/deconstruction only, not through that particular function. I'm
thinking to try to hide the warning as I think my code is correct.<br>
      </tt></div>
      <div><tt><br>
Anyway I'm curious on the mechanism used by that library... I've
already noticed a few nice tricks in this library, like a small state
monad to take optional parameters, much more elegant than any other
mechanism i've seen so far to achieve the same effect.<br>
      <br>
      </tt></div>
      <tt>Thank you!<br>
      </tt>
      <div><tt><br>
Emmanuel<br>
      </tt></div>
      </div>
      </div>
      </div>
      <pre><tt>
</tt><fieldset></fieldset><tt>
_______________________________________________
Beginners mailing list
<a moz-do-not-send="true" href="mailto:Beginners@haskell.org"
 target="_blank">Beginners@haskell.org</a>
<a moz-do-not-send="true"
 href="http://www.haskell.org/mailman/listinfo/beginners"
 target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a>
</tt></pre>
    </blockquote>
    <tt><br>
    </tt>
    </div>
  </blockquote>
  </div>
  <br>
  </div>
  <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
Beginners mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Beginners@haskell.org">Beginners@haskell.org</a>
<a class="moz-txt-link-freetext" href="http://www.haskell.org/mailman/listinfo/beginners">http://www.haskell.org/mailman/listinfo/beginners</a>
  </pre>
</blockquote>
<br>
</body>
</html>