Re: [Haskell-cafe] Cleaning up stable names?

2009-09-01 Thread Peter Verswyvelen
but without that function, stable names are not that useful I guess? they
would cause a space leak?
On Mon, Aug 31, 2009 at 10:59 PM, Job Vranish jvran...@gmail.com wrote:

 I also would like a isStableNameTargetAlive function.
 Though if you had such a function then you probably _could_ make a
 deRefStableName function, which, since there isn't one, probably means
 that such a function would be hard to make.

 - Job

 On Sun, Aug 30, 2009 at 4:54 PM, Peter Verswyvelen bugf...@gmail.comwrote:

 From the documentation, I don't think I grasp how stable names work.
 From the docs:
 There is no deRefStableName operation. You can't get back from a stable
 name to the original Haskell object. The reason for this is that the
 existence of a stable name for an object does not guarantee the existence of
 the object itself; it can still be garbage collected.

 From this I can conclude that stable names behave a bit like weak
 pointers.

 However, suppose I have a hash table of these stable names. How can I
 remove the redundant stable names from the table? I mean removing stable
 names that refer to an object that is garbage collected? I don't see any
 function for checking that (e.g. isStableNameTargetAlive or something)

 Thanks,
 Peter





 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Snow Leopard Breaks GHC

2009-09-01 Thread Christian Maeder

It seems, bootstrapping cabal went wrong. Does
http://hackage.haskell.org/platform/2009.2.0.2/haskell-platform-2009.2.0.2-i386.dmg
work?

Once cabal works, options --ld-option=-m32 (and also --gcc-option=-m32)
may be used. These options may also be passed to ./Setup configure

C.

Tom Tobin wrote:
 Hmm ... running Snow Leopard here, I added these arguments to my
 /usr/bin/ghc (and my /usr/bin/ghci, and /usr/bin/runhaskell, for good
 measure), and I end up getting the following error on cabal update
 after installing cabal-install:
 
 *
 cabal: user error (Codec.Compression.Zlib: incompatible version)
 *
 
 Earlier in the cabal-install bootstrap process, I get the following line:
 
 *
 ld: warning: in
 /Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/libgmp.a,
 file is not of required architecture
 *
 
 I'm guessing something's still not being set to 32-bit?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Takusen - is anyone currently using it on Win32 - ODBC?

2009-09-01 Thread Jeff Zaroyko
2009/9/1 Günther Schmidt gue.schm...@web.de:

 One of the files for instance has 298 k lines. A glance over sushi revealed
 that parsec is involved so I can only presume it is read into memory all at
 once. That would certainly be a problem.


There is nothing inherent about parsec that would cause all input to
be read into memory, TxtSushi uses parsec for parsing SQL, not for
CSV, by the way.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Question about Lazy.IO

2009-09-01 Thread staafmeister


Hi,

I've been wondering about Lazy IO for a while. Suppose we have a program
like

main = interact (unlines . somefunction . lines)

then somefunction is a pure function. With the semantic interpretation of:
given a input list
return an output list. However I, the user, can change my input depending on
the output of this
function. Now in simple cases like this, this will not be a problem. But
suppose you are reading
and writing to a file. Now the result of pure functions become dependent on
the order of execution,
breaking (I think) referential transparency. Am I wrong here or how could
you prove that Lazy IO
is consistent nonetheless?

Greetings,
Gerben

-- 
View this message in context: 
http://www.nabble.com/Question-about-Lazy.IO-tp25236848p25236848.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Question about Lazy.IO

2009-09-01 Thread Luke Palmer
On Tue, Sep 1, 2009 at 3:05 AM, staafmeisterg.c.stave...@uu.nl wrote:
 Hi,

 I've been wondering about Lazy IO for a while. Suppose we have a program
 like

 main = interact (unlines . somefunction . lines)

 then somefunction is a pure function. With the semantic interpretation of:
 given a input list
 return an output list. However I, the user, can change my input depending on
 the output of this
 function. Now in simple cases like this, this will not be a problem. But
 suppose you are reading
 and writing to a file. Now the result of pure functions become dependent on
 the order of execution,
 breaking (I think) referential transparency. Am I wrong here or how could
 you prove that Lazy IO
 is consistent nonetheless?

Ignoring timeliness in responses (which our theory doesn't talk
about), you are allowed to change your input based on its output in
exactly the same way as any other function could.

The reason this is okay is in the realm of domain theory.  There is a
good introductory tutorial in the Haskell wikibook:
http://en.wikibooks.org/wiki/Haskell/Denotational_semantics

Here is an intuition.  Let's forget you are a user, and just call you
a function user.

user :: String - String
program :: String - String

The input and output of a program is related to these functions like so:

let input = user output
output = program input
in (input, output)

Now, user could certainly be a function like:

user ('a':rest) = 'x':rest
user ('b':rest) = 'y':rest

