Re: [Haskell-cafe] Yampa vs. Reactive

2008-12-22 Thread Thomas Davie


On 21 Dec 2008, at 13:10, Henrik Nilsson wrote:


Hi Tom,

 In reactive, one doesn't.  All behaviors and events have the same
 absolute 0 value for time.

Right. I believe the possibility of starting behaviors later
is quite important.

And from what Conal wrote in a related mail, I take it that this
is recognized, and that this capability is something that is
being considered for reactive?


Yep, it is indeed.

Thanks for this series of emails by the way.  It's helped clarify in  
my head exactly what problems Yampa solved, and exactly which of them  
Reactive does or doesn't solve.


Thanks

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


RE: [Haskell-cafe] Trouble with FFI on Windows2000...

2008-12-22 Thread Serge LE HUITOUZE
Hi Kyra (I tried to email you directly, but, for some reason, my mail 
bounced...),
Hi Haskellers,


  dlltool -d cproj1.def -l libcproj1.a
  ghc --make testFFI_2.hs -optl-lcproj1 -optl-L.
  [...]
  This leads to an error box with message:
  DLL (null) not found on specified path
 
 dlltool -d cproj1.def -l libcproj1.a -D cproj1.dll

Thanks very much for this answer, short and effective (an ideal one)!

Just an additional question, just for curiosity:

Does anyone know why this -D option doesn't appear in the following two pages?
 - 
http://www.haskell.org/haskellwiki/GHC/Using_the_FFI#Setting_up_your_build_environment_.28Visual_Studio_Specific.29
 - http://www.haskell.org/haskellwiki/GHC:FAQ#GHC_on_Windows (parag. 1.4.3.4)

Is this because the behavior I got is Win2K specific (hence very few people run 
into in 2008)?


Thanks again Kyra for your precious help.

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


[Haskell-cafe] Re: Time for a new logo?

2008-12-22 Thread Benjamin L . Russell
On Sun, 14 Dec 2008 16:50:11 -0500, sam lee skyn...@gmail.com
wrote:

http://i35.tinypic.com/mjon83.png
used this: http://www.simwebsol.com/ImageTool/Default.aspx

This logo still has not been uploaded to the Haskell logos/New logo
ideas (http://haskell.org/haskellwiki/Haskell_logos/New_logo_ideas)
page.

Could you please upload it before it is forgotten?

-- Benjamin L. Russell
-- 
Benjamin L. Russell  /   DekuDekuplex at Yahoo dot com
http://dekudekuplex.wordpress.com/
Translator/Interpreter / Mobile:  +011 81 80-3603-6725
Furuike ya, kawazu tobikomu mizu no oto. 
-- Matsuo Basho^ 

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


RE: [Haskell-cafe] Can I build and install GHC 6.10.1 without previous installed ghc

2008-12-22 Thread Duncan Coutts
On Mon, 2008-12-22 at 11:53 +0800, Wang, Chunye (NSN - CN/Beijing)
wrote:
 
 I tried to install the ghc 6.8.0 last year but failed for some
 reason. Now I decide to do it again, because I'd like to try
 some examples in Real World Haskell Now I remember why I try to
 install it from source code, because the binary version has the
 following problem.

 I guess ``timer_create '' is failed because of library confliction.

I suggest you use the binary for ghc-6.8.2 (not 6.8.3) or earlier
because those were built on an old Red Hat 9 server and are thus
compatible with older versions of glibc and the Linux kernel.

If you really need ghc-6.10 (you probably do not if you're just trying
examples from the Real World Haskell book) then you can build ghc-6.10.x
from source once you have the ghc-6.8.2 binary installed.

Duncan

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


Re: [Haskell-cafe] Removing/Uninstalling cabal packages ?

2008-12-22 Thread Duncan Coutts
On Sun, 2008-12-21 at 13:30 -0600, brian wrote:
 On Sun, Dec 21, 2008 at 12:12 PM, Laurent Giroud m...@niaow.com wrote:
  I have been doing a few experiments with cabal packages lately and I wish to
  uninstall these to return to a cleaner package base. However, there doesn't
  seem to be a cabal uninstall command and reading the documentation at
  http://www.haskell.org/ghc/docs/latest/html/Cabal/index.html does not tell
  much about how to do that manually.
 
 I think you want 'ghc-pkg list' and 'ghc-pkg unregister'.

If you also want to remove the files then that also has to be done
manually at the moment.

If any volunteers would like to help us implement tracking of installed
files that would be most welcome.

Duncan

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


RE: [Haskell-cafe] Can I build and install GHC 6.10.1 withoutprevious installed ghc

2008-12-22 Thread Wang, Chunye (NSN - CN/Beijing)
Hi Duncan,


wget
http://haskell.org/ghc/dist/6.8.2/ghc-6.8.2-x86_64-unknown-linux.tar.bz2
tar -jxvf ghc-6.8.2-x86_64-unknown-linux.tar.bz2 
cd ghc-6.8.2
./configure 

checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
Which we'll further canonicalise into: x86_64-unknown-linux
checking for path to top of build tree... pwd: timer_create: Invalid
argument
configure: error: cannot determine current directory

Even though I can fixed this by ``cp /bin/pwd utils/pwd/pwd'' , there is
still similar error

``ghc-pkg.bin: timer_create: Invalid argument''

I guess any executable file generates same error message.


Best Regards
Chunye Wang chunye.w...@nsn.com


-Original Message-
From: ext Duncan Coutts [mailto:duncan.cou...@worc.ox.ac.uk] 
Sent: Monday, December 22, 2008 5:38 PM
To: Wang, Chunye (NSN - CN/Beijing)
Cc: Haskell-Cafe@haskell.org
Subject: RE: [Haskell-cafe] Can I build and install GHC 6.10.1
withoutprevious installed ghc

On Mon, 2008-12-22 at 11:53 +0800, Wang, Chunye (NSN - CN/Beijing)
wrote:
 
 I tried to install the ghc 6.8.0 last year but failed for some reason.

 Now I decide to do it again, because I'd like to try some examples in 
 Real World Haskell Now I remember why I try to install it from 
 source code, because the binary version has the following problem.

 I guess ``timer_create '' is failed because of library confliction.

I suggest you use the binary for ghc-6.8.2 (not 6.8.3) or earlier
because those were built on an old Red Hat 9 server and are thus
compatible with older versions of glibc and the Linux kernel.

If you really need ghc-6.10 (you probably do not if you're just trying
examples from the Real World Haskell book) then you can build ghc-6.10.x
from source once you have the ghc-6.8.2 binary installed.

Duncan

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


Re[2]: [Haskell-cafe] Trouble with the ST monad

2008-12-22 Thread Bulat Ziganshin
Hello Andre,

Monday, December 22, 2008, 4:44:34 AM, you wrote:

 Is there any difference between using freeze/thaw from Data.Array.MArray
 versus freezeSTArray/thawSTArray from GHC.Arr?

portability, at least


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

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


Re[2]: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Bulat Ziganshin
Hello Günther,

Monday, December 22, 2008, 1:57:22 AM, you wrote:

try -threaded, +RTS -N2, and forkOS simultaneously. it may work - i
don't see reasons why other threads should be freezd why one does
unsafe call

nother solution is to compile library with unsafe call changed to
safe. this change is always safe but make call ~10mcs slower :)


 Hi Mads,

 I just noticed that too.

 I had been wondering why this problem does not occur with the sample app
  from RWH eventhough I was employing the same technics as they did.

 It just occured to me that all the DB interactions in their app are fairly
 short and thus the problem never becomes apparent.

 Thanks everyone, I was going crazy here, couldn't figure out what I was
 doing wrong.

 Would anyone happen to know of a safe alternative to HDBC?

 Günther


 Am 21.12.2008, 23:39 Uhr, schrieb Mads Lindstrøm  
 mads_lindstr...@yahoo.dk:

 Hi Günther,

 Hi Mads,

 I'm using HDBC with sqlite3

 Looking at
 http://software.complete.org/software/repositories/entry/hdbc-sqlite3/Database/HDBC/Sqlite3/Connection.hs
   
 and  
 http://software.complete.org/software/repositories/entry/hdbc-sqlite3/Database/HDBC/Sqlite3/Statement.hsc
   
 you can see that HDBC-sqlite's foreign calls are indeed marked unsafe.

 /Mads


 Günther

 ___
 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


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

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


[Haskell-cafe] Re: [Haskell] ANN: HLint 1.0

2008-12-22 Thread Neil Mitchell
Hi Lennart,

 It would be nice if HLint didn't suggest things that it will object to
 in the next round.
 Like

 LLVM/Core/CodeGen.hs:176:1: Eta reduce
 Found:
  applyArgs f g = apArgs 0 f g
 Why not:
  applyArgs f = apArgs 0 f

The idea is to specify things one step at a time, so the user learns
from the hints, as well as fixing them. However, in the case of eta
reduction, doing several reductions at a time does make sense. I'll
add it to the todo  list.

Thanks

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


Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Malcolm Wallace
Don Stewart d...@galois.com wrote:

 Modify the 'unsafe' inports to be 'safe'? I don't think HDBC is going
 to call back in, so should be fine. John?

For those who are puzzled, Don is suggesting that
foreign import ccall unsafe foo :: Bar - Baz
should simply be changed to
foreign import ccall safe foo :: Bar - Baz

And in case anyone is wondering whether fiddling with safety
declarations is entirely wise:

   unsafe means I, the programmer, guarantee that this foreign function
   cannot call back into Haskell land, so you, the compiler, are free to
   do unsafe things when implementing the call.

   safe means I the programmer, cannot guarantee that this foreign
   function is safe, so please, you the compiler, make sure that you add
   extra checks and assurances to ensure that the call really will be
   safe in case it calls back into Haskell land.

The terminology seems counter-intuitive, but in other other words, a
safe call is slower but more flexible, an unsafe call is fast and
dangerous.  Therefore it is always OK to convert an unsafe declaration
into a safe one, but never OK to convert from safe to unsafe
without looking at what the foreign side actually does.

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


[Haskell-cafe] new Haskell logos/Logo design tools - HaskellWiki page [Was: Re: Time for a new logo?]

2008-12-22 Thread Benjamin L . Russell
In order to encourage participation in The Great 2009 Haskell Logo
Contest, I have created a new Haskell logos/Logo design tools -
HaskellWiki page (see
http://haskell.org/haskellwiki/Haskell_logos/Logo_design_tools).

This page is still a stub; if you have any further information on logo
design tools or logo design-related resource sites, including design
advice, please feel free to add to it.

The more participation, the better!

-- Benjamin L. Russell
-- 
Benjamin L. Russell  /   DekuDekuplex at Yahoo dot com
http://dekudekuplex.wordpress.com/
Translator/Interpreter / Mobile:  +011 81 80-3603-6725
Furuike ya, kawazu tobikomu mizu no oto. 
-- Matsuo Basho^ 

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


Re: [Haskell-cafe] understanding enumerator/iteratee

2008-12-22 Thread Jason Dusek
  So an iteratee is not like a cursor because it does not own
  the collection -- it just tells us how to step it. The
  enumerator owns the collection and provides a way to scope
  resource use?

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


Re: [Haskell-cafe] understanding enumerator/iteratee

2008-12-22 Thread Artyom Shalkhakov
Hi Jason!

2008/12/22 Jason Dusek jason.du...@gmail.com:
  So an iteratee is not like a cursor because it does not own
  the collection -- it just tells us how to step it. The
  enumerator owns the collection and provides a way to scope
  resource use?

Iteratee does not know anything about resources,
it doesn't need to. It is just a function which, given an input
stream (which is either EOF, block of data or an IO error string),
decides what to do, one of:
* yield with some (useful) results (and with the rest of the input)
* request more input by returning a continuation

The enumerator on the other hand, decides when to open the
resource (a file, for example), when to close it, and how to step
through it. Iteratee only gets the fruits of this hard work. :)

 it just tells us how to step it

