<div dir="ltr">Hi David,<div><br></div><div>Thanks for chipping in. I found the solution to be to include "directory" in cabal file "build-depends". I was confused because my stack ghci config didn't need :m + System.directory to work. But somehow cabal repl does not work without some kind of import.<br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 22, 2016 at 8:00 PM,  <span dir="ltr"><<a href="mailto:beginners-request@haskell.org" target="_blank">beginners-request@haskell.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Send Beginners mailing list submissions to<br>
        <a href="mailto:beginners@haskell.org">beginners@haskell.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/beginners</a><br>
or, via email, send a message with subject or body 'help' to<br>
        <a href="mailto:beginners-request@haskell.org">beginners-request@haskell.org</a><br>
<br>
You can reach the person managing the list at<br>
        <a href="mailto:beginners-owner@haskell.org">beginners-owner@haskell.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of Beginners digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
   1.  cabal repl issue (Lai Boon Hui)<br>
   2. Re:  cabal repl issue (David McBride)<br>
   3. Re:  Monadic functions definitions for free monadic DSL<br>
      (Sumit Raja)<br>
   4. Re:  Monadic functions definitions for free monadic DSL<br>
      (Kim-Ee Yeoh)<br>
<br>
<br>
------------------------------<wbr>------------------------------<wbr>----------<br>
<br>
Message: 1<br>
Date: Fri, 21 Oct 2016 22:35:19 +0800<br>
From: Lai Boon Hui <<a href="mailto:laiboonh@gmail.com">laiboonh@gmail.com</a>><br>
To: <a href="mailto:beginners@haskell.org">beginners@haskell.org</a><br>
Subject: [Haskell-beginners] cabal repl issue<br>
Message-ID:<br>
        <CAJdQggnSvw8z7V+SBY=<a href="mailto:y2TEfhpcK2znLHpkp9i%2BEdq5QAgXM7w@mail.gmail.com">y2TEfhpcK<wbr>2znLHpkp9i+Edq5QAgXM7w@mail.<wbr>gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
Hi all,<br>
<br>
when i execute cabal repl i get this:<br>
<br>
<interactive>:1:8: error:<br>
<br>
    Not in scope: ‘System.Directory.<wbr>getCurrentDirectory’<br>
<br>
    No module named ‘System.Directory’ is imported.<br>
because my ghci.conf has<br>
:def pwd (\_-> System.Directory.<wbr>getCurrentDirectory >>= print >> return "")<br>
<br>
Does anyone know how i can include System.Directory somehow even though its<br>
not used in my cabal project?<br>
<br>
--<br>
Best Regards,<br>
Boon Hui<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mail.haskell.org/pipermail/beginners/attachments/20161021/81951b8d/attachment-0001.html" rel="noreferrer" target="_blank">http://mail.haskell.org/<wbr>pipermail/beginners/<wbr>attachments/20161021/81951b8d/<wbr>attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Fri, 21 Oct 2016 10:56:55 -0400<br>
From: David McBride <<a href="mailto:toad3k@gmail.com">toad3k@gmail.com</a>><br>
To: The Haskell-Beginners Mailing List - Discussion of primarily<br>
        beginner-level topics related to Haskell <<a href="mailto:beginners@haskell.org">beginners@haskell.org</a>><br>
Subject: Re: [Haskell-beginners] cabal repl issue<br>
Message-ID:<br>
        <CAN+Tr42JiQ3x-MtrZXthx=<a href="mailto:PHjnJ%2BRH7zj3HJGQ6L%2Bj7Y3cFcfw@mail.gmail.com">PHjnJ+<wbr>RH7zj3HJGQ6L+j7Y3cFcfw@mail.<wbr>gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