Which makes a decision about what to type before seeing all the
output.  Program could make use of this:

program inp = 'a':case inp of { 'x':_ - hello; 'y':_ - world }

This mutual recursion would not be well-defined if all of the output
must be seen before the input can be known, because the output depends
on the input and the input depends on the output.  However, this is a
perfectly valid Haskell program, without considering I/O, and will
compute (input, output) to be (xhello, ahello).

I have now tried twice to explain why this is possible more deeply in
terms of domain theory, but it has bloated the message to three times
this size.  If you would like me to include my response, I'd be more
than happy to, but it does get rather technical.

Luke
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Question about Lazy.IO

2009-09-01 Thread staafmeister


Dear Luke,

Thanks for your reply. I am interested in a more detailed explanation. If
it's
to long for this forum you can also mail it to me.

In response to your answer. In your program the user is also a pure
function. But I,
as a user, am not pure so I can do side effects. More specific suppose I
program something like this

ss - hGetContent handle (lazy IO)
dosomethingweird handle ss (a function that alters the file at will)

Now as a programmer I should be positive that ss will be the file as it was
before dosomethingweird modifies it. But this can never be guaranteed if ss
is lazy. And now things start to depend on the order of evaluation breaking
referential transparency, or do I overlook something.

For concreteness suppose dosomethingweird appends ss to the end of the
file. If ss is strict then it just copies the whole file, if ss is lazy it
copies the
whole file an infinite number of times.

Gerben


-- 
View this message in context: 
http://www.nabble.com/Question-about-Lazy.IO-tp25236848p25238044.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Problems installing documentation and sources using Cabal on Mac OSX

2009-09-01 Thread Colin Adams
I noticed today on the train (no internet connection!) that the
documentation for packages I had installed with cabal was missing, and
that there was no source in .cabal/packages for them.

Now I'm in the offiice, I tried --reinstall --enable-documentation.
There was a warning about haddock and ghc version mismatch (so much
for the haskell platform install), so I did a --reinstall of haddock.

Now the message I see is:

cabal: can't find source for module Paths_happstack_server

(happstack_server is the first package I'm trying to reinstall to get docs).

So I think the documentation failure is because haddock can't find the
source code (nor can I), but I don't know why there is no source
installed in .cabal/packages - what should I do to further track this
problem down?

-- 
Colin Adams
Preston,
Lancashire,
ENGLAND
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Re[2]: [Haskell-cafe] GUI library

2009-09-01 Thread Job Vranish
Deallocation is automatic (just like C++ Qt)

C++ Qt has excellent unicode support. I haven't explicit tried it in
qtHaskell, but as far as I know it should work just fine.

Unfortunatly it does not currently build just with cabal, however the build
scripts are very clean (no configure) and the haskell half is cabalized.
 To build on windows you only need the haskell platform and the Qt SDK
(and then you either have to put the ghc path into Qts qtEnv.bat (what I
did), or you have to put the Qt paths into the system path) and then you run
the qtHaskells build.bat and you're done.
 To build on linux you need the haskell platform and Qt4 dev libraries
(they are probably in your distros package manager) and then you run the
qtHaskells build script, and your done. Umm, with one gotcha, on my system I
had to replace two instances of 'gmake' in the build script with 'make'. You
might not have to do that on your system.

Qt uses the native APIs to draw controls, so your apps look appropriate on
different platforms.

- Job

On Tue, Sep 1, 2009 at 12:43 AM, Bulat Ziganshin
bulat.zigans...@gmail.comwrote:

 Hello Job,

 Tuesday, September 1, 2009, 1:16:38 AM, you wrote:

  I recommend qtHaskell.

 how it's in areas of
 - memory deallocation when it's no more need - is it automatic or
 manual?
 - unicode support
 - compatibiliy with latest ghc versions - does it build by Cabal or we
 need to wait while gurus release installers for Windows?
 - does it use native GUI controls on Windows or draws them itself?

 i'm asking because those questions arise when using other libs


 --
 Best regards,
  Bulatmailto:bulat.zigans...@gmail.com


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] GUI library

2009-09-01 Thread Job Vranish
If you're already used to C++ Qt and PyQt, qtHaskell should be relatively
straightforward (though probably with a few gotchas).
You could download qtHaskell and look at the examples to get an idea for the
feel of it. If you're already used to Qt they should look familiar.

Subclassing _is_ done a little weird:

First you declare a dummy datatype:

data MyQPushButton = MyQPushButton

And then you use the qSubClass function:

myQPushButton :: String - IO (QPushButton MyQPushButton)
myQPushButton s = qSubClass $ qPushButton1 s

The type signature here is necessary. It's the only thing that forces the
new (QPushButton a) to be a QPushButton MyQPushButton.

Then you can use your subclassed buttons like so:

main :: IO ()
main = do
app - qApplication
dialog - qDialog
button1 - myQPushButton Click for Stuff
qObject_connectSlot1 button1 clicked() button1 click() $
on_pbutton_clicked dialog
mainLayout - qVBoxLayout
qLayout_addWidget mainLayout button1
qWidget_setLayout dialog mainLayout
qWidget_setWindowTitle dialog Stuff Test
ok - qDialog_exec dialog
return()

on_pbutton_clicked :: QDialog () - QPushButton MyQPushButton - IO ()
on_pbutton_clicked _dlg _this  = do
mb - qMessageBox1 _dlg
qMessageBox_setText mb $ Stuff
qWidget_show mb
return ()

Hmmm, though it doesn't look like you can currently overload methods of your
parent class, usually you don't need too though as you can just tie into a
signal (so you still can do things like paint). Though I'm kinda suprised I
didn't notice this before, I'll have to email the guy and see if this is
actually an issue.

Also, qtHaskell doesn't fully support all the Qt widgets (though it covers
most of them) but there is a new version coming out soon that should be more
complete.

Overall qtHaskell has served my perposes well.

There is also a good listing of GUI toolkits for Haskell at
http://www.haskell.org/haskellwiki/Applications_and_libraries/GUI_libraries

- Job

On Tue, Sep 1, 2009 at 1:49 AM, Michael Mossey m...@alumni.caltech.eduwrote:

 Thanks for the info. Interesting. I'm already familiar with C++ Qt and also
 PyQt. I am also a fan of Qt.

 However, as a beginner to Haskell, I want to be sure I don't get myself
 into trouble. I hope that qtHaskell is straightforward.

 Qt depends on deriving user classes. How is this handled in qtHaskell?

 Thanks,

 -Mike


 Job Vranish wrote:

 I recommend qtHaskell.
 I am a big fan of Qt in general. It has good documentation and extensive
 examples, is very well designed, and has a good license. I'd even say the
 C++ version is good choice for beginners (certainly easier to understand/use
 than say GTK).
 The qtHaskell bindings are also pretty good. The documentation and
 examples are not as extensive, but you can usually use the C++ documentation
 to fill in the gaps.
 Being already familiar with C++ Qt, using qtHaskell was a snap. However,
 if you're unfamiliar with both Qt and Haskell it will probably be confusing
 at first. Though I'd bet money the GTK bindings aren't any better in that
 regard.
 I'd still say you'd be more productive with qtHaskell in the long run.

 - Job


 On Sat, Aug 29, 2009 at 11:03 AM, Michael Mossey 
 m...@alumni.caltech.edumailto:
 m...@alumni.caltech.edu wrote:

I want to choose a GUI library for my project. Some background: I'm
a beginner to functional programming and have been working through
Haskell books for a few months now. I'm not just learning Haskell
for s**ts and giggles; my purpose is to write
music-composition-related code; in particular, I want to write a
graphical musical score editor. (Why write my own editor, you may
ask? Because I want to fully integrate it with
computer-assisted-composition algorithms that I plan to write, also
in Haskell.) I decided to use Haskell for its great features as a
functional programming language.

Regarding a choice of GUI library, I want these factors:

- it needs to provide at a minimum a drawing surface, a place I can
draw lines and insert characters, in addition to all the standard
widgets and layout capabilities we have to come to expect from a GUI
library.

- This is a Windows application.

- it needs to be non-confusing for an intermediate-beginner
Haskeller. Hopefully good documentation and examples will exist on
the web.