I would say that it just tells us how to react to various forms of
input. :) This is much like the function you pass to foldr.

I hope this clarifies iteratees a bit (and that my understanding
is correct).

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


RE: [Haskell-cafe] Can I build and install GHC 6.10.1 withoutprevious installed ghc

2008-12-22 Thread Duncan Coutts
On Mon, 2008-12-22 at 17:53 +0800, Wang, Chunye (NSN - CN/Beijing)
wrote:
 Hi Duncan,
 
 
 wget
 http://haskell.org/ghc/dist/6.8.2/ghc-6.8.2-x86_64-unknown-linux.tar.bz2
 tar -jxvf ghc-6.8.2-x86_64-unknown-linux.tar.bz2 

Ahh, x86-64. Those have always been built on Fedora Core 5.

My only suggestion is to try older ones, eg 6.6.1. That version should
still be able to built 6.10.1 from source and should still be usable for
the RWH book.

Duncan

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


Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Duncan Coutts
On Mon, 2008-12-22 at 10:30 +, Malcolm Wallace wrote:

 For those who are puzzled, Don is suggesting that
 foreign import ccall unsafe foo :: Bar - Baz
 should simply be changed to
 foreign import ccall safe foo :: Bar - Baz
 
 And in case anyone is wondering whether fiddling with safety
 declarations is entirely wise:
 
unsafe means I, the programmer, guarantee that this foreign function
cannot call back into Haskell land, so you, the compiler, are free to
do unsafe things when implementing the call.
 
safe means I the programmer, cannot guarantee that this foreign
function is safe, so please, you the compiler, make sure that you add
extra checks and assurances to ensure that the call really will be
safe in case it calls back into Haskell land.
 
 The terminology seems counter-intuitive, but in other other words, a
 safe call is slower but more flexible, an unsafe call is fast and
 dangerous.  Therefore it is always OK to convert an unsafe declaration
 into a safe one, but never OK to convert from safe to unsafe
 without looking at what the foreign side actually does.

And in general we would not even bother with considering using unsafe
for calls that are already expensive. It's only worth considering when
the length of the call is always very short.

For example in a database library it might make sense to use 'unsafe' on
the data-access functions that extract data from a local query result
but we should always use 'safe' on any DB function that might want to
talk to the network (eg to get more query results).

Duncan

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


Re: [Haskell-cafe] A hell of a question

2008-12-22 Thread Luke Palmer
On Sun, Dec 21, 2008 at 6:03 PM, Andrzej Jaworski hims...@poczta.nom.plwrote:

 I just want to say Hello to let you know that there are some serious
 entities watching you besides
 monads and FBI:-)

 There has been a hell of a discussion recently about logos, languages and
 religion and I want to add
 to this.

 First let me disassociate Haskell from Taoism which to may taste has left
 us in an unhealthy climate.
 It suffices to say that Taoism is a school of clever trics and cute
 aphorisms but without the
 slightest attempt to explain or generalize let alone produce an abstract
 idea or a system. That is
 why its wisdom is non transferable in spite of majority of humans desending
 from it. Haskell on the
 contrary is a minority school that implements abstract ideas for problem
 solving in the most
 transferable way to date, so that other languages look into it for their
 share. But don't worry,
 thay will choke becouse it is them who practice Taoizm. Playing too many
 tricks will eventually
 trick them, even if some are powerful enough to brainwash dicent professors
 to preach
 interoperability or the like. Every viable complexity needs a single
 underlying concept to survive,
 including you and the universe. Microsoft and the like excluding;-)
 Haskell has all that: consistency, transparency and self-contained concept.


I associate Haskell with Zen, due to one of my favorite dialogues: If it's
purely functional, how do you *do* anything? You don't ;-)   (Courtesy of
Conal Elliott)

Haskell and Zen both happen to be my favorites in their respective fields
(and exactly which field that is for both is somewhat fuzzy)

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


Re: [Haskell-cafe] understanding enumerator/iteratee

2008-12-22 Thread Jason Dusek
  I'm taking a stab at composable streams, starting with
  cursors. I managed to make a derived cursor today -- as I work
  through this stuff, I hope to understand Iteratee/Enumerator
  better.

--
Jason Dusek

http://github.com/jsnx/streams/tree/554dd69339f027f113a6cfa16f552727ba9d92b3/Control/Stream/OneWay.hs
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Defining a containing function on polymorphic list

2008-12-22 Thread Raeck Zhao




 
I am trying to define a containing function to see if a value is one
of the elements within a list which is polymorphic, but failed with the
following codes:
  contain :: a - [a] - Bool

 contain x [] = False

 contain x (y:ys) = if x == y then True else contain x ys
it seems that the problem is the 'operator' == does not support a polymorphic 
check? 
Any way can solve the problem? or any alternative solution to achieve the 
purpose?
Thanks!
Raeck 
_
It’s the same Hotmail®. If by “same” you mean up to 70% faster.
http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_broad1_122008___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Takusen

2008-12-22 Thread Günther Schmidt

Hi all,

where can I find some sample code or other examples to familiarize me with  
Takusen?


Does Takusen use safe ccall only, or does it also use ccall unsafe?

Günther

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


Re: [Haskell-cafe] Defining a containing function on polymorphic list

2008-12-22 Thread Andrew Wagner
The problem here is even slightly deeper than you might realize. For
example, what if you have a list of functions. How do you compare two
functions to each other to see if they're equal? There is no good way really
to do it! So, not only is == not completely polymorphic, but it CAN'T be.

There is a nice solution for this, however, and it's very simple:

contain :: Eq a - [a] - Bool
contain x [] = False
contain x (y:ys) = if x == y then True else contain x ys

The Eq a in the type signature says that 'a' must be a member of the 'Eq'
typeclass. That says, in turn, that 'a' must have == defined for it.
Fortunately, most types have, or can easily derive that definition. Here is
the definition of the typeclass:

class 
Eqhttp://haskell.org/ghc/docs/latest/html/libraries/base/Data-Eq.html#t%3AEqa
where(==)http://haskell.org/ghc/docs/latest/html/libraries/base/Data-Eq.html#v%3A%3D%3D::
a - a -
Boolhttp://haskell.org/ghc/docs/latest/html/libraries/ghc-prim/GHC-Bool.html#t%3ABool
(/=)http://haskell.org/ghc/docs/latest/html/libraries/base/Data-Eq.html#v%3A%2F%3D::
a - a -
Boolhttp://haskell.org/ghc/docs/latest/html/libraries/ghc-prim/GHC-Bool.html#t%3ABool
That is, for 'a' to be a member of 'Eq', it must have a == operator which
can take 2 values of that type and return a Boolean, saying whether or not
they're equal, and it must also have a definition for the /= operator, which
is not equal. These two are also defined in terms of each other, so if you
define ==, you get /= for free, and vice versa.

That's probably more information than you needed to know, but I hope it
helps.

2008/12/22 Raeck Zhao ra...@msn.com

  I am trying to define a containing function to see if a value is one of
 the elements within a list which is polymorphic, but failed with the
 following codes:
  contain :: a - [a] - Bool
  contain x [] = False
  contain x (y:ys) = if x == y then True else contain x ys it seems that
 the problem is the 'operator' == does not support a polymorphic check?
 Any way can solve the problem? or any alternative solution to achieve the
 purpose?
 Thanks!
 Raeck

 --
 It's the same Hotmail(R). If by same you mean up to 70% faster. Get your
 account 
 now.http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_broad1_122008

 ___
 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] haskell for windows mobile 6 on Intel PXA270 processor

2008-12-22 Thread Constantine Potapov
Hi All.

I'm looking for haskell interpreter/compiler for windows mobile 6 (I
have an Asus A696 PDA with intel PXA270 processor).

Somebody head about any haskell implementation for this platform?

-- 
With best regards,
Constantine Potapov.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread John Goerzen
Duncan Coutts wrote:
 On Mon, 2008-12-22 at 10:30 +, Malcolm Wallace wrote:
 
 The terminology seems counter-intuitive, but in other other words, a
 safe call is slower but more flexible, an unsafe call is fast and
 dangerous.  Therefore it is always OK to convert an unsafe declaration
 into a safe one, but never OK to convert from safe to unsafe
 without looking at what the foreign side actually does.
 
 And in general we would not even bother with considering using unsafe
 for calls that are already expensive. It's only worth considering when
 the length of the call is always very short.
 
 For example in a database library it might make sense to use 'unsafe' on
 the data-access functions that extract data from a local query result
 but we should always use 'safe' on any DB function that might want to
 talk to the network (eg to get more query results).

It's difficult to anticipate the needs here.  For instance, some people
may be using a few very-long-running queries measured in minutes, such
as the original poster.  Other people, such as web app developers, may
be issuing literally millions of queries, right after another, where the
difference matters.

I had initially used unsafe because of the documented performance
benefit, plus I certainly am not expecting Sqlite to call back into the
Haskell runtime.

It seems to me strange that using unsafe instead of safe would have
negative implications for threading.  After all, as Malcolm said above,
it is always OK to convert an unsafe declaration into a safe one.  So
could the compiler be made to be smart enough to do so when it is
advantageous for threading purposes?

What's the best way to make this suitable for both people with many
queries and those with long-running queries?

I should also add that I suspect the C calls that are bothering the
original poster here are the standard ones for reading results, and
could be called many, many times on even a single query.

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


Re: [Haskell-cafe] Defining a containing function on polymorphic list

2008-12-22 Thread Denis Bueno
2008/12/22 Andrew Wagner wagner.and...@gmail.com:
 The problem here is even slightly deeper than you might realize. For
 example, what if you have a list of functions. How do you compare two
 functions to each other to see if they're equal? There is no good way really
 to do it! So, not only is == not completely polymorphic, but it CAN'T be.

 There is a nice solution for this, however, and it's very simple:

 contain :: Eq a - [a] - Bool

Please note that the syntax here should be:

contain :: Eq a = a - [a] - Bool

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


Re: [Haskell-cafe] Defining a containing function on polymorphic list

2008-12-22 Thread Andrew Wagner
Yes, of course, sorry for the typo.

On Mon, Dec 22, 2008 at 9:17 AM, Denis Bueno dbu...@gmail.com wrote:

 2008/12/22 Andrew Wagner wagner.and...@gmail.com:
  The problem here is even slightly deeper than you might realize. For
  example, what if you have a list of functions. How do you compare two
  functions to each other to see if they're equal? There is no good way
 really
  to do it! So, not only is == not completely polymorphic, but it CAN'T be.
 
  There is a nice solution for this, however, and it's very simple:
 
  contain :: Eq a - [a] - Bool

 Please note that the syntax here should be:

