Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  Re: Memory usage problem (Sami Liedes)
   2.  Re: Memory usage problem (Heinrich Apfelmus)
   3.  SMTPClient + hsemail-1.6 = errors (Sergey Mironov)
   4. Re:  SMTPClient + hsemail-1.6 = errors (Robert Wills)
   5.  Cygwin error: D:\Haskell\bin/windres: can't open temporary
      file `\/cca02652.irc': No such file or directory (remy willems)
   6.  Re: Cygwin error: D:\Haskell\bin/windres: can't  open
      temporary file `\/cca02652.irc': No such file or directory
      (remy willems)
   7.  Rewriting traversal over trees (Darryn Reid)


----------------------------------------------------------------------

Message: 1
Date: Thu, 25 Mar 2010 02:36:17 +0200
From: Sami Liedes <[email protected]>
Subject: Re: [Haskell-beginners] Re: Memory usage problem
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

On Wed, Mar 24, 2010 at 11:23:05AM +0100, Heinrich Apfelmus wrote:
> A quick fix would be to intersperse a function between  sort  and
> readRecords  that imposes proper evaluation order:
[...]
> While I expect the above to work, I hesitate to claim that it actually
> does. The reason is that I don't understand your  readRecords  function
> at a glance, unlike the  processFile  pipeline, it is not apparent how
> it works. Since finding and fixing space leaks is easier if your code is
> more obvious, I recommend to reformulate it as a function composition as
> well, for instance something like this:
[...]

Thanks, that was enlightening! With your version of readRecords the
program takes as much memory as with mine (it's still more than 10x
what the C version takes, but perhaps that's the cost of using
Haskell). But your version taught me a lot. Exactly the kind of
feedback I needed :)

        Sami
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
Url : 
http://www.haskell.org/pipermail/beginners/attachments/20100324/e4f5d81f/attachment-0001.bin

------------------------------

Message: 2
Date: Thu, 25 Mar 2010 11:26:35 +0100
From: Heinrich Apfelmus <[email protected]>
Subject: [Haskell-beginners] Re: Memory usage problem
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8

Sami Liedes wrote:
> On Wed, Mar 24, 2010 at 11:23:05AM +0100, Heinrich Apfelmus wrote:
>> A quick fix would be to intersperse a function between  sort  and
>> readRecords  that imposes proper evaluation order:
> [...]
>> While I expect the above to work, I hesitate to claim that it actually
>> does. The reason is that I don't understand your  readRecords  function
>> at a glance, unlike the  processFile  pipeline, it is not apparent how
>> it works. Since finding and fixing space leaks is easier if your code is
>> more obvious, I recommend to reformulate it as a function composition as
>> well, for instance something like this:
> [...]
> 
> Thanks, that was enlightening! With your version of readRecords the
> program takes as much memory as with mine (it's still more than 10x
> what the C version takes, but perhaps that's the cost of using
> Haskell). But your version taught me a lot. Exactly the kind of
> feedback I needed :)

My pleasure. :)

I should point out that my version of  readRecords  still needs to be
composed with the  strictify  function, for the same reasons as yours.
But it shouldn't be very difficult to bake the evaluation order into
readRecords  now if desired.


Also note that my  readRecord  has introduced another potential space
leak. But thanks to the clarified structure, it is easy to spot. Namely,
the function

     prefix "Name: " &&& prefix "Version: "

is problematic. Expanding the (&&&) combinator, this is equal to

    \xs -> (prefix "Name: " xs, prefix "Version: " xs)

which means that the  xs  is used twice and thus potentially leaky.
After all, the first component might evaluate  xs  in full, which will
then leak around until the second component consumes it. This is exactly
what will happen if you feed it a patological input file consisting of
just a single but huge record along the lines of

    Version: xyz
    Name: haskell
    Foo: bar
    Foo: bar
    ...
    ...
    Foo: Bar


If this turns out to be a major problem, you can simply rewrite the
offending function to evaluate the components "in parallel". The
partition  function in the Haskell Prelude demonstrates how to do this.



Regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com



------------------------------

Message: 3
Date: Fri, 26 Mar 2010 02:34:14 +0300
From: Sergey Mironov <[email protected]>
Subject: [Haskell-beginners] SMTPClient + hsemail-1.6 = errors
To: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

Hi.
I was trying to install  SMTPClient-1.0.1

Compiler reported me:

ier...@vault SMTPClient-1.0.1 % cabal build
Preprocessing library SMTPClient-1.0.1...
Building SMTPClient-1.0.1...
[1 of 2] Compiling Network.SMTP.ClientSession (
Network/SMTP/ClientSession.hs, dist/build/Network/SMTP/ClientSession.o
)

Network/SMTP/ClientSession.hs:242:16:
    Not in scope: data constructor `Message'

Network/SMTP/ClientSession.hs:406:15:
    Not in scope: data constructor `Message'