- It might be nice to have advanced graphics capability such as Qt
provides, things like antialiasied shapes, and a canvas with
efficient refresh (refereshes only the area that was exposed, and if
your canvas items are only primitives, it can do refreshes from
within C++ (no need to touch your Haskell code at all). However I'm
wondering if qtHaskell fits my criteria well-documented and lots
of examples aimed at beginners.

Thanks,
Mike
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org 

Re: [Haskell-cafe] Cleaning up stable names?

2009-09-01 Thread Job Vranish
Well usually, when I've used stable names, I've just used them to check if
things are the same, and then thrown them away. So no chance for a space
leak. It's usually unsafe to keep stable names around for very long as they
can lose their ability to tell if two things are the same (if this surprises
you, you should carefully reread
http://haskell.org/ghc/docs/latest/html/libraries/base/System-Mem-StableName.html#v%3AmakeStableName).

Out of curiosity, how are you planning on using them?

- Job

On Tue, Sep 1, 2009 at 3:40 AM, Peter Verswyvelen bugf...@gmail.com wrote:

 but without that function, stable names are not that useful I guess? they
 would cause a space leak?

 On Mon, Aug 31, 2009 at 10:59 PM, Job Vranish jvran...@gmail.com wrote:

 I also would like a isStableNameTargetAlive function.
 Though if you had such a function then you probably _could_ make a
 deRefStableName function, which, since there isn't one, probably means
 that such a function would be hard to make.

 - Job

 On Sun, Aug 30, 2009 at 4:54 PM, Peter Verswyvelen bugf...@gmail.comwrote:

 From the documentation, I don't think I grasp how stable names work.
 From the docs:
 There is no deRefStableName operation. You can't get back from a stable
 name to the original Haskell object. The reason for this is that the
 existence of a stable name for an object does not guarantee the existence of
 the object itself; it can still be garbage collected.

 From this I can conclude that stable names behave a bit like weak
 pointers.

 However, suppose I have a hash table of these stable names. How can I
 remove the redundant stable names from the table? I mean removing stable
 names that refer to an object that is garbage collected? I don't see any
 function for checking that (e.g. isStableNameTargetAlive or something)

 Thanks,
 Peter





 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe




___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Cleaning up stable names?

2009-09-01 Thread Peter Verswyvelen
I was planning to use them for caching OpenGL display lists and render
targets. These are generated from a pure scene graph description, and
if the same description is handed over to the render engine, it would
just reuse the previously cached OpenGL object.  I can of course just
embedding and IORef inside the pure structures, that would also work I
guess




On Tue, Sep 1, 2009 at 6:09 PM, Job Vranishjvran...@gmail.com wrote:
 Well usually, when I've used stable names, I've just used them to check if
 things are the same, and then thrown them away. So no chance for a space
 leak. It's usually unsafe to keep stable names around for very long as they
 can lose their ability to tell if two things are the same (if this surprises
 you, you should carefully reread
 http://haskell.org/ghc/docs/latest/html/libraries/base/System-Mem-StableName.html#v%3AmakeStableName
 ).

 Out of curiosity, how are you planning on using them?


 - Job

 On Tue, Sep 1, 2009 at 3:40 AM, Peter Verswyvelen bugf...@gmail.com wrote:

 but without that function, stable names are not that useful I guess? they
 would cause a space leak?
 On Mon, Aug 31, 2009 at 10:59 PM, Job Vranish jvran...@gmail.com wrote:

 I also would like a isStableNameTargetAlive function.
 Though if you had such a function then you probably _could_ make a
 deRefStableName function, which, since there isn't one, probably means that
 such a function would be hard to make.

 - Job

 On Sun, Aug 30, 2009 at 4:54 PM, Peter Verswyvelen bugf...@gmail.com
 wrote:

 From the documentation, I don't think I grasp how stable names work.
 From the docs:
 There is no deRefStableName operation. You can't get back from a stable
 name to the original Haskell object. The reason for this is that the
 existence of a stable name for an object does not guarantee the existence 
 of
 the object itself; it can still be garbage collected.
 From this I can conclude that stable names behave a bit like weak
 pointers.
 However, suppose I have a hash table of these stable names. How can I
 remove the redundant stable names from the table? I mean removing stable
 names that refer to an object that is garbage collected? I don't see any
 function for checking that (e.g. isStableNameTargetAlive or something)
 Thanks,
 Peter




 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe





___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Can't get my head round monad transformers

2009-09-01 Thread Colin Adams
I'm trying to add a state monad onto the IO monad for use in a
happstack application. I thought this should involve using StateT and
Happstack.Server.SimpleHTTP.simpleHTTP', but I can't figure out how to
plumb it all together. Any tips will be welcome.

-- 
Colin Adams
Preston,
Lancashire,
ENGLAND
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Slow IO?

2009-09-01 Thread Jason Dusek
2009/08/31 Don Stewart d...@galois.com:
 If you can abstract out a common function for lexing ints out of
 bytestrings, we could add it to the bytestring-lexing package.

  All the really performant implementations operate on strings
  with multiple ints in them; I suspect this reduces memory
  traffic -- and indeed, Eugene's code using my libs allocates
  about twice as much memory as Don's code.

  I've tried a few different things with strictness annotations
  to no avail.

  I'm having some trouble understanding the meaning of entries
  in the profiler's output. I have a file with 5 million random
  integers in it, totalling 26210408 bytes (21210408 bytes of
  which are not newlines). The relevant part is here:

COST CENTRE  MODULE entries

MAIN MAIN 0
 mainMain 1
  bint   Main   501
   lazy_int  Data.ByteString.Nums.Careless.Int 41211385
digitize Data.ByteString.Nums.Careless.Int 21210408

  The number of entries to `lazy_int` is puzzling. Eugene's
  `bint` is called for each line of the file -- once for the
  header and then 5 million times for each of the integers.
  (There are two numbers on the first line but Eugene's program
  only uses `k` so `bint` is only actually entered once.)
  However, `bint` just calls my `int` and `int` calls `lazy_int`
  so why are there 41 million plus entries of `lazy_int`?

--
Jason Dusek


spoj-eugene-prof-opt-bang-acc-scc-dfold.prof
Description: Binary data
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Can't get my head round monad transformers

2009-09-01 Thread Peter Verswyvelen
Maybe the chapter on monad transformers in RWH can help?

http://book.realworldhaskell.org/read/monad-transformers.html



On Tue, Sep 1, 2009 at 7:34 PM, Colin
Adamscolinpaulad...@googlemail.com wrote:
 I'm trying to add a state monad onto the IO monad for use in a
 happstack application. I thought this should involve using StateT and
 Happstack.Server.SimpleHTTP.simpleHTTP', but I can't figure out how to
 plumb it all together. Any tips will be welcome.

 --
 Colin Adams
 Preston,
 Lancashire,
 ENGLAND
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Cleaning up stable names?

2009-09-01 Thread Luke Palmer
Have you considered computing a hash of the scene graph description
(compositionally)?  This gives you all the same advantages, including
re-using shared subparts of the graph (which would be unlikely to stay
around for very long as stable names).

Luke

On Tue, Sep 1, 2009 at 11:02 AM, Peter Verswyvelenbugf...@gmail.com wrote:
 I was planning to use them for caching OpenGL display lists and render
 targets. These are generated from a pure scene graph description, and
 if the same description is handed over to the render engine, it would
 just reuse the previously cached OpenGL object.  I can of course just
 embedding and IORef inside the pure structures, that would also work I
 guess




 On Tue, Sep 1, 2009 at 6:09 PM, Job Vranishjvran...@gmail.com wrote:
 Well usually, when I've used stable names, I've just used them to check if
 things are the same, and then thrown them away. So no chance for a space
 leak. It's usually unsafe to keep stable names around for very long as they
 can lose their ability to tell if two things are the same (if this surprises
 you, you should carefully reread
 http://haskell.org/ghc/docs/latest/html/libraries/base/System-Mem-StableName.html#v%3AmakeStableName
 ).

 Out of curiosity, how are you planning on using them?


 - Job

 On Tue, Sep 1, 2009 at 3:40 AM, Peter Verswyvelen bugf...@gmail.com wrote:

 but without that function, stable names are not that useful I guess? they
 would cause a space leak?
 On Mon, Aug 31, 2009 at 10:59 PM, Job Vranish jvran...@gmail.com wrote:

 I also would like a isStableNameTargetAlive function.
 Though if you had such a function then you probably _could_ make a
 deRefStableName function, which, since there isn't one, probably means that
 such a function would be hard to make.

 - Job

 On Sun, Aug 30, 2009 at 4:54 PM, Peter Verswyvelen bugf...@gmail.com
 wrote:

 From the documentation, I don't think I grasp how stable names work.
 From the docs:
 There is no deRefStableName operation. You can't get back from a stable
 name to the original Haskell object. The reason for this is that the
 existence of a stable name for an object does not guarantee the existence 
 of
 the object itself; it can still be garbage collected.
 From this I can conclude that stable names behave a bit like weak
 pointers.
 However, suppose I have a hash table of these stable names. How can I
 remove the redundant stable names from the table? I mean removing stable
 names that refer to an object that is garbage collected? I don't see any
 function for checking that (e.g. isStableNameTargetAlive or something)
 Thanks,
 Peter




 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe





 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Cleaning up stable names?

2009-09-01 Thread Peter Verswyvelen
Yes that is possible too. But it feels obvious to first lookup by
stable name. I had no idea stable names were so volatile. They should
be called unstable names then :-)

In .NET it is possible to assign an identifier to an object, and that
identifier will always be the same for the same object, no matter
where to garbage collectors moves the object in memory. For Haskell,
at first sight it would feel natural to have something like that too.

On Tue, Sep 1, 2009 at 8:31 PM, Luke Palmerlrpal...@gmail.com wrote:
 Have you considered computing a hash of the scene graph description
 (compositionally)?  This gives you all the same advantages, including
 re-using shared subparts of the graph (which would be unlikely to stay
 around for very long as stable names).

 Luke

 On Tue, Sep 1, 2009 at 11:02 AM, Peter Verswyvelenbugf...@gmail.com wrote:
 I was planning to use them for caching OpenGL display lists and render
 targets. These are generated from a pure scene graph description, and
 if the same description is handed over to the render engine, it would
 just reuse the previously cached OpenGL object.  I can of course just
 embedding and IORef inside the pure structures, that would also work I
 guess




 On Tue, Sep 1, 2009 at 6:09 PM, Job Vranishjvran...@gmail.com wrote:
 Well usually, when I've used stable names, I've just used them to check if
 things are the same, and then thrown them away. So no chance for a space
 leak. It's usually unsafe to keep stable names around for very long as they
 can lose their ability to tell if two things are the same (if this surprises
 you, you should carefully reread
 http://haskell.org/ghc/docs/latest/html/libraries/base/System-Mem-StableName.html#v%3AmakeStableName
 ).

 Out of curiosity, how are you planning on using them?


 - Job

 On Tue, Sep 1, 2009 at 3:40 AM, Peter Verswyvelen bugf...@gmail.com wrote:

 but without that function, stable names are not that useful I guess? they
 would cause a space leak?
 On Mon, Aug 31, 2009 at 10:59 PM, Job Vranish jvran...@gmail.com wrote:

 I also would like a isStableNameTargetAlive function.
 Though if you had such a function then you probably _could_ make a
 deRefStableName function, which, since there isn't one, probably means 
 that
 such a function would be hard to make.

 - Job

 On Sun, Aug 30, 2009 at 4:54 PM, Peter Verswyvelen bugf...@gmail.com
 wrote:

 From the documentation, I don't think I grasp how stable names work.
 From the docs:
 There is no deRefStableName operation. You can't get back from a stable
 name to the original Haskell object. The reason for this is that the
 existence of a stable name for an object does not guarantee the 
 existence of
 the object itself; it can still be garbage collected.
 From this I can conclude that stable names behave a bit like weak
 pointers.
 However, suppose I have a hash table of these stable names. How can I
 remove the redundant stable names from the table? I mean removing stable
 names that refer to an object that is garbage collected? I don't see any
 function for checking that (e.g. isStableNameTargetAlive or something)
 Thanks,
 Peter




 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe





 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Question about Lazy.IO

2009-09-01 Thread Jason Dusek
2009/09/01 Luke Palmer lrpal...@gmail.com:
 I have now tried twice to explain why this is possible more
 deeply in terms of domain theory, but it has bloated the
 message to three times this size.  If you would like me to
 include my response, I'd be more than happy to, but it does
 get rather technical.

  I'm sure I'm not alone when I say I'd like to see the longer,
  more technical response.

--
Jason Dusek
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Slow IO?

2009-09-01 Thread Jason Dusek
  I've uploaded a new version of bytestring-nums that, while
  still slower than the fast/custom codes, allows Eugene's
  earlier program to a little more than 20% faster than it did
  before. It no longer handles spurious characters in the input
  by skipping over them (this is probably not a common
  requirement, anyways).

http://hackage.haskell.org/package/bytestring-nums-0.3.0

  I suspect that splitting the string into pieces and then
  mapping the parser over the pieces will never be faster than
  an all-in-one parser/tester/incrementer like the fast programs
  have.

--
Jason Dusek
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Cleaning up stable names?

2009-09-01 Thread Brandon S. Allbery KF8NH

On Sep 1, 2009, at 14:57 , Peter Verswyvelen wrote:

In .NET it is possible to assign an identifier to an object, and that
identifier will always be the same for the same object, no matter
where to garbage collectors moves the object in memory. For Haskell,
at first sight it would feel natural to have something like that too.



Hm. I'd think such names would have to live in a monad (which then  
leads you to either Reader or ST, I think).


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] How to understand the 'forall' ?