contain :: Eq a = a - [a] - Bool

  Denis

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


[Haskell-cafe] ANN: Control.Monad.IfElse

2008-12-22 Thread Jeff Heard
Provides useful anaphoric and monadic versions of if-else and when, as
well as infix operators for the actions to allow things like this:

-- Allow the clause to be in m a
whenM (Gtk.widgetIsFocus win) $ do
  this
  that

-- anaphoric if.  If the condition is nonempty, pass the conditional
value to the then clause, otherwise do an action that requires no
parameter.
aif (lookup name list)
  (\file - Right `liftM` hGetLine file)
  (do f - openFile name
   l - hGetLine file
   return $ Right (f,l))

-- infix version of Control.Monad.When
(x5) ? putStrLn x

-- infix version of anaphoric when
lookup name list =? \value - putStrLn value

-- infix version of anaphoric whenM
Gtk.widgetIntersect win rect =? \intersectingRectangle' -
Gtk.invalidate intersectingRectangle'
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Defining a containing function on polymorphic list

2008-12-22 Thread Thomas Davie


On 22 Dec 2008, at 15:18, Andrew Wagner wrote:


Yes, of course, sorry for the typo.

On Mon, Dec 22, 2008 at 9:17 AM, Denis Bueno dbu...@gmail.com wrote:
2008/12/22 Andrew Wagner wagner.and...@gmail.com:
 The problem here is even slightly deeper than you might realize. For
 example, what if you have a list of functions. How do you compare  
two
 functions to each other to see if they're equal? There is no good  
way really
 to do it! So, not only is == not completely polymorphic, but it  
CAN'T be.


 There is a nice solution for this, however, and it's very simple:

 contain :: Eq a - [a] - Bool

Please note that the syntax here should be:

   contain :: Eq a = a - [a] - Bool

 Denis


Of note, unless this is an exercise, such a function already exists --  
it's called elem.


How do you find such a function?  You search on haskell.org/hoogle.

http://haskell.org/hoogle/?hoogle=Eq+a+%3D%3E+a+-%3E+%5Ba%5D+-%3E+Bool

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


[Haskell-cafe] A hell of a question

2008-12-22 Thread Andrzej Jaworski

Hi Luke,
When neurosurgeons split the brain into left and right hemisphere cutting it 
along corpus callosum
the patient will talk to you with his left
half and right half independently - each time unaware what his other half was 
talking about a moment
earlier. I believe Zen emulates such
split on a microscopic scale. We all go thru similar state when we conceive an 
original idea - if we
do not write this down or formulate it
immediately the discovery will loose its punch and sense of depth. The best 
documented and most
prominent example is Hegel's discovery of
dialectical logic - after extensive writing about that at some point he 
honestly admits loosing the
original concept. But if not for his
western oververbosity we might not today use the term 'naive' set theory. Every 
serious mathematician
touching foundations is today perfectly
aware of the price we pay for formulating things. But I am unaware of any 
virtue of trying to clap
with one hand;-)

Regards,
-Andrzej

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


[Haskell-cafe] Re: forkIO on multicore

2008-12-22 Thread Simon Marlow

Duncan Coutts wrote:

On Fri, 2008-12-19 at 10:42 -0600, Jake McArthur wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Paul Keir wrote:

fibs = 0 : 1 : zipWith (+) fibs (tail fibs)

This is a CAF (Constant Applicative Form). Since it is actually a
constant it is never garbage collected, and is always shared, so each
thread is only calculating it once. You have essentially created a
lookup table.


Though note that with all our obvious suggestions there is still no
speedup:

heavytask m n = putMVar m $! (fibs !! 10)
  where
fibs = n : (n+1) : zipWith (+) fibs (tail fibs)

-- so now fibs is not globally shared but is used per-heavytask
-- it is also evaluated by heavy task rather than just putting a thunk
-- into the MVar

main = do ms - sequence $ replicate 8 newEmptyMVar
  sequence_
[ forkIO (heavytask m n)
| (m, n) - zip ms [0..] ]
  ms' - mapM takeMVar ms
  mapM_ print ms'

Looking at the GC stats (+RTS -t -RTS) we see that the majority of the
time in this program is spent doing GC and that when we run with -N4 the
time spent doing GC is even higher.


This is an interesting example.  It shows up a weakness in the GC that I'm 
working on fixing right now.


The interesting aspect of this example is that the thread stacks get large. 
 You can see this by using +RTS -hT: a large chunk of the heap is taken up 
by TSOs. Each of those (fibs !! 10) requires linear stack, because 
(fibs 10) depends on (fibs 9), and so on.  That could probably be 
fixed by adding some strictness, but that's not the goal here - we should 
still be able to run the program in parallel.


So when there are large stacks around, GC takes a long time because it has 
to traverse stacks.  But we should be able to alleviate the problem by (a) 
using a larger heap, and (b) using parallel GC.  Not doing parallel GC is 
seriously going to hurt peformance, because the data will have to be moved 
from one CPU's cache to another.  But it turns out that parallel GC is 
misbehaving on this example too, because it doesn't force each stack to be 
scanned by the same thread that is executing it - I'm working on fixing that.


Having each CPU be able to GC independently would be a big improvement, of 
course.  We think we understand how this can be done in the context of GHC, 
it's just a matter of doing it, but it's a big job.


Parallel performance is something that we expect to make dramatic 
improvements over the next few months as we investigate more programs and 
improve the tools.  The current HEAD is already a lot better than 6.10.1.


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


RE: [Haskell-cafe] Defining a containing function on polymorphic list

2008-12-22 Thread Raeck Zhao

Thank you very much for your reply! It is really helpful!

But I just found another 'problem', I just realize that the list does not 
support the user-defined data type?
the list is also depending on the Eq function?

For example,

data Shape = Square | Triangle | Circle

when I type either

[Square, Triangle, Circle]

or 

Square == Square

there are errors!

So there is no way to construct a truly polymorphic List? any way to extend the 
list to support some user-defined data type?

Or...  I define the Shape in a wrong way actually?

Thanks

Raeck


Date: Mon, 22 Dec 2008 09:02:53 -0500
From: wagner.and...@gmail.com
To: ra...@msn.com
Subject: Re: [Haskell-cafe] Defining a containing function on polymorphic list
CC: haskell-cafe@haskell.org; beginn...@haskell.org

The problem here is even slightly deeper than you might realize. For example, 
what if you have a list of functions. How do you compare two functions to each 
other to see if they're equal? There is no good way really to do it! So, not 
only is == not completely polymorphic, but it CAN'T be. 


There is a nice solution for this, however, and it's very simple:

contain :: Eq a - [a] - Bool

contain x [] = False

contain x (y:ys) = if x == y then True else contain x ys

The Eq a in the type signature says that 'a' must be a member of the 'Eq' 
typeclass. That says, in turn, that 'a' must have == defined for it. 
Fortunately, most types have, or can easily derive that definition. Here is the 
definition of the typeclass:


class  Eq a  where
(==) :: a - a - Bool
(/=) :: a - a - Bool

That is, for 'a' to be a member of 'Eq', it must have a == operator which can 
take 2 values of that type and return a Boolean, saying whether or not they're 
equal, and it must also have a definition for the /= operator, which is not 
equal. These two are also defined in terms of each other, so if you define ==, 
you get /= for free, and vice versa. 


That's probably more information than you needed to know, but I hope it helps.

2008/12/22 Raeck Zhao ra...@msn.com









 
I am trying to define a containing function to see if a value is one
of the elements within a list which is polymorphic, but failed with the
following codes:

  contain :: a - [a] - Bool

 contain x [] = False

 contain x (y:ys) = if x == y then True else contain x ys
it seems that the problem is the 'operator' == does not support a polymorphic 
check? 

Any way can solve the problem? or any alternative solution to achieve the 
purpose?

Thanks!

Raeck
 
It's the same Hotmail®. If by same you mean up to 70% faster. Get your 
account now.


___

Haskell-Cafe mailing list

Haskell-Cafe@haskell.org

http://www.haskell.org/mailman/listinfo/haskell-cafe




_
Life on your PC is safer, easier, and more enjoyable with Windows Vista®. 
http://clk.atdmt.com/MRT/go/127032870/direct/01/___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Günther Schmidt

Hi,

I am not yet 100% certain that the unsafe calls are indeed the cause of  
the problem, eventhough I strongly suspect there are.


I can tell you more once I have managed to rewrite all unsafe calls into  
safe once, reinstall HDBC.Sqlite3 and then run my app again to see the  
effects. My first attempt doing so was not successful, I'm not certain  
whether I missed an unsafe call or the app is using an old version of  
HDBC.Sqlite3 or whatever.


I understand that Takusen does not use unsafe calls and would like to  
try it with that one then, but haven't find enough docs yet on how to use  
Takusen.


Günther

Am 22.12.2008, 15:15 Uhr, schrieb John Goerzen jgoer...@complete.org:


Duncan Coutts wrote:

On Mon, 2008-12-22 at 10:30 +, Malcolm Wallace wrote:


The terminology seems counter-intuitive, but in other other words, a
safe call is slower but more flexible, an unsafe call is fast and
dangerous.  Therefore it is always OK to convert an unsafe  
declaration

into a safe one, but never OK to convert from safe to unsafe
without looking at what the foreign side actually does.


And in general we would not even bother with considering using unsafe
for calls that are already expensive. It's only worth considering when
the length of the call is always very short.

For example in a database library it might make sense to use 'unsafe' on
the data-access functions that extract data from a local query result
but we should always use 'safe' on any DB function that might want to
talk to the network (eg to get more query results).


It's difficult to anticipate the needs here.  For instance, some people
may be using a few very-long-running queries measured in minutes, such
as the original poster.  Other people, such as web app developers, may
be issuing literally millions of queries, right after another, where the
difference matters.

I had initially used unsafe because of the documented performance
benefit, plus I certainly am not expecting Sqlite to call back into the
Haskell runtime.

It seems to me strange that using unsafe instead of safe would have
negative implications for threading.  After all, as Malcolm said above,
it is always OK to convert an unsafe declaration into a safe one.  So
could the compiler be made to be smart enough to do so when it is
advantageous for threading purposes?

What's the best way to make this suitable for both people with many
queries and those with long-running queries?

I should also add that I suspect the C calls that are bothering the
original poster here are the standard ones for reading results, and
could be called many, many times on even a single query.

-- John
___
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] Defining a containing function on polymorphic list

2008-12-22 Thread Andrew Wagner
There are two ways to fix this. Let me see if I can get my syntax right this
time :)

1.) Let GHC work out the Eq instance:
  data Shape = Square | Triangle | Circle deriving Eq

2.) Tell GHC how to do it explicitly:
  data Shape = Square | Triangle | Circle
  instance Eq Shape where
Square == Square = True
Triangle == Triangle = True
Circle == Circle = True
_ == _ = False

Note that the last line here means that any other comparisons are false.