I've made some digging: Seems that newest version of 'hsemail' (1.6)
breaks backward compatibility (SMTPClient depends on it)

My questions:
1) Where should i send bugreport to?
There are no emails on http://hackage.haskell.org/package/SMTPClient
so i don't know how to contact maintainers.

2) How to fallback hsemail?
i tried:

ier...@vault ~ % cabal install hsemail-1.3  #  good, i suppose
ier...@vault ~ % ghc-pkg hide hsemail-1.6 # Bad one
ier...@vault ~ % caball install -v SMTPClient
...
... bla-bla ...
...
selecting hsemail-1.6 (installed or hackage) and discarding hsemail-1.0, 1.1,
1.2, 1.3, 1.4 and 1.5
...

Looks like hiding a package is not a case for me.

ps

I am using ghc-6.12

--
Thanks,
Sergey


------------------------------

Message: 4
Date: Fri, 26 Mar 2010 01:02:15 +0000
From: Robert Wills <[email protected]>
Subject: Re: [Haskell-beginners] SMTPClient + hsemail-1.6 = errors
To: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

HaskellNet contains an smtp client as well.

http://hackage.haskell.org/package/HaskellNet

It worked last time I checked.

main = do
 con <- connectSMTP smtpServer
 let msg = ([("From", "HaskellNet <" ++ sendFrom ++
">"),("Subject","Test")], BS.pack "\r\nhello from haskellnet")
 sendMail sendFrom sendTo (BS.pack $ show $ showMessage "utf-8" msg) con
 closeSMTP con

Regards,
Rob

On Thu, Mar 25, 2010 at 11:34 PM, Sergey Mironov <[email protected]> wrote:
> Hi.
> I was trying to install  SMTPClient-1.0.1
>
> Compiler reported me:
>
> ier...@vault SMTPClient-1.0.1 % cabal build
> Preprocessing library SMTPClient-1.0.1...
> Building SMTPClient-1.0.1...
> [1 of 2] Compiling Network.SMTP.ClientSession (
> Network/SMTP/ClientSession.hs, dist/build/Network/SMTP/ClientSession.o
> )
>
> Network/SMTP/ClientSession.hs:242:16:
>    Not in scope: data constructor `Message'
>
> Network/SMTP/ClientSession.hs:406:15:
>    Not in scope: data constructor `Message'
>
> I've made some digging: Seems that newest version of 'hsemail' (1.6)
> breaks backward compatibility (SMTPClient depends on it)
>
> My questions:
> 1) Where should i send bugreport to?
> There are no emails on http://hackage.haskell.org/package/SMTPClient
> so i don't know how to contact maintainers.
>
> 2) How to fallback hsemail?
> i tried:
>
> ier...@vault ~ % cabal install hsemail-1.3  #  good, i suppose
> ier...@vault ~ % ghc-pkg hide hsemail-1.6 # Bad one
> ier...@vault ~ % caball install -v SMTPClient
> ...
> ... bla-bla ...
> ...
> selecting hsemail-1.6 (installed or hackage) and discarding hsemail-1.0, 1.1,
> 1.2, 1.3, 1.4 and 1.5
> ...
>
> Looks like hiding a package is not a case for me.
>
> ps
>
> I am using ghc-6.12
>
> --
> Thanks,
> Sergey
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>


------------------------------

Message: 5
Date: Thu, 25 Mar 2010 21:16:25 +0100
From: remy willems <[email protected]>
Subject: [Haskell-beginners] Cygwin error: D:\Haskell\bin/windres:
        can't open      temporary file `\/cca02652.irc': No such file or 
directory
To: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

I am using cygwin. While in cygwin, when I try to make EHC, the essential
haskell compiler, I get the following error:

D:\Haskell\bin/windres: can't open temporary file `\/cca02652.irc': No such
file
 or directory
strip: 'build/libutil/setup.exe': No such file

There are no strange permission in the folder I'm running the make. I'm the
administrator and am running cygwin in "run as adminstrator" mode.

Could someone help me? I'm really stuck with this. Much appreciated,
Remy.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20100325/f04e10bb/attachment-0001.html

------------------------------

Message: 6
Date: Thu, 25 Mar 2010 21:53:56 +0100
From: remy willems <[email protected]>
Subject: [Haskell-beginners] Re: Cygwin error: D:\Haskell\bin/windres:
        can't   open temporary file `\/cca02652.irc': No such file or directory
To: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

I'm trying to install the package directory from cygwin. I am a windows user
and have tried to use "cabal install directory" from the windows prompt but
that quickly gives an error about a missing tool.
I'm using cygwin to install directory now. However I still get an error. The
error is:

* Missing header file: HsDirectory.h
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.