2009-09-01 Thread zaxis

data Branch tok st a = forall b. Branch (PermParser tok st (b - a))
(GenParser tok st b)

please shed a light on me, thanks!
-- 
View this message in context: 
http://www.nabble.com/How-to-understand-the-%27forall%27---tp25250783p25250783.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Question about Lazy.IO

2009-09-01 Thread Diego Souza
   I'm sure I'm not alone when I say I'd like to see the longer,
   more technical response.

No, you aren't. Please `flood in' :-)

-- 
~dsouza
yahoo!im: paravinicius
gpg key fingerprint: 71B8 CE21 3A6E F894 5B1B  9ECE F88E 067F E891 651E
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Snow Leopard Breaks GHC

2009-09-01 Thread Tom Tobin
On Tue, Sep 1, 2009 at 3:14 AM, Christian
Maederchristian.mae...@dfki.de wrote:

 It seems, bootstrapping cabal went wrong. Does
 http://hackage.haskell.org/platform/2009.2.0.2/haskell-platform-2009.2.0.2-i386.dmg
 work?

Installing the Haskell Platform package, combined with adding the
previously mentioned options to /usr/bin/ghc (-optc-m32 -opta-m32
-optl-m32), seems to have done the trick.  Thank you!
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to understand the 'forall' ?