On Mon, Dec 22, 2008 at 9:35 AM, Raeck Zhao ra...@msn.com wrote:

  Thank you very much for your reply! It is really helpful!

 But I just found another 'problem', I just realize that the list does not
 support the user-defined data type?
 the list is also depending on the Eq function?

 For example,

 data Shape = Square | Triangle | Circle

 when I type either

 [Square, Triangle, Circle]

 or

 Square == Square

 there are errors!

 So there is no way to construct a truly polymorphic List? any way to extend
 the list to support some user-defined data type?

 Or...  I define the Shape in a wrong way actually?

 Thanks

 Raeck


 --
 Date: Mon, 22 Dec 2008 09:02:53 -0500
 From: wagner.and...@gmail.com
 To: ra...@msn.com
 Subject: Re: [Haskell-cafe] Defining a containing function on polymorphic
 list
 CC: haskell-cafe@haskell.org; beginn...@haskell.org

 The problem here is even slightly deeper than you might realize. For
 example, what if you have a list of functions. How do you compare two
 functions to each other to see if they're equal? There is no good way really
 to do it! So, not only is == not completely polymorphic, but it CAN'T be.

 There is a nice solution for this, however, and it's very simple:

 contain :: Eq a - [a] - Bool
 contain x [] = False
 contain x (y:ys) = if x == y then True else contain x ys

 The Eq a in the type signature says that 'a' must be a member of the 'Eq'
 typeclass. That says, in turn, that 'a' must have == defined for it.
 Fortunately, most types have, or can easily derive that definition. Here is
 the definition of the typeclass:

 class 
 Eqhttp://haskell.org/ghc/docs/latest/html/libraries/base/Data-Eq.html#t:Eqa
 where 
 (==)http://haskell.org/ghc/docs/latest/html/libraries/base/Data-Eq.html#v:%3D%3D::
  a - a -
 Boolhttp://haskell.org/ghc/docs/latest/html/libraries/ghc-prim/GHC-Bool.html#t:Bool
 (/=)http://haskell.org/ghc/docs/latest/html/libraries/base/Data-Eq.html#v:/%3D::
  a - a -
 Boolhttp://haskell.org/ghc/docs/latest/html/libraries/ghc-prim/GHC-Bool.html#t:Bool
 That is, for 'a' to be a member of 'Eq', it must have a == operator which
 can take 2 values of that type and return a Boolean, saying whether or not
 they're equal, and it must also have a definition for the /= operator, which
 is not equal. These two are also defined in terms of each other, so if you
 define ==, you get /= for free, and vice versa.

 That's probably more information than you needed to know, but I hope it
 helps.

 2008/12/22 Raeck Zhao ra...@msn.com

  I am trying to define a containing function to see if a value is one of
 the elements within a list which is polymorphic, but failed with the
 following codes:
  contain :: a - [a] - Bool
  contain x [] = False
  contain x (y:ys) = if x == y then True else contain x ys it seems that
 the problem is the 'operator' == does not support a polymorphic check?
 Any way can solve the problem? or any alternative solution to achieve the
 purpose?
 Thanks!
 Raeck

 --
 It's the same Hotmail(R). If by same you mean up to 70% faster. Get your
 account 
 now.http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_broad1_122008

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



 --
 Life on your PC is safer, easier, and more enjoyable with Windows Vista(R). 
 See
 how http://clk.atdmt.com/MRT/go/127032870/direct/01/

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


Re[2]: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Bulat Ziganshin
Hello John,

Monday, December 22, 2008, 5:15:46 PM, you wrote:

 And in general we would not even bother with considering using unsafe
 for calls that are already expensive. It's only worth considering when
 the length of the call is always very short.

the other way to look at it is to measure overhead of safe call.

on 1 GHz Duron i measured 66.000 calls of trivial safe function per
second, meaning 16.000 cpu ticks per call (ghc 6.8). it's rather large
overhead for many trivial functions, but for calls to sql engine it
seems rather small


-- 
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] Re: Threads with high CPU usage

2008-12-22 Thread John Goerzen
Günther Schmidt wrote:
 Hi,
 
 I am not yet 100% certain that the unsafe calls are indeed the cause of  
 the problem, eventhough I strongly suspect there are.
 
 I can tell you more once I have managed to rewrite all unsafe calls into  
 safe once, reinstall HDBC.Sqlite3 and then run my app again to see the  
 effects. My first attempt doing so was not successful, I'm not certain  
 whether I missed an unsafe call or the app is using an old version of  
 HDBC.Sqlite3 or whatever.

That is an interesting data point indeed.  You might try to isolate the
problem into some small section of code that reproduces it, so that we
can do some more testing on our own systems.

-- John

 
 I understand that Takusen does not use unsafe calls and would like to  
 try it with that one then, but haven't find enough docs yet on how to use  
 Takusen.
 
 Günther
 
 Am 22.12.2008, 15:15 Uhr, schrieb John Goerzen jgoer...@complete.org:
 
 Duncan Coutts wrote:
 On Mon, 2008-12-22 at 10:30 +, Malcolm Wallace wrote:

 The terminology seems counter-intuitive, but in other other words, a
 safe call is slower but more flexible, an unsafe call is fast and
 dangerous.  Therefore it is always OK to convert an unsafe  
 declaration
 into a safe one, but never OK to convert from safe to unsafe
 without looking at what the foreign side actually does.
 And in general we would not even bother with considering using unsafe
 for calls that are already expensive. It's only worth considering when
 the length of the call is always very short.

 For example in a database library it might make sense to use 'unsafe' on
 the data-access functions that extract data from a local query result
 but we should always use 'safe' on any DB function that might want to
 talk to the network (eg to get more query results).
 It's difficult to anticipate the needs here.  For instance, some people
 may be using a few very-long-running queries measured in minutes, such
 as the original poster.  Other people, such as web app developers, may
 be issuing literally millions of queries, right after another, where the
 difference matters.

 I had initially used unsafe because of the documented performance
 benefit, plus I certainly am not expecting Sqlite to call back into the
 Haskell runtime.

 It seems to me strange that using unsafe instead of safe would have
 negative implications for threading.  After all, as Malcolm said above,
 it is always OK to convert an unsafe declaration into a safe one.  So
 could the compiler be made to be smart enough to do so when it is
 advantageous for threading purposes?

 What's the best way to make this suitable for both people with many
 queries and those with long-running queries?

 I should also add that I suspect the C calls that are bothering the
 original poster here are the standard ones for reading results, and
 could be called many, many times on even a single query.

 -- John
 ___
 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] Can I build and install GHC 6.10.1 withoutprevious installed ghc

2008-12-22 Thread Robert Greayer
I've recently built 6.10.1 on fairly archaic RHEL servers, both 64 and 32 bit, 
and the incantation that worked most seamlessly for me was to grab a really old 
binary release (in my case 6.2 worked) that installs without intervention, and 
then build up to the latest version (6.10.1) in steps -- I built 6.6 with 6.2, 
then 6.10.1 with 6.6, and it all worked without a problem.  Of course, I'd try 
6.6/binary first, but if that doesn't work, all is not lost, older binary 
releases may still work, and you can then bootstrap from those.

Rob



- Original Message 
From: Wang, Chunye (NSN - CN/Beijing) chunye.w...@nsn.com
To: Haskell-Cafe@haskell.org
Sent: Monday, December 22, 2008 4:53:53 AM
Subject: RE: [Haskell-cafe] Can I build and install GHC 6.10.1 withoutprevious 
installed ghc

Hi Duncan,


wget
http://haskell.org/ghc/dist/6.8.2/ghc-6.8.2-x86_64-unknown-linux.tar.bz2
tar -jxvf ghc-6.8.2-x86_64-unknown-linux.tar.bz2 
cd ghc-6.8.2
./configure 

checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
Which we'll further canonicalise into: x86_64-unknown-linux
checking for path to top of build tree... pwd: timer_create: Invalid
argument
configure: error: cannot determine current directory

Even though I can fixed this by ``cp /bin/pwd utils/pwd/pwd'' , there is
still similar error

``ghc-pkg.bin: timer_create: Invalid argument''

I guess any executable file generates same error message.


Best Regards
Chunye Wang chunye.w...@nsn.com


-Original Message-
From: ext Duncan Coutts [mailto:duncan.cou...@worc.ox.ac.uk] 
Sent: Monday, December 22, 2008 5:38 PM
To: Wang, Chunye (NSN - CN/Beijing)
Cc: Haskell-Cafe@haskell.org
Subject: RE: [Haskell-cafe] Can I build and install GHC 6.10.1
withoutprevious installed ghc

On Mon, 2008-12-22 at 11:53 +0800, Wang, Chunye (NSN - CN/Beijing)
wrote:
 
 I tried to install the ghc 6.8.0 last year but failed for some reason.

 Now I decide to do it again, because I'd like to try some examples in 
 Real World Haskell Now I remember why I try to install it from 
 source code, because the binary version has the following problem.

 I guess ``timer_create '' is failed because of library confliction.

I suggest you use the binary for ghc-6.8.2 (not 6.8.3) or earlier
because those were built on an old Red Hat 9 server and are thus
compatible with older versions of glibc and the Linux kernel.

If you really need ghc-6.10 (you probably do not if you're just trying
examples from the Real World Haskell book) then you can build ghc-6.10.x
from source once you have the ghc-6.8.2 binary installed.

Duncan

___
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] Re: Threads with high CPU usage

2008-12-22 Thread GŸuenther Schmidt

John Goerzen schrieb:

Günther Schmidt wrote:
  

Hi,

I am not yet 100% certain that the unsafe calls are indeed the cause of  
the problem, eventhough I strongly suspect there are.


I can tell you more once I have managed to rewrite all unsafe calls into  
safe once, reinstall HDBC.Sqlite3 and then run my app again to see the  
effects. My first attempt doing so was not successful, I'm not certain  
whether I missed an unsafe call or the app is using an old version of  
HDBC.Sqlite3 or whatever.



That is an interesting data point indeed.  You might try to isolate the
problem into some small section of code that reproduces it, so that we
can do some more testing on our own systems.

-- John

  
I'd love to provide you with it but you'd have to manage a query that 
takes a long time to finish yourself.


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


RE: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Bayley, Alistair
 From: haskell-cafe-boun...@haskell.org 
 [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Günther Schmidt
 
 I understand that Takusen does not use unsafe calls and 
 would like to  
 try it with that one then, but haven't find enough docs yet 
 on how to use  
 Takusen.

Not a lot of detailed examples exist for Takusen. I'm hoping the documentation 
for Database.Enumerator is a reasonable place to start.
http://darcs.haskell.org/takusen/doc/html/Database-Enumerator.html

I just reviewed the Takusen code and, for no apparent reason, the ODBC module 
specifies unsafe for all of its FFI imports, but the other modules do not (so 
they get the default, which I assume is safe). I also was not aware of unsafe 
calls blocking other threads. I'll change the ODBC imports to be safe (or 
rather, unspecified).

Alistair
 
*
Confidentiality Note: The information contained in this message,
and any attachments, may contain confidential and/or privileged
material. It is intended solely for the person(s) or entity to
which it is addressed. Any review, retransmission, dissemination,
or taking of any action in reliance upon this information by
persons or entities other than the intended recipient(s) is
prohibited. If you received this in error, please contact the
sender and delete the material from any computer.
*

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


Re[2]: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Bulat Ziganshin
Hello Alistair,

Monday, December 22, 2008, 7:28:03 PM, you wrote:

 safe). I also was not aware of unsafe calls blocking other threads.