Just do this:<br>
<br>
:m +System.Directory<br>
:def pwd (\_ -> getCurrentDirectory >>= print >> return "")<br>
<br>
On Fri, Oct 21, 2016 at 10:35 AM, Lai Boon Hui <<a href="mailto:laiboonh@gmail.com">laiboonh@gmail.com</a>> wrote:<br>
<br>
> Hi all,<br>
><br>
> when i execute cabal repl i get this:<br>
><br>
> <interactive>:1:8: error:<br>
><br>
>     Not in scope: ‘System.Directory.<wbr>getCurrentDirectory’<br>
><br>
>     No module named ‘System.Directory’ is imported.<br>
> because my ghci.conf has<br>
> :def pwd (\_-> System.Directory.<wbr>getCurrentDirectory >>= print >> return<br>
> "")<br>
><br>
> Does anyone know how i can include System.Directory somehow even though<br>
> its not used in my cabal project?<br>
><br>
> --<br>
> Best Regards,<br>
> Boon Hui<br>
><br>
> ______________________________<wbr>_________________<br>
> Beginners mailing list<br>
> <a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/beginners</a><br>
><br>
><br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mail.haskell.org/pipermail/beginners/attachments/20161021/81bfe668/attachment-0001.html" rel="noreferrer" target="_blank">http://mail.haskell.org/<wbr>pipermail/beginners/<wbr>attachments/20161021/81bfe668/<wbr>attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
Message: 3<br>
Date: Sat, 22 Oct 2016 12:14:15 +1100<br>
From: Sumit Raja <<a href="mailto:sumitraja@gmail.com">sumitraja@gmail.com</a>><br>
To: <a href="mailto:beginners@haskell.org">beginners@haskell.org</a><br>
Subject: Re: [Haskell-beginners] Monadic functions definitions for<br>
        free monadic DSL<br>
Message-ID:<br>
        <<a href="mailto:CAD4nrSf68uPFaHKpHN01wJjhhMMO5tSBQqHfM1cBogphxvUihg@mail.gmail.com">CAD4nrSf68uPFaHKpHN01wJjhhMMO<wbr>5tSBQqHfM1cBogphxvUihg@mail.<wbr>gmail.com</a>><br>
Content-Type: text/plain; charset=UTF-8<br>
<br>
> I feel like if you can figure out what you actually want Accept to do, it<br>
> will become clearer.  Here's my attempt.  Accept takes a chan, takes a<br>
> procedure to loop on, a procedure to accept on, and then returns the server<br>
> chan to continue the loop.  I don't know if this is entirely right, but it<br>
> type checks and hopefully it will give you some ideas.<br>
<br>
As you've said Accept needs refinement. I tried writing a interpretUDP<br>
which doesn't have an accept loop but does have a bind + listen. I<br>
suspect that accept needs to move into the interpretTCP somehow and<br>
the DSL needs to be Bind or similar. Bind makes more sense as well if<br>
I wanted to write a pipes or a chan based interpreter.<br>
<br>
Thanks for the rewrite and the pointers.<br>
<br>
-Sumit<br>
<br>
<br>
------------------------------<br>
<br>
Message: 4<br>
Date: Sat, 22 Oct 2016 08:27:32 +0700<br>
From: Kim-Ee Yeoh <<a href="mailto:ky3@atamo.com">ky3@atamo.com</a>><br>
To: The Haskell-Beginners Mailing List - Discussion of primarily<br>
        beginner-level topics related to Haskell <<a href="mailto:beginners@haskell.org">beginners@haskell.org</a>><br>
Subject: Re: [Haskell-beginners] Monadic functions definitions for<br>
        free monadic DSL<br>
Message-ID:<br>
        <<a href="mailto:CAPY%2BZdQfO_%2B42BGYd2zAL6bvdgQuCadjgADj0T_7C7ogk-Xvpg@mail.gmail.com">CAPY+ZdQfO_+<wbr>42BGYd2zAL6bvdgQuCadjgADj0T_<wbr>7C7ogk-Xvpg@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
Dear Sumit,<br>
<br>
You are right that there's something's fishy about the free monadic<br>
modeling of accept.<br>
<br>
The following parallel construction will prove instructive:<br>
<br>
The native effect:<br>
<br>
   send :: chan -> ByteString -> IO Bool<br>
<br>
is modeled in the free monad by the constructor for the base functor<br>
<br>
   Send :: chan -> ByteString -> (Bool -> next) -> NetworkActivity chan next<br>
<br>
which is the data wrapping used in the value level<br>
<br>
   sendit :: chan -> ByteString -> Free (NetworkActivity chan) Bool<br>
   sendit chan buf = liftF (Send chan buf identity)<br>
<br>
Analogously, the native<br>
<br>
   accept :: chan -> IO chan<br>
<br>
is modeled by<br>
<br>
   Accept :: chan -> (chan -> next) -> NetworkActivity chan next<br>