I have searched for this file and found it in the
"Haskell\directory1.0.1.0\include" folder. I googled the error and found
something about adding #include <sys/types> to the file. The "HsDirectory.h"
file already contains "#include <sys/types>".
What should I do?
Many thanks,
Remy.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20100325/9ad1c95b/attachment-0001.html

------------------------------

Message: 7
Date: Fri, 26 Mar 2010 16:53:27 +1030
From: Darryn Reid <[email protected]>
Subject: [Haskell-beginners] Rewriting traversal over trees
To: [email protected]
Message-ID: <1269584607.2484.33.ca...@montaigne>
Content-Type: text/plain; charset="UTF-8"


Hi, I hope that this is an appropriate place to post this question; I'm
an experienced computer scientist and mathematician but am new to
Haskell (I love it, I might add, but have much to learn).

I've coded a (fairly) general rewriting traversal - I suspect the
approach might be generalisable to all tree-like types, but this doesn't
concern me much right now. My purpose is for building theorem provers
for a number of logics, separating the overall control mechanism from
the specific rules for each logic.

The beauty of Haskell here is in being able to abstract the traversal
away from the specific reduction rules and languages of the different
logics. I have paired down the code here to numbers rather than modal
formulas for the sake of clarity and simplicity. My question is
two-fold:
1. Does my representation of the traversal seem good or would it be
better expressed differently? If so, I'd appreciate the thoughts of more
experienced Haskell users.
2. I cannot really see how to easily extend this to a queue-based
breadth-first traversal. I'm sure others must have a good idea of how to
do what I'm doing here except in breadth-first order; I'd appreciate it
very much if someone could show me how to make a second breadth-first
version.

Thanks in advance for any help!

Darryn.

start of code.
-------------------------------------------------------------------------
import Control.Monad
import Control.Monad.Identity

-- Tableau is a tree containing formulas of type a, in 
-- Fork (disjunctive) nodes and Single (conjunctive) nodes.
-- Paths from root to Nil each represent an interpretation.
data Tableau a =   Nil                           -- End of a path
                 | Single a (Tableau a)          -- Conjunction
                 | Fork (Tableau a) (Tableau a)  -- Disjunction
                 deriving (Eq, Show)

-- 'Cut' directs the traversal to move back up the tree rather than into
-- the current subtree, while 'Next' directs the traversal to proceed
-- into the subtree.
data Action = Cut | Next 
              deriving (Eq, Show)

-- The type of the rewrite function to perform at each node in
-- the traversal of the tree. The Rewriter returns the new
-- subtree to replace the existing subtree rooted at the
-- traversal node, and a direction controlling the traversal
-- to the next node.
type Rewriter m a = Tableau a -> m (Tableau a, Action)

-- The traversal function, depth-first order.
rewrite :: (Monad m) => Rewriter m a -> Tableau a -> m (Tableau a)
rewrite rf t = do (t', d) <- rf t
                  rewrite' rf d t'

-- Worker function for traversal, really its main body.
rewrite' :: (Monad m) => Rewriter m a -> Action -> Tableau a -> m
(Tableau a)
rewrite' rf Cut  t             = return t
rewrite' rf Next Nil           = return Nil
rewrite' rf Next (Single x t1) = do t1' <- rewrite rf t1
                                    return (Single x t1')
rewrite' rf Next (Fork t1 t2)  = do t1' <- rewrite rf t1
                                    t2' <- rewrite rf t2
                                    return (Fork t1' t2')

-- Some examples to test the code with:
-- ghci> let t0 = (Single 2 (Single 3 Nil))
-- ghci> let t1 = (Single 1 (Fork t0 (Fork (Single 4 Nil) (Single 5
Nil))))
-- ghci> let t2 = (Fork (Single 10 Nil) (Single 11 Nil))
-- ghci> let t3 = (Fork (Single 3 Nil) (Single 3 Nil))

-- Running "test4 t1 t2" produces the expected result; running 
-- "test4 t1 t3" does not terminate, because this endlessly 
-- generates new patterns that match the substitution condition:
test4 :: (Num t) => Tableau t -> Tableau t -> Tableau t
test4 tab tab' = runIdentity (rewrite rf tab)
            where rf (Single 3 Nil) = return (tab', Next)
                  rf t              = return (t, Next)

-- Running "test5 t1 t3", however, does terminate because the "Cut"
-- prevents the traversal from entering the newly spliced subtrees
-- that match the pattern.
test5 :: (Num t) => Tableau t -> Tableau t -> Tableau t
test5 tab tab' = runIdentity (rewrite rf tab)
            where rf (Single 3 Nil) = return (tab', Cut)
                  rf t              = return (t, Next)
-------------------------------------------------------------------------
end of code.



------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 21, Issue 27
*****************************************

Reply via email to