2009-09-01 Thread Eugene Kirpichov
This means that for any type 'b' you can construct a value of type
'Branch tok st a' by passing to Branch an argument of type
'(PermParser tok st (b - a))' and 'GenParser tok st b'.
This also means that when you're given a value of type Branch tok st
a, you don't know what that 'b' type was; the only thing you know is
that the 'b' in 'b - a' in the first argument of Branch is the same
as the 'b' in 'GenParser tok st b'.

See also: the haskellwiki page on existential types.

2009/9/2 zaxis z_a...@163.com:

 data Branch tok st a = forall b. Branch (PermParser tok st (b - a))
 (GenParser tok st b)

 please shed a light on me, thanks!
 --
 View this message in context: 
 http://www.nabble.com/How-to-understand-the-%27forall%27---tp25250783p25250783.html
 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe




-- 
Eugene Kirpichov
Web IR developer, market.yandex.ru
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Slow IO?

2009-09-01 Thread Steve
On Tue, 2009-09-01 at 08:45 +0400, Eugene Kirpichov wrote:
 Hm, on my machine Don's code has exactly the same performance my code above.
That's strange.

 Also, replacing the 'test' and 'parse' functions with this one
 
 add :: Int - Int - S.ByteString - Int
 add k i s = fst $ S.foldl' f (i, 0) s
   where f (!i, !n) '\n' | n`divisibleBy`k = (i+1, 0)
 | otherwise   = (i,   0)
 f (!i, !n) w  = (i, 10*n+ord w-ord '0')
 
 increases performance by another 15% (0.675s vs 0.790s)