<br>
used in<br>
<br>
   acc :: chan -> Free (NetworkActivity chan) chan<br>
   acc chan = liftF (Accept chan identity)<br>
<br>
Except that you used a different constructor for the base functor. Not<br>
<br>
   Accept :: chan -> (chan -> next) -> NetworkActivity chan next<br>
<br>
but<br>
<br>
   Accept :: chan -> next -> (chan -> next) -> NetworkActivity chan next<br>
<br>
which is equivalent to<br>
<br>
   Accept :: chan -> (Maybe chan -> next) -> NetworkActivity chan next<br>
<br>
The new free monadic term that substitutes for the native accept is the<br>
same like before<br>
<br>
   acc chan = liftF (Accept chan identity)<br>
<br>
only with a different type<br>
<br>
   acc :: chan -> Free (NetworkActivity chan) (Maybe chan)<br>
<br>
modeling a native<br>
<br>
   accept :: chan -> IO (Maybe chan)<br>
<br>
Given a native API, its free monad encoding is entirely boilerplate. I<br>
wrote about the boilerplate process here (skip the sections that don't<br>
concern you):<br>
<br>
<a href="http://www.atamo.com/articles/free-monads-wont-detox-your-colon/" rel="noreferrer" target="_blank">http://www.atamo.com/articles/<wbr>free-monads-wont-detox-your-<wbr>colon/</a><br>
<br>
Best, Kim-Ee<br>
<br>
-- Kim-Ee<br>
<br>
On Fri, Oct 14, 2016 at 6:44 AM, Sumit Raja <<a href="mailto:sumitraja@gmail.com">sumitraja@gmail.com</a>> wrote:<br>
<br>
> > I would really like to help you, but without your imports, packages, etc,<br>
> > it is really hard to interpret your program.  Like where does decodeUtf8<br>
> > come from, or receive, or TCPSocket?  If they are functions you wrote, I<br>
> > don't need their code, the types would be sufficient.<br>
> ><br>
> Imports are:<br>
><br>
> import Protolude<br>
> import Control.Monad.Free<br>
> import System.Socket<br>
> import System.Socket.Family.Inet<br>
> import System.Socket.Type.Stream<br>
> import System.Socket.Protocol.TCP<br>
> import Control.Exception ( bracket, catch )<br>
> import Data.ByteString as BS (uncons)<br>
><br>
>     decodeUtf8 :: ByteString -> Text<br>
>     encodeUtf8 :: Text -> ByteString<br>
><br>
> I'm using the socket library for the actual networking<br>
> (<a href="https://hackage.haskell.org/package/socket-0.6.0.1" rel="noreferrer" target="_blank">https://hackage.haskell.org/<wbr>package/socket-0.6.0.1</a>)<br>
><br>
>     type TCPSocket = Socket Inet Stream TCP<br>
>     receive :: Socket f t p -> Int -> MessageFlags -> IO ByteString Source<br>
>     send :: Socket f t p -> ByteString -> MessageFlags -> IO Int<br>
>     accept :: (Family f, Storable (SocketAddress f)) => Socket f t p<br>
> -> IO (Socket f t p, SocketAddress f)<br>
><br>
> If it helps the full source is at<br>
> <a href="https://bitbucket.org/sumitraja/network-free/src/" rel="noreferrer" target="_blank">https://bitbucket.org/<wbr>sumitraja/network-free/src/</a><br>
> a4fcbc74c9e178e81d8b10b60d912b<wbr>32c542b661/src/Lib.hs.<br>
><br>
> Looking forward to your assistance.<br>
><br>
> Thanks<br>
><br>
> Sumit<br>
> ______________________________<wbr>_________________<br>
> Beginners mailing list<br>
> <a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/beginners</a><br>
><br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mail.haskell.org/pipermail/beginners/attachments/20161022/742c58ac/attachment-0001.html" rel="noreferrer" target="_blank">http://mail.haskell.org/<wbr>pipermail/beginners/<wbr>attachments/20161022/742c58ac/<wbr>attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
Subject: Digest Footer<br>
<br>
______________________________<wbr>_________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/beginners</a><br>
<br>
<br>
------------------------------<br>
<br>
End of Beginners Digest, Vol 100, Issue 14<br>
******************************<wbr>************<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Best Regards,<div>Boon Hui</div></div></div>
</div></div></div>