they don't to it directly. but without -threaded +RTS -N (or forkOS)
there is only 1 OS thread that runs all haskell threads. unsafe call
blocks it untill call finished, while safe call allows to reuse it for
other haskell threads execution. i've attached old ghc commentary on
this topic, although things may be significantly changed ATM


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

The GHC Commentary - Supporting multi-threaded	interoperation.htm
Description: Binary data
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] monad constraint + record update

2008-12-22 Thread Peter Padawitz
I'd like to define a monad Set for types in the class Eq. But how can 
the arguments of Set be constrained when Set is defined as an instance 
of Monad? instance Eq a = Monad Set where ... obviously cannot work.


Is there a standard update function for fields in data types, something 
that OO programmers do with assignments like obj.attr := value ?


Peter

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



Re: [Haskell-cafe] The Haskell re-branding exercise

2008-12-22 Thread Eelco Lempsink

On 21 dec 2008, at 22:26, Sebastian Sylvan wrote:
I am very shortly travelling abroad for several weeks and will not  
have (reliable access to) a computer, but isn't this a task for one  
of the haskell web-apps people (HSP, HAppS, Turbinado, etc.) to show  
us once and for all why *their* library is better than the  
competition? :-)


Hmm, right.  I started on a thing in HAppS.  See http://github.com/eelco/voting/ 
 for the source code (contributors more than welcome!) and http://code.tupil.com/voting/ 
 for a live demo.  It relies heavily on javascript, needs some work  
on the UI and there are a lot of features that could be added, but it  
works.


--
Regards,

Eelco Lempsink



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


Re: [Haskell-cafe] The Haskell re-branding exercise

2008-12-22 Thread Loup Vaillant
2008/12/22 Eelco Lempsink ee...@lempsink.nl:
 Hmm, right.  I started on a thing in HAppS.  See
 http://github.com/eelco/voting/ for the source code (contributors more than
 welcome!) and http://code.tupil.com/voting/ for a live demo.  It relies
 heavily on javascript, needs some work on the UI and there are a lot of
 features that could be added, but it works.

Great.
Could it be further hacked to accept ties, as suggested by Sebastian?
Something like:

thingie1 thingie1bis
thingie3
thingie4 thingie4bis

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


[Haskell-cafe] Problems Installing Takusen with Sqlite Backend

2008-12-22 Thread Günther Schmidt

Hi Alistair,

what does it take to install Takusen on Win32 with Sqlite backend?

I did manage to install *plain* Takusen via cabal install by downgrading  
to Cabal-1.4 but when I want to


   cabal-install takusen -fsqlite

it complains about a missing sqlite3.

What do I need to fix?

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


Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Duncan Coutts
On Mon, 2008-12-22 at 08:15 -0600, John Goerzen wrote:
 Duncan Coutts wrote:
  On Mon, 2008-12-22 at 10:30 +, Malcolm Wallace wrote:
  
  The terminology seems counter-intuitive, but in other other words, a
  safe call is slower but more flexible, an unsafe call is fast and
  dangerous.  Therefore it is always OK to convert an unsafe declaration
  into a safe one, but never OK to convert from safe to unsafe
  without looking at what the foreign side actually does.
  
  And in general we would not even bother with considering using unsafe
  for calls that are already expensive. It's only worth considering when
  the length of the call is always very short.
  
  For example in a database library it might make sense to use 'unsafe' on
  the data-access functions that extract data from a local query result
  but we should always use 'safe' on any DB function that might want to
  talk to the network (eg to get more query results).
 
 It's difficult to anticipate the needs here.  For instance, some people
 may be using a few very-long-running queries measured in minutes, such
 as the original poster.  Other people, such as web app developers, may
 be issuing literally millions of queries, right after another, where the
 difference matters.

The cost of a safe call is not really that high. In comparison to
something a C function that just extracts a member from a structure it's
high, but compared to executing even a simple SQL query I expect it's
not even measurable.

 I had initially used unsafe because of the documented performance
 benefit, plus I certainly am not expecting Sqlite to call back into the
 Haskell runtime.
 
 It seems to me strange that using unsafe instead of safe would have
 negative implications for threading.  After all, as Malcolm said above,
 it is always OK to convert an unsafe declaration into a safe one.  So
 could the compiler be made to be smart enough to do so when it is
 advantageous for threading purposes?

I think it could only do it by turning all unsafe functions into
safe ones. As I understand it, the ability to switch rts capability is
the more expensive of the properties that safe provides (compared to
allowing the function to be re-entrant) because it involves pthread
mutexes.

 What's the best way to make this suitable for both people with many
 queries and those with long-running queries?

If the squlite API distinguishes executing a query (potentially long
running) from extracting data from the result set (always quick) then it
would be possible to mark the former safe and the latter unsafe and
still not impose any great overhead on any user.

Duncan

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


Re: [Haskell-cafe] Re: [Haskell] ANN: HLint 1.0

2008-12-22 Thread Claus Reinke

Well, sort of. Ok, we can parse that. Let's assume a variable x holds
the output of :show modules as a String. We call lines on it, then map
words on it, do a !! 2 on it, and we get [Util.hs,, Recorder.hs,,
Game.hs,, Monadius.hs,, Demo.hs,]. Chuck in a map (filter (\=
',')), and we get a good list. We can turn the list into a string
suitable for hlint with a quick unwords.

So our long sought after command becomes ':def hoogle (\_ - return $
:!  ++ (unwords $ map (filter (\= ',')) $ (map words $ lines x) !!
2))'. But wait, how do we get 'x'? How do we call :show modules inside
a Haskell expression? I have carefully looked over
http://haskell.org/haskellwiki/GHC/GHCi#Using_GHCi and
http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci-commands.html
and my conclusion is that you can't. You can't do a let x = :show
modules, there is no function which will take :show modules, and so
on. :functions can accept Haskell output, but it's a one-way barrier.
It's no good writing Haskell functions which need information from the
:functions.


The first url includes a link to a .ghci mini-tutorial (section 4) that, 
among other things, implements 


   :redir var cmd  -- execute cmd, redirecting stdout to var

Happy Holidays!-)
Claus

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


Re: [Haskell-cafe] Defining a containing function on polymorphic list

2008-12-22 Thread Miguel Mitrofanov


On 22 Dec 2008, at 17:35, Raeck Zhao wrote:

But I just found another 'problem', I just realize that the list  
does not support the user-defined data type?


Don't worry, it does.


the list is also depending on the Eq function?


No, it doesn't.


data Shape = Square | Triangle | Circle

[Square, Triangle, Circle]


Should work fine.


or

Square == Square



Wouldn't work unless you declare your type Shape an instance of  
class Eq - which can be done automatically.

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


Re: [Haskell-cafe] Defining a containing function on polymorphic list

2008-12-22 Thread Luke Palmer
2008/12/22 Raeck Zhao ra...@msn.com

  Thank you very much for your reply! It is really helpful!

 But I just found another 'problem', I just realize that the list does not
 support the user-defined data type?
 the list is also depending on the Eq function?

 For example,

 data Shape = Square | Triangle | Circle

 when I type either

 [Square, Triangle, Circle]


This is perfectly legal, but GHCi won't be able to print it, because there
is no Show instance for Shape.  You can declare one:

instance Show Shape where
show Square = Square
show Triagle = Triangle
show Circle = Circle

This can be generated automatically when you declare the type, by using:

data Shape = Square | Triangle | Circle
deriving (Show)




 or

 Square == Square


Similarly, to use (==), you need an Eq instance, which can be defined much
in the same way as the Show instance above  (deriving also works on Eq --
don't generalize too hastily; not all classes work with deriving).

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


Re: [Haskell-cafe] monad constraint + record update

2008-12-22 Thread Miguel Mitrofanov

You can use a continuation trick I describe below.

First of all, I would like to work in a more general situation. So,  
instead of working with Set, I'd like to declare two classes:


 class Returnable m a where ret :: a - m a

and

 class Bindable m a b where bind :: m a - (a - m b) - m b

I'm sure you're able to define instances like instance Ord a =  
Returnable Set a by yourself. You'll need MultiParamTypeClasses and  
FlexibleInstances for that to work.


Now, the trick:

 newtype Restricted r m a = Restricted ((a - m r) - m r)
 instance Monad (Restricted r m) where
 return x = Restricted $ \h - h x
 Restricted g = f = Restricted $ \h - g $ \x - let  
Restricted g' = f x in g' h


Quite simple, and doesn't mention pseudo-monadic structure of m at  
all.


Now, the fun part:

 embed :: Bindable m a r = m a - Restricted r m a
 embed mx = Restricted (bind mx)

 unembed :: Returnable m r = Restricted r m r - m r
 unembed (Restricted g) = g ret

You may also want another class

 class Summable m a where
 zero :: m a
 plus :: m a - m a - m a

and now you can have

 instance Summable m r = MonadPlus (Restricted r m) where
 mzero = Restricted $ const zero
 Restricted g1 `mplus` Restricted g2 = Restricted $ \h - g1 h  
`plus` g2 h


From now on, you can do something like that:

 unembed $ do x - embed $ Set.fromList [6,2,3]
  (do y - return x
  z - embed $ Set.fromList [1..2]
  guard $ y  5
  return $ y + z)
  `mplus` return 10

and have fromList [3,4,5,10], as expected

On 22 Dec 2008, at 20:19, Peter Padawitz wrote:

I'd like to define a monad Set for types in the class Eq. But how  
can the arguments of Set be constrained when Set is defined as an  
instance of Monad? instance Eq a = Monad Set where ... obviously  
cannot work.


Is there a standard update function for fields in data types,  
something that OO programmers do with assignments like obj.attr :=  
value ?


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] A hell of a question

2008-12-22 Thread Andrzej Jaworski

Arnaud Bailly kindly exposed my mistake: I cited Leibniz Monadology attributing 
it to Spinoza. Call
me idiot but it wasn't thoughtless mistake, I really mixed up Spinoza's concept 
of 'modes' with
Leibniz's concept of 'monad'. But it is because of my laziness rather than 
foolishness (at least this
time). My argument is that in his final writings Leibniz's 'monads' encompass 
reality as perceptions
and emanate from God as thought emanates from the mind, which is exactly what 
Spinoza's 'modes' are
about. So monads and modes being equal I prefer Spinoza as a patron for Haskell 
for his purity of
cause-effect treatment.

Arnold adds another Haskell-Spinoza nicety, I hope he won't mind my including 
his all letter.
Thank you Arnold, it is encouraging to find guys like you. Philosophy is not my 
thing but I believe
every man should tackle it as exercise.


Hello Andrzej,
Thanks a lot for your bit of rationalism among all these devotions :-)

I think however that you are confusing Spinoza with Leibniz in the
following assertion. Monads are a concept invented by the latter,
together with the famous the best possible world ever mocked by
Voltaire in Candide.

The comparison between Haskell and spinozism is rather interesting
though, especially when one considers that Spinoza's Ethic is based
on the idea that the ultimate goal of one self is to increase its
power to live, an affect which it calls Joy.

Thinking of Haskell as a way to increase one's joy and one's power is
a nice thought.

Regards,
Arnaud Bailly

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


[Haskell-cafe] concurrent haskell: thread priorities

2008-12-22 Thread Neal Alexander