On my system I get a 50% slowdown using this add function!

I guess is just shows that benchmarking code on one single
CPU/memory/OS/ghc combination does not give results that apply widely.
I'm using:
AMD Athlon X2 4800
2GB memory
Linux (Fedora 11, 64-bit version)
ghc 6.10.3

Steve

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Slow IO?

2009-09-01 Thread Eugene Kirpichov
2009/9/2 Steve stevech1...@yahoo.com.au:
 On Tue, 2009-09-01 at 08:45 +0400, Eugene Kirpichov wrote:
 Hm, on my machine Don's code has exactly the same performance my code above.
 That's strange.

 Also, replacing the 'test' and 'parse' functions with this one

 add :: Int - Int - S.ByteString - Int
 add k i s = fst $ S.foldl' f (i, 0) s
   where f (!i, !n) '\n' | n`divisibleBy`k = (i+1, 0)
                         | otherwise       = (i,   0)
         f (!i, !n) w  = (i, 10*n+ord w-ord '0')

 increases performance by another 15% (0.675s vs 0.790s)

 On my system I get a 50% slowdown using this add function!

 I guess is just shows that benchmarking code on one single
 CPU/memory/OS/ghc combination does not give results that apply widely.
 I'm using:
 AMD Athlon X2 4800
 2GB memory
 Linux (Fedora 11, 64-bit version)
 ghc 6.10.3


I've got a Centrino Duo 2000 (I'm on a notebook), Ubuntu 9.04 and ghc 6.10.2.

However, we have not set up on what exact input file we're using :)
I'm using one where it is written 1000 3 and then 1000 lines
of 9 follow.

Also, I wonder what one'd get if one compiled this program with jhc,
but I don't know whether jhc is able to compile Data.ByteString.

 Steve





-- 
Eugene Kirpichov
Web IR developer, market.yandex.ru
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Slow IO?

2009-09-01 Thread Steve
On Wed, 2009-09-02 at 11:55 +0800, Steve wrote:
 On Tue, 2009-09-01 at 08:45 +0400, Eugene Kirpichov wrote:
  Hm, on my machine Don's code has exactly the same performance my code above.
 That's strange.
 
  Also, replacing the 'test' and 'parse' functions with this one
  
  add :: Int - Int - S.ByteString - Int
  add k i s = fst $ S.foldl' f (i, 0) s
where f (!i, !n) '\n' | n`divisibleBy`k = (i+1, 0)
  | otherwise   = (i,   0)
  f (!i, !n) w  = (i, 10*n+ord w-ord '0')
  
  increases performance by another 15% (0.675s vs 0.790s)
 
 On my system I get a 50% slowdown using this add function!
 
 I guess is just shows that benchmarking code on one single
 CPU/memory/OS/ghc combination does not give results that apply widely.
 I'm using:
 AMD Athlon X2 4800
 2GB memory
 Linux (Fedora 11, 64-bit version)
 ghc 6.10.3

I should have also said that the test method and test data is important
too.

This is what I have been using:
$ time ./0450  0450.input.data
and looking at the 'real' value.

The file 0450.input.data is generated with a Python script:
#!/usr/bin/env python
'''
generate a data file for problem 0450
'''

from __future__ import division# new in 2.2, redundant in 3.0
from __future__ import absolute_import # new in 2.5, redundant in
2.7/3.0
from __future__ import print_function  # new in 2.6, redundant in 3.0

import io
import random

inFile = '0450.input.data'
#n, k, tiMax = 10**6, 3, 10**9
n, k, tiMax = 10**7, 3, 10**9

with io.open(inFile, 'wb') as f:
  f.write('%d %d\n' % (n, k))
  for i in xrange(n):
ti = random.randint(1, tiMax)
f.write('%d\n' % (ti,))


Steve

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Slow IO?

2009-09-01 Thread Mark Wotton


On 02/09/2009, at 2:26 PM, Eugene Kirpichov wrote:





I've got a Centrino Duo 2000 (I'm on a notebook), Ubuntu 9.04 and  
ghc 6.10.2.