From what i understand (correct me if I'm wrong):

The threaded RT creates an OS thread for each CPU/core on the system and 
uses them to multiplex userland threads. These are context switched 
whenever they block/yield/gc and no priorities can be assigned.


It seems like we could get some priority based scheduling (and still be 
slackers) if we allow marked green threads to be strictly associated 
with a specific OS thread (forkChildIO?).



Its not a very good solution, but it seems easy to implement and would 
be nice for the few problems that really need priority based scheduling.


How many of those problems involve having 1 thread running at 
high/realtime priority? Maybe most?


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


Re: [Haskell-cafe] Rewrite thunk action rule?

2008-12-22 Thread Dan Weston

Peter Todd wrote:

Not quite. If I have a thunk, at the low level somewhere it must refer
to the transform function, the transform matrix, and the element that is
to be transformed. If I apply another transform to that unevaluated
thunk, my understanding is that haskell will represent it as such:

thunk transform Ta (thunk transform Tb e)

When I want the following:

thunk transform (Ta * Tb) e


Is this an example of a Thunktor?

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


Re: [Haskell-cafe] monad constraint + record update

2008-12-22 Thread Cristiano Paris
On Mon, Dec 22, 2008 at 6:19 PM, Peter Padawitz peter.padaw...@udo.edu wrote:
 I'd like to define a monad Set for types in the class Eq. But how can the
 arguments of Set be constrained when Set is defined as an instance of Monad?
 instance Eq a = Monad Set where ... obviously cannot work.

Shouldn't you impose the constraint when defining functions operating
on Set values? I guess that the contraint should be enforced not only
when dealing with monadic code, but also whenever it appears in your
program.

 Is there a standard update function for fields in data types, something that
 OO programmers do with assignments like obj.attr := value ?

Your statement doesn't make much sense in the functional world of Haskell.

There's a record update construct which may resemble the OO data
update operation but it makes a whole new copy of the original value,
i.e.:

foo a = a { attr = value }

which is basically like doing:

foo a = a + 2

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


Re: [Haskell-cafe] concurrent haskell: thread priorities

2008-12-22 Thread Bulat Ziganshin
Hello Neal,

Monday, December 22, 2008, 11:07:32 PM, you wrote:

 The threaded RT creates an OS thread for each CPU/core on the system and
 uses them to multiplex userland threads. These are context switched 
 whenever they block/yield/gc and no priorities can be assigned.

not exactly. amount of OS threads created controlled by +RTS -N option
to the program; unless program has special function that RTS calls to
set up this value

they are switched on every minor GC which by default occurs after
each 256kb allocated which is rather frequent event

 It seems like we could get some priority based scheduling (and still be
 slackers) if we allow marked green threads to be strictly associated 
 with a specific OS thread (forkChildIO?).

forkOS creates new haskell thread and new OS thread specially for it

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

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


[Haskell-cafe] OpenAL

2008-12-22 Thread brian
Does the example code at
http://articles.bluishcoder.co.nz/Haskell/OpenAL work for anyone? I
added some putStrLns to see the device and context, and get

$ ./Main2
Device (ALCdevice 0x08a744c8)
Context (ALCcontext 0x08aabda0)
AL lib: alSource.c:2291: alcDestroyContext(): 1 Source(s) NOT deleted
AL lib: alBuffer.c:1097: exit() 2 Buffer(s) NOT deleted

and no sound.

I had more complex code using OpenAL working some time ago, but the
sound was crackly because my distribution used the original OpenAL
implementation. Now that people are switching to OpenAL Soft,
Haskell's OpenAL seems to be acting strangely. I mailed Sven in
September, but didn't hear back.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread John Goerzen
On Mon, Dec 22, 2008 at 04:28:03PM -, Bayley, Alistair wrote:
  From: haskell-cafe-boun...@haskell.org 
  [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Günther Schmidt
  
  I understand that Takusen does not use unsafe calls and 
  would like to  
  try it with that one then, but haven't find enough docs yet 
  on how to use  
  Takusen.
 
 Not a lot of detailed examples exist for Takusen. I'm hoping the 
 documentation for Database.Enumerator is a reasonable place to start.
 http://darcs.haskell.org/takusen/doc/html/Database-Enumerator.html
 
 I just reviewed the Takusen code and, for no apparent reason, the ODBC module 
 specifies unsafe for all of its FFI imports, but the other modules do not (so 
 they get the default, which I assume is safe). I also was not aware of unsafe 
 calls blocking other threads. I'll change the ODBC imports to be safe (or 
 rather, unspecified).

Makes sense.  I will make the similar change in all HDBC backends.

-- John

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


Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Günther Schmidt

Hi guys,

I just tried to forkIO-off the database code to keep the UI responsive  
using Takusen with Sqlite this time.


The problem persists though, the UI freezes.

AFAIK the sqlite-Takusen code does not use unsafe ccall which would block  
the thread, so that might not be the cause of the problem after all.


Before you guys make the effort to fix this you might see if you can  
reproduce the problem maybe uploading a 50 MB file into an Sqlite  
database, for instance, or something else that will keep the database busy  
for some time in a row.


I did not use -threaded and forkOS though.

Günther



Am 22.12.2008, 21:59 Uhr, schrieb John Goerzen jgoer...@complete.org:


On Mon, Dec 22, 2008 at 04:28:03PM -, Bayley, Alistair wrote:

 From: haskell-cafe-boun...@haskell.org
 [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Günther Schmidt

 I understand that Takusen does not use unsafe calls and
 would like to
 try it with that one then, but haven't find enough docs yet
 on how to use
 Takusen.

Not a lot of detailed examples exist for Takusen. I'm hoping the  
documentation for Database.Enumerator is a reasonable place to start.

http://darcs.haskell.org/takusen/doc/html/Database-Enumerator.html

I just reviewed the Takusen code and, for no apparent reason, the ODBC  
module specifies unsafe for all of its FFI imports, but the other  
modules do not (so they get the default, which I assume is safe). I  
also was not aware of unsafe calls blocking other threads. I'll change  
the ODBC imports to be safe (or rather, unspecified).


Makes sense.  I will make the similar change in all HDBC backends.

-- John




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


Re: [Haskell-cafe] Pattern combinators

2008-12-22 Thread David Menendez
On Sun, Dec 21, 2008 at 10:14 PM, Andrew Wagner wagner.and...@gmail.com wrote:
 I'd love to see a copy of this go up on hackage for experimentation. Would
 you care to upload your code, or send it to me so I can upload it?

I've uploaded my latest version to http://hpaste.org/13263. It
explicitly makes patterns polymorphic over the answer type of the case
statement by making Pattern a newtype and universally quantifying the
(un)currying and matching functions.

For example,

(-) :: Pattern a () vec - Curry vec ans - Case a ans


I'm not sure it makes sense to create a package just yet. At the very
least, you should ask Morten Rhiger first. The type signatures are
mine, but the code is mostly straight transcriptions from his paper.

-- 
Dave Menendez d...@zednenem.com
http://www.eyrie.org/~zednenem/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Duncan Coutts
On Mon, 2008-12-22 at 22:12 +0100, Günther Schmidt wrote:
 Hi guys,
 
 I just tried to forkIO-off the database code to keep the UI responsive  
 using Takusen with Sqlite this time.
 
 The problem persists though, the UI freezes.

You might need to provide us more details on the GUI code. As I
understand if you're using gtk2hs. You need to make sure that you're not
blocking the GUI event loop by making blocking calls in event handlers.
All blocking stuff has to be run via forkIO and the event handler must
be allowed to return so that Gtk+ can redraw windows etc.

In this context, by blocking I mean blocking a single Haskell thread,
which is of course different from the safe/unsafe foreign calls which
blocks a whole OS thread and thus all the Haskell threads.

Duncan

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


Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Günther Schmidt

Hi,

I put in on hpaste:

http://hpaste.org/13264

slightly simplified

Günther

Am 22.12.2008, 22:36 Uhr, schrieb Duncan Coutts  
duncan.cou...@worc.ox.ac.uk:



On Mon, 2008-12-22 at 22:12 +0100, Günther Schmidt wrote:

Hi guys,

I just tried to forkIO-off the database code to keep the UI responsive
using Takusen with Sqlite this time.

The problem persists though, the UI freezes.


You might need to provide us more details on the GUI code. As I
understand if you're using gtk2hs. You need to make sure that you're not
blocking the GUI event loop by making blocking calls in event handlers.
All blocking stuff has to be run via forkIO and the event handler must
be allowed to return so that Gtk+ can redraw windows etc.

In this context, by blocking I mean blocking a single Haskell thread,
which is of course different from the safe/unsafe foreign calls which
blocks a whole OS thread and thus all the Haskell threads.

Duncan




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


[Haskell-cafe] Stupid question #374: why is MaybeT not in the standard library?

2008-12-22 Thread Brian Hurt


I wrote my own implementation of MaybeT (which was a usefull exercise), 
but a quick google showed:


http://www.haskell.org/haskellwiki/New_monads/MaybeT

But I'm wondering why it's not in the standard library.  The standards 
committee just hasn't gotten around to it yet?  Or was there some 
discussion of this in the past on some (public) maillist, that my 
admittedly shallow googling failed to uncover, that someone could point me 
at?


Thanks.

Brian

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


Re: [Haskell-cafe] concurrent haskell: thread priorities

2008-12-22 Thread Thomas DuBuisson

 It seems like we could get some priority based scheduling (and still be
 slackers) if we allow marked green threads to be strictly associated with a
 specific OS thread (forkChildIO?).


I think you want the GHC-only GHC.Conc.forkOnIO

Suggestions like this are more motivation for the suggestion [1] to adopt a
re-engineered / haskell-based RTS [2].

Tom

[1]
http://www.reddit.com/r/haskell_proposals/comments/7itaz/simple_robust_maintainable_rts_for_ghc_io_pdf/
[2] http://www.seas.upenn.edu/~lipeng/homepage/papers/lmpjt07hw.pdf
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The Haskell re-branding exercise

2008-12-22 Thread Isaac Dupree
(responding with just a bit of possibly relevant context, 
not always directly)


Paul Johnson wrote:
I've lived through a couple of corporate rebranding exercises in my time, and 
I've read about some others.  They follow a pattern:

...
   2. The new branding is released with as much fanfare as possible.  Press
  releases are released.  Staff are given briefings about the significance
  of the whole exercise and the bold new future that it symbolises.


I don't think our choice of logo is quite as significant as 
a corporate logo.  We could even use more than one logo if 
we wanted (maybe different people or different places).  The 
current logo is prominent on the haskell.org (and 
wikipedia), mainly... places I rarely see, when working on 
Haskell.


I see a couple things people are trying to do

- Self-descriptive, without trying to change the way we are 
as a community or a language


- Inviting to newcomers, mostly independent of how we 
actually work (although better if we advertize things we can 
actually provide, of course)


I don't think it's trying to create a change in the language 
or the community, mostly it's to reflect the change that has 
already happened.



   3. The staff universally agree that the new logo is not a patch on the old
  one.  The old one was a much loved friend; it stood for something; people
  have spent years working for it.  The new one is obviously a piece of
  cheap gimcrackery


yup, I'll miss the old logo.  To me, it still looks 
beautiful, clean and fitting.


A paradox of the Haskell world is that, while the language is Vulcan, the 
community around it is dominated by Warm Fuzziness.  Clearly the two are not 
mutually exclusive.


nice observation!

A rebranding exercise needs to start with a short list of adjectives that the 
brand is to represent,


good idea... although we could just be attracted by whatever 
proposed logo happens to have beauty instead, if our only 
purpose is not to be stuck with an ugly logo.


and I think that the Haskell community needs to decide 
this before it fires up Inkscape.


or in parallel with :-) -- random creativity can help us 
start thinking about what we don't want to see, and why we 
don't want to see it, too


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


Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Sterling Clover
Thanks John! I've been running into this quite a bit with the ODBC backend
as well. Having an entire server app freeze because MS SQL Server decides to
deadlock is rather unpleasant.
Cheers,
Sterl.

On Mon, Dec 22, 2008 at 3:59 PM, John Goerzen jgoer...@complete.org wrote:

 On Mon, Dec 22, 2008 at 04:28:03PM -, Bayley, Alistair wrote:
   From: haskell-cafe-boun...@haskell.org
   [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Günther Schmidt
  
   I understand that Takusen does not use unsafe calls and
   would like to
   try it with that one then, but haven't find enough docs yet
   on how to use
   Takusen.
 
  Not a lot of detailed examples exist for Takusen. I'm hoping the
 documentation for Database.Enumerator is a reasonable place to start.
  http://darcs.haskell.org/takusen/doc/html/Database-Enumerator.html
 
  I just reviewed the Takusen code and, for no apparent reason, the ODBC
 module specifies unsafe for all of its FFI imports, but the other modules do
 not (so they get the default, which I assume is safe). I also was not aware
 of unsafe calls blocking other threads. I'll change the ODBC imports to be
 safe (or rather, unspecified).

 Makes sense.  I will make the similar change in all HDBC backends.

 -- John

 ___
 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] Stupid question #374: why is MaybeT not in the standard library?

2008-12-22 Thread Luke Palmer
On Mon, Dec 22, 2008 at 3:31 PM, Brian Hurt bh...@spnz.org wrote:


 I wrote my own implementation of MaybeT (which was a usefull exercise), but
 a quick google showed:

 http://www.haskell.org/haskellwiki/New_monads/MaybeT

 But I'm wondering why it's not in the standard library.  The standards
 committee just hasn't gotten around to it yet?  Or was there some discussion
 of this in the past on some (public) maillist, that my admittedly shallow
 googling failed to uncover, that someone could point me at?


Yeah, it'd be useful.  Doesn't really matter, though, because it's on
Hackage (http://hackage.haskell.org), so it's just a cabal install MaybeT
 away.

Now that cabal and cabal-install are reasonably mature, we really don't have
to worry about what's blessed as standard anymore.  :-)

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


Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Duncan Coutts
On Mon, 2008-12-22 at 22:55 +0100, Günther Schmidt wrote:
 Hi,
 
 I put in on hpaste:
 
 http://hpaste.org/13264
 
 slightly simplified

Ok, that works fine when the action is something like threadDelay so
it's clearly not blocking the UI.

Duncan

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


Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread GŸuenther Schmidt

Hi Duncan,

are you saying then that the db-code is what's blocking the UI?

Günther

Duncan Coutts schrieb:

On Mon, 2008-12-22 at 22:55 +0100, Günther Schmidt wrote:
  

Hi,

I put in on hpaste:

http://hpaste.org/13264

slightly simplified



Ok, that works fine when the action is something like threadDelay so
it's clearly not blocking the UI.

Duncan

  



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


Re: [Haskell-cafe] The Haskell re-branding exercise

2008-12-22 Thread Eelco Lempsink

On 22 dec 2008, at 19:14, Loup Vaillant wrote:

2008/12/22 Eelco Lempsink ee...@lempsink.nl:

Hmm, right.  I started on a thing in HAppS.  See
http://github.com/eelco/voting/ for the source code (contributors  
more than
welcome!) and http://code.tupil.com/voting/ for a live demo.  It  
relies
heavily on javascript, needs some work on the UI and there are a  
lot of

features that could be added, but it works.


Great.
Could it be further hacked to accept ties, as suggested by Sebastian?
Something like:

thingie1 thingie1bis
thingie3
thingie4 thingie4bis



Yes.  Done.  It's quite tricky to get the dragging and dropping  
interface to work nice, but I think I'm getting close.  If anybody  
with jQuery experience has some ideas how to improve it, please do :)


--
Regards,

Eelco Lempsink



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


Re: [Haskell-cafe] A hell of a question

2008-12-22 Thread Jason Dusek
2008/12/22 Luke Palmer lrpal...@gmail.com:
 Andrzej Jaworski hims...@poczta.nom.pl
  First let me disassociate Haskell from Taoism...

 I associate Haskell with Zen...

  The relationship between Taoism and Zen is actually very
  close. The notion of stillness practice is essentially
  Chinese. Indian schools of meditation and schools of Buddhism
  not originating in China, tend to emphasize an /object/ of
  meditation -- a God, a candle, what-have-you. The practice of
  sitting still, doing nothing finds its way into Buddhism
  when Chan Buddhism is formed in China. It is an adaption of a
  Taoist practice with a long history -- and in fact, Chan was
  seen as a Taoist renewal. It is Chan that makes its way to
  Japan to become the Zen we all know.

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


Re: [Haskell-cafe] A hell of a question

2008-12-22 Thread Jason Dusek
Andrzej Jaworski hims...@poczta.nom.pl wrote:
 First let me disassociate Haskell from Taoism which to may
 taste has left us in an unhealthy climate.  It suffices to say
 that Taoism is a school of clever trics and cute aphorisms but
 without the slightest attempt to explain or generalize let
 alone produce an abstract idea or a system. That is why its
 wisdom is non transferable in spite of majority of humans
 desending from it.

  Taoist religion in China is very much a popular religion,
  closely associated with festivals, weddings and magic tricks.
  As a popular religion, Taoism is indeed deeply compromised;
  but then again, so is Zen in Japan, Christianity in Europe and
  indeed, most popular religions in the place where they became
  popular.

  As a philosophy, Taoism is more concerned with doubt than
  knowledge; with humility than pride of understanding; of
  course it makes litte attempt to explain or generalize.
  An essential notion in Taoism is that signs and symbols do not
  communicate the truth -- to appreciate Taoist practice, you
  must engage in the practice of Taoism for a spell. Thus it is
  in practical arts -- Chinese medicine, Taiji, strategy -- that
  one comes to appreciate the Way and its Power.

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


Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread Ryan Ingram
You shouldn't need forkOS, but without -threaded (and related RTS
switches to enable multithreading) I think you are sunk.  Without
enabling multithreading support, you are saying that your program
(which might use concurrency features of Haskell) will run on a single
OS thread.  During a foreign call that never calls back into Haskell,
then, there's no place for the RTS to pre-empt and switch back to
Haskell code.

It's kind of confusing with multiple things named threads; call a
Haskell thread a lightweight thread, and an OS thread a heavy
thread.  Each heavy thread can either be executing Haskell lightweight
threads, or inside a foreign out-call.  Once you jump across to
foreign-land, the heavy thread can't do anything (even for a safe
out-call) until the out-call either makes an in-call back into Haskell
code, or returns.

Enabling -threaded allows the Haskell runtime to create more heavy
threads; even without -threaded you can make as many lightweight
threads as you like and the runtime will handle scheduling them for
you; a heavy thread can carry many light threads.  But a foreign call
takes a whole heavy thread no matter what.

  -- ryan

On Mon, Dec 22, 2008 at 1:12 PM, Günther Schmidt red...@fedoms.com wrote:
 Hi guys,

 I just tried to forkIO-off the database code to keep the UI responsive using
 Takusen with Sqlite this time.

 The problem persists though, the UI freezes.

 AFAIK the sqlite-Takusen code does not use unsafe ccall which would block
 the thread, so that might not be the cause of the problem after all.

 Before you guys make the effort to fix this you might see if you can
 reproduce the problem maybe uploading a 50 MB file into an Sqlite database,
 for instance, or something else that will keep the database busy for some
 time in a row.

 I did not use -threaded and forkOS though.

 Günther



 Am 22.12.2008, 21:59 Uhr, schrieb John Goerzen jgoer...@complete.org:

 On Mon, Dec 22, 2008 at 04:28:03PM -, Bayley, Alistair wrote:

  From: haskell-cafe-boun...@haskell.org
  [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Günther Schmidt
 
  I understand that Takusen does not use unsafe calls and
  would like to
  try it with that one then, but haven't find enough docs yet
  on how to use
  Takusen.

 Not a lot of detailed examples exist for Takusen. I'm hoping the
 documentation for Database.Enumerator is a reasonable place to start.
 http://darcs.haskell.org/takusen/doc/html/Database-Enumerator.html

 I just reviewed the Takusen code and, for no apparent reason, the ODBC
 module specifies unsafe for all of its FFI imports, but the other modules do
 not (so they get the default, which I assume is safe). I also was not aware
 of unsafe calls blocking other threads. I'll change the ODBC imports to be
 safe (or rather, unspecified).

 Makes sense.  I will make the similar change in all HDBC backends.

 -- John



 ___
 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] A hell of a question

2008-12-22 Thread Jonathan Cast
On Mon, 2008-12-22 at 17:14 -0800, Jason Dusek wrote:
 Andrzej Jaworski hims...@poczta.nom.pl wrote:
  First let me disassociate Haskell from Taoism which to may
  taste has left us in an unhealthy climate.  It suffices to say
  that Taoism is a school of clever trics and cute aphorisms but
  without the slightest attempt to explain or generalize let
  alone produce an abstract idea or a system. That is why its
  wisdom is non transferable in spite of majority of humans
  desending from it.

 ...

   Thus it is
   in practical arts -- Chinese medicine, Taiji, strategy -- that
   one comes to appreciate the Way and its Power.

But nonetheless, Haskell is not a practical art, no more than
theoretical physics or abstract algebra.

jcc


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


Re: [Haskell-cafe] A hell of a question

2008-12-22 Thread Jason Dusek
Jonathan Cast jonathancc...@fastmail.fm wrote:
 Jason Dusek wrote:
  Thus it is in practical arts -- Chinese medicine, Taiji,
  strategy -- that one comes to appreciate the Way and its
  Power.

 But nonetheless, Haskell is not a practical art, no more than
 theoretical physics or abstract algebra.

  I guess the question is whether we are treating Haskell as a
  means to appreciate Taoism or as Taoism itself.

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


Re: [Haskell-cafe] Stupid question #374: why is MaybeT not in the standard library?

2008-12-22 Thread Antoine Latter
2008/12/22 Luke Palmer lrpal...@gmail.com:
 Yeah, it'd be useful.  Doesn't really matter, though, because it's on
 Hackage (http://hackage.haskell.org), so it's just a cabal install
 MaybeT away.
 Now that cabal and cabal-install are reasonably mature, we really don't have
 to worry about what's blessed as standard anymore.  :-)

Although I still had to use my own because I wanted a MonadPlus
instance.  I would offer a patch, but since there's more than one
useful MonadPlus instance for MaybeT it probably still wouldn't be
right for everyone.

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


Re: [Haskell-cafe] Cabal Install Links to Source from Haddock Docs

2008-12-22 Thread R Hayes


Thank you.  As it turns out, I was aware of that recipe.  What I  
wanted was to be able to use cabal install's nice dependency following  
features and still get source links in my documentation.


Personally, I feel that inclusion of source and docs should be the  
DEFAULT for cabal, as well as for binary distributions of ghc.


-rhayes

On Dec 21, 2008, at 1:11 AM, Thomas Hartman wrote:


the answer: not cabal install, just cabal.

thart...@thartman-laptop:~/haskellInstalls/smallInstalls/ 
pureMD5-0.2.3
thart...@thartman-laptop:~/haskellInstalls/smallInstalls/ 
pureMD5-0.2.3cabal

--help | grep -i doc
haddock  Generate Haddock HTML documentation.
thart...@thartman-laptop:~/haskellInstalls/smallInstalls/ 
pureMD5-0.2.3cabal

haddock --help | grep -i link
  --hyperlink-source Hyperlink the documentation to the source  
code
thart...@thartman-laptop:~/haskellInstalls/smallInstalls/ 
pureMD5-0.2.3cabal

haddock --hyperlink-source

2008/12/21 R Hayes rfha...@reillyhayes.com:


Is there a way I can get Haddock Docs WITH links to source (local)  
from

modules installed with cabal install xxx?

Getting the docs themselves is pretty easy by changing either
~/.cabal/config or using --enable-documentation.

Automatically generating the source (colourised or not) and  
integrated links

eludes me.

-r
___
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] Re: Is this related to monomorphism restriction?

2008-12-22 Thread Iavor Diatchki
Hi,

On Sun, Dec 21, 2008 at 11:45 AM, Luke Palmer lrpal...@gmail.com wrote:
 2008/12/21 Iavor Diatchki iavor.diatc...@gmail.com


 g :: TestClass a = a - Integer
 g = fst (a :: (a - Integer, a - Integer))

 Which I believe needs to be written:

 g :: forall a. TestClass a = a - Integer
 g = fst (a :: (a - Integer, a - Integer))


quite right!  sorry for not testing my code.
-iavor



 Here we are using another GHC extension called scoped type variables
 to associate the a in the type signature of g with the a in the
 type annotation for the value a.

 Hope that this helps,
 Iavor




 On Sun, Dec 21, 2008 at 9:21 AM, Maurí­cio briqueabra...@yahoo.com
 wrote:
  Why isn't the last line of this code allowed?
  f :: (TestClass a) = a - Integer
  f = const 1
  a = (f,f)
  g = fst a
  The only thing I can think about is monomorphism
  restriction, but it's allowed (...)
 
  (...) The reason is that a has type
  a :: (TestClass a, TestClass b) = (a,b)
  and then when we take 'fst' of this value (as in g) we get
 
  g :: (TestClass a, TestClass b) = a
  which is an ambiguous type, (...)
 
  Is there some version (i.e., set of extensions) of
  Haskell where this would be allowed?
 
  ___
  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] Time for a new logo?

2008-12-22 Thread ksvanhorn

Looking over the New_logo_ideas page, my vote is for the snowflake logo:

http://haskell.org/sitewiki/images/9/98/Haskell-Symstar.png

(I would simplify it, though, by removing the motto pure - lazy - fun.)

I like this logo because it works well on two different levels.  For those
in the know, the lambda and = symbols suggest monads and first-class
functions, two important features of the language.  For those unfamiliar
with Haskell or functional programming, the logo still looks pretty cool and
manages to suggest mathematical beauty.
-- 
View this message in context: 
http://www.nabble.com/Time-for-a-new-logo--tp21004746p21138458.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] Re: Threads with high CPU usage

2008-12-22 Thread Günther Schmidt

Hi Ryan,

BINGO!

that did it.

Thanks a lot. It certainly works now, finally, eventhough I don't really  
know what the implications are.


Günther

Am 23.12.2008, 02:14 Uhr, schrieb Ryan Ingram ryani.s...@gmail.com:


You shouldn't need forkOS, but without -threaded (and related RTS
switches to enable multithreading) I think you are sunk.  Without
enabling multithreading support, you are saying that your program
(which might use concurrency features of Haskell) will run on a single
OS thread.  During a foreign call that never calls back into Haskell,
then, there's no place for the RTS to pre-empt and switch back to
Haskell code.

It's kind of confusing with multiple things named threads; call a
Haskell thread a lightweight thread, and an OS thread a heavy
thread.  Each heavy thread can either be executing Haskell lightweight
threads, or inside a foreign out-call.  Once you jump across to
foreign-land, the heavy thread can't do anything (even for a safe
out-call) until the out-call either makes an in-call back into Haskell
code, or returns.

Enabling -threaded allows the Haskell runtime to create more heavy
threads; even without -threaded you can make as many lightweight
threads as you like and the runtime will handle scheduling them for
you; a heavy thread can carry many light threads.  But a foreign call
takes a whole heavy thread no matter what.

  -- ryan

On Mon, Dec 22, 2008 at 1:12 PM, Günther Schmidt red...@fedoms.com  
wrote:

Hi guys,

I just tried to forkIO-off the database code to keep the UI responsive  
using

Takusen with Sqlite this time.

The problem persists though, the UI freezes.

AFAIK the sqlite-Takusen code does not use unsafe ccall which would  
block

the thread, so that might not be the cause of the problem after all.

Before you guys make the effort to fix this you might see if you can
reproduce the problem maybe uploading a 50 MB file into an Sqlite  
database,
for instance, or something else that will keep the database busy for  
some

time in a row.

I did not use -threaded and forkOS though.

Günther



Am 22.12.2008, 21:59 Uhr, schrieb John Goerzen jgoer...@complete.org:


On Mon, Dec 22, 2008 at 04:28:03PM -, Bayley, Alistair wrote:


 From: haskell-cafe-boun...@haskell.org
 [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Günther  
Schmidt


 I understand that Takusen does not use unsafe calls and
 would like to
 try it with that one then, but haven't find enough docs yet
 on how to use
 Takusen.

Not a lot of detailed examples exist for Takusen. I'm hoping the
documentation for Database.Enumerator is a reasonable place to start.
http://darcs.haskell.org/takusen/doc/html/Database-Enumerator.html

I just reviewed the Takusen code and, for no apparent reason, the ODBC
module specifies unsafe for all of its FFI imports, but the other  
modules do
not (so they get the default, which I assume is safe). I also was not  
aware
of unsafe calls blocking other threads. I'll change the ODBC imports  
to be

safe (or rather, unspecified).


Makes sense.  I will make the similar change in all HDBC backends.

-- John




___
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] Re: Threads with high CPU usage

2008-12-22 Thread John Goerzen
Günther Schmidt wrote:
 Hi Ryan,
 
 BINGO!
 
 that did it.
 
 Thanks a lot. It certainly works now, finally, eventhough I don't really  
 know what the implications are.

Did it still work with the unmodified HDBC as well?  Just curious.

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


Re: [Haskell-cafe] Re: Threads with high CPU usage

2008-12-22 Thread wman
Thanks to you all for inspiration.

My web app (which otherwise ran ok) was getting stuck while getting harassed
by ab (apache-benchmark) after receiving some 800+ requests in short
succession (not less, never gotten to 900, what was weird that running like
500 reqs - pause - 500 reqs ... went ok).

After compiling with -threaded and running with +RTS -N2 it handles 10k+
requests (with 10 concurrent request running at once) without missing a
beat.

Well, at least I double checked everything else ;-)))
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Takusen

2008-12-22 Thread Artyom Shalkhakov
Hi Günther,

2008/12/22 Günther Schmidt red...@fedoms.com:
 where can I find some sample code or other examples to familiarize me with
 Takusen?

The best resource I've found is:

http://darcs.haskell.org/takusen/doc/html/Database-Enumerator.html

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


[Haskell-cafe] intercalate and (byte)strings

2008-12-22 Thread wman
I encountered the following code :

-- B == Data.ByteString ; L == Data.ByteString.Lazy
contents' = B.intercalate B.empty $ L.toChunks contents

with a previously unencountered function intercalate. A quick google query
later i knew that it's just intersperse  concat nicely bundled and started
wondering why anybody would do this, as simple

contents' = B.concat $ L.toChunks contents

would do (probably nearly) the same. The only thing I am able to come up
with is that it somehow helps streamline the memory usage (if it has some
meaning).

Is there some reason to use intercalate empty list instead of concat
list (probably when dealing with non-lazy bytestrings) ?

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


[Haskell-cafe] [Byte8] - ByteString

2008-12-22 Thread Galchin, Vasili
Hello,

  I have been reading through Data-ByteString. What is the is most
elegant and efficient way to map/unmap [Byte8] - ByteString?

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


Re: [Haskell-cafe] [Byte8] - ByteString

2008-12-22 Thread Luke Palmer
2008/12/22 Galchin, Vasili vigalc...@gmail.com

 Hello,

   I have been reading through Data-ByteString. What is the is most
 elegant and efficient way to map/unmap [Byte8] - ByteString?


pack and unpack.  You might need a fromIntegral in there, depending on
whether Byte8 and Word8 are the same.

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


Re: [Haskell-cafe] Stupid question #374: why is MaybeT not in the standard library?

2008-12-22 Thread Luke Palmer
On Mon, Dec 22, 2008 at 6:52 PM, Antoine Latter aslat...@gmail.com wrote:

 2008/12/22 Luke Palmer lrpal...@gmail.com:
  Yeah, it'd be useful.  Doesn't really matter, though, because it's on
  Hackage (http://hackage.haskell.org), so it's just a cabal install
  MaybeT away.
  Now that cabal and cabal-install are reasonably mature, we really don't
 have
  to worry about what's blessed as standard anymore.  :-)

 Although I still had to use my own because I wanted a MonadPlus
 instance.  I would offer a patch, but since there's more than one
 useful MonadPlus instance for MaybeT it probably still wouldn't be
 right for everyone.


There are?  The only two I can think of are the left-biased and its dual, in
which case the convention is to choose the left-biased one.  Is there
another?

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


Re: [Haskell-cafe] Stupid question #374: why is MaybeT not in the standard library?

2008-12-22 Thread J. Garrett Morris
On Mon, Dec 22, 2008 at 2:31 PM, Brian Hurt bh...@spnz.org wrote:
 But I'm wondering why it's not in the standard library.  The standards
 committee just hasn't gotten around to it yet?  Or was there some discussion
 of this in the past on some (public) maillist, that my admittedly shallow
 googling failed to uncover, that someone could point me at?

It's equivalent to ErrorT ()  - but ErrorT String is almost always a
better option anyway.

 /g

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


Re: [Haskell-cafe] [Byte8] - ByteString

2008-12-22 Thread Galchin, Vasili
sorry actually ByteString - [Word8]




On Tue, Dec 23, 2008 at 12:49 AM, Luke Palmer lrpal...@gmail.com wrote:

 2008/12/22 Galchin, Vasili vigalc...@gmail.com

 Hello,

   I have been reading through Data-ByteString. What is the is most
 elegant and efficient way to map/unmap [Byte8] - ByteString?


 pack and unpack.  You might need a fromIntegral in there, depending on
 whether Byte8 and Word8 are the same.

 Luke


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