However, we have not set up on what exact input file we're using :)
I'm using one where it is written 1000 3 and then 1000 lines
of 9 follow.

Also, I wonder what one'd get if one compiled this program with jhc,
but I don't know whether jhc is able to compile Data.ByteString.


It couldn't last time I tried - choked on some INLINE pragmas. Might  
not be a massive job, but there aren't enough hours in the day...


mark
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to understand the 'forall' ?

2009-09-01 Thread zaxis

Isnot it clear without the 'forall' ?
data Branch tok st a = Branch (PermParser tok st (b - a)) (GenParser tok st
b)

thanks!


jkff wrote:
 
 This means that for any type 'b' you can construct a value of type
 'Branch tok st a' by passing to Branch an argument of type
 '(PermParser tok st (b - a))' and 'GenParser tok st b'.
 This also means that when you're given a value of type Branch tok st
 a, you don't know what that 'b' type was; the only thing you know is
 that the 'b' in 'b - a' in the first argument of Branch is the same
 as the 'b' in 'GenParser tok st b'.
 
 See also: the haskellwiki page on existential types.
 
 2009/9/2 zaxis z_a...@163.com:

 data Branch tok st a = forall b. Branch (PermParser tok st (b - a))
 (GenParser tok st b)

 please shed a light on me, thanks!
 --
 View this message in context:
 http://www.nabble.com/How-to-understand-the-%27forall%27---tp25250783p25250783.html
 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

 
 
 
 -- 
 Eugene Kirpichov
 Web IR developer, market.yandex.ru
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 

-- 
View this message in context: 
http://www.nabble.com/How-to-understand-the-%27forall%27---tp25250783p25251783.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to understand the 'forall' ?

2009-09-01 Thread Ryan Ingram
You can also look at it in terms of the deconstruction operation on
this data type.

For example, lists:

 data List a = Nil | Cons a (List a)

 case_list :: r - (a - List a - r) - List a - r
 case_list nil_case cons_case Nil = nil_case
 case_list nil_case cons_case (Cons x xs) = cons_case x xs

Now, given the Branch type:

 data Branch tok st a = forall b. Branch (PermParser tok st (b - a)) 
 (GenParser tok st b)

what is the type of its case construct?  Here's the answer:

 case_branch :: (forall b. PermParser tok st (b - a) - GenParser tok st b - 
 r) - Branch tok st a - r
 case_branch k (Branch pparser gparser) = k pparser gparser

Notice the higher-rank type on the argument k; it has to be able to
accept *any* type b, because the constructor hid an object of *some*
type which is no longer known.  So unless you can accept *any* b, you
can't operate on this object.

  -- ryan
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to understand the 'forall' ?

2009-09-01 Thread Eugene Kirpichov
2009/9/2 zaxis z_a...@163.com:

 Isnot it clear without the 'forall' ?
 data Branch tok st a = Branch (PermParser tok st (b - a)) (GenParser tok st
 b)

 thanks!


The situation is not so simple.
Consider, for example, a procedure that takes as input a *generic*
sorting algorithm:

sortThem :: (forall a. Ord a = [a] - [a]) - [Int] - [String] -
([Int], [String])
sortThem sortAlgo ints strings = (sortAlgo ints, sortAlgo strings)

Here you can't omit the 'forall' because if you do, then inside the
body of the sortThem function the 'a' type variable has a fixed value
and can't be both Int and String!

This is a somewhat esoteric example, but one could consider, for
instance, a procedure that takes as input some trees of different
types and a generic tree traversal algorithm. Well, have a look at the
haskellwiki page, there's a pile of examples :)

P.S. I tried to write up the difference between datatype and function
declarations in this respect, but my explanations turned into a mess,
so I erased them in the hope that someone will explain it better than
me.


 jkff wrote:

 This means that for any type 'b' you can construct a value of type
 'Branch tok st a' by passing to Branch an argument of type
 '(PermParser tok st (b - a))' and 'GenParser tok st b'.
 This also means that when you're given a value of type Branch tok st
 a, you don't know what that 'b' type was; the only thing you know is
 that the 'b' in 'b - a' in the first argument of Branch is the same
 as the 'b' in 'GenParser tok st b'.

 See also: the haskellwiki page on existential types.

 2009/9/2 zaxis z_a...@163.com:

 data Branch tok st a = forall b. Branch (PermParser tok st (b - a))
 (GenParser tok st b)

 please shed a light on me, thanks!
 --
 View this message in context:
 http://www.nabble.com/How-to-understand-the-%27forall%27---tp25250783p25250783.html
 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe




 --
 Eugene Kirpichov
 Web IR developer, market.yandex.ru
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe



 --
 View this message in context: 
 http://www.nabble.com/How-to-understand-the-%27forall%27---tp25250783p25251783.html
 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe




-- 
Eugene Kirpichov
Web IR developer, market.yandex.ru
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe