[Haskell-cafe] Re: hmatrix

2008-06-03 Thread Alberto Ruiz

Anatoly Yakovenko wrote:

do you have any plans to provide an interface for inplace updates?

Yes, I will try to write a simple version of Data.Array.ST...



I can try to help you, although I still dont quite grok monads.
Wouldn't it be more efficient to use StorableArray, so you can cast
from and to C?  I am not sure how vectors and matrixes are represented
in C, but I imagine it should be possible to manipulate them without
resorting to copying between haskell and C.

That's right, the correspondence with StorableArray is direct, and 
efficient conversion can be easily added to the library. I mentioned the 
idea of Data.Array.ST to have also the possibility of writing pure code, 
without IO, internally implemented with inplace updates.


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


Re: [Haskell-cafe] Re: hmatrix

2008-06-03 Thread Bulat Ziganshin
Hello Alberto,

Tuesday, June 3, 2008, 11:27:54 AM, you wrote:

 Yes, I will try to write a simple version of Data.Array.ST...
 That's right, the correspondence with StorableArray is direct, and
 efficient conversion can be easily added to the library. I mentioned the
 idea of Data.Array.ST to have also the possibility of writing pure code,
 without IO, internally implemented with inplace updates.

STRef/STArray operations are just IORef/IOArray operations imported in
some way/ you can easily import any other operations to ST monad as
far as you use rank-2 types to guarantee that impureness will not
escape the runST call. look into unsafeIOtoST function

providing unmovable STUArray variant may be a good idea


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Re: hmatrix

2008-06-03 Thread Alberto Ruiz

Bulat Ziganshin wrote:

Hello Alberto,

Tuesday, June 3, 2008, 11:27:54 AM, you wrote:


Yes, I will try to write a simple version of Data.Array.ST...

That's right, the correspondence with StorableArray is direct, and
efficient conversion can be easily added to the library. I mentioned the
idea of Data.Array.ST to have also the possibility of writing pure code,
without IO, internally implemented with inplace updates.


STRef/STArray operations are just IORef/IOArray operations imported in
some way/ you can easily import any other operations to ST monad as
far as you use rank-2 types to guarantee that impureness will not
escape the runST call. look into unsafeIOtoST function


Good! So you can easily hide the IO operations in the ST monad. I will 
definitely look into it.



providing unmovable STUArray variant may be a good idea




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


Re: [Haskell-cafe] ghc 6.8.2 issue

2008-06-03 Thread Duncan Coutts

On Mon, 2008-06-02 at 23:11 -0500, Galchin, Vasili wrote:
 at this point rebuild and install the unix package ...
 
 [EMAIL PROTECTED]:~/FTP/Haskell/bytestring-mmap-0.2.0$ runhaskell
 Setup.lhs clean
 cleaning...
 [EMAIL PROTECTED]:~/FTP/Haskell/bytestring-mmap-0.2.0$ runhaskell
 Setup.lhs configure
 Configuring bytestring-mmap-0.2.0...
 [EMAIL PROTECTED]:~/FTP/Haskell/bytestring-mmap-0.2.0$ runhaskell
 Setup.lhs build
 Setup.lhs: error reading dist/setup-config; run setup configure
 command?
 
 dist/setup-config is not being populated at the end. In your
 response below, are you saying that teh segfaults occur because ghc
 itself relies on the unix package?

Something like that yes.

You're running runhaskell Setup.lhs and that loads and runs code from
the Cabal library. The Cabal library depends on the process library
which depends on the unix library. So by replacing the same version of
the unix package you're breaking everything else which depends on it,
including Cabal and thus runhaskell Setup.lhs.

So the solution is to not do that. Don't re-install the exact same
version of any of the core libs that come with ghc. Adding new versions
is fine, replacing existing versions is not fine because it breaks all
the other packages that were already built against that package.

Duncan

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


Re: [Haskell-cafe] [ANN] bloomfilter 1.0 - Fast immutable and mutable Bloom filters

2008-06-03 Thread Ketil Malde
Thomas Hartman [EMAIL PROTECTED] writes:

 What kind of speed do you get on your laptop for Data.Set? How much
 faster is the bloom filter?

I tried to modify examples/Words.hs to use Data.Set insted.  The
results look like this (first Bloom, second Data.Set, both compiled
with -O2):

nmd:..filter/examples % ./Words   
57025 words
0.013326ss to count words
Bloom { 4194304 bits } 
0.050608ss to construct filter
0.034806ss to query every element

nmd:..filter/examples % ./WordsS
57025 words
0.013291ss to count words
False
0.755115ss to construct filter
0.423289ss to query every element

In order to avoid printing the entire set, while still evaluating it,
I replaced the printing of the set with printing the result of a
search for a non-existing element - I should really use a strict
insert, I guess.  Anyway, this hopefully gives an indication - looks
like a factor of 10 in this case, but it will depend on the size of
the data - more data, greater improvement.

BTW, Nice work, Bryan!  I have plans for this.

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ghc 6.8.2 issue

2008-06-03 Thread Duncan Coutts

On Tue, 2008-06-03 at 00:04 -0500, Galchin, Vasili wrote:
 Duncan,
 
  By installing localling, I runhaskell Setup.hs configure
 --prefix=$HOME plus add local path to LD_LIBRARY_PATH and
 LD_RUN_PATH? On Linux, does ghc use .so's or is it linked statically?

ghc is linked statically but when you do things like runhaskell Setup.hs
you're asking ghc to dynamically load packages. runhaskell/runghc is
basically a form of ghci, and ghci does dynamic code loading. If you've
broken some of the packages that ghci loads and runs code from then
you'll run into problems, mysterious segfaults and the like.

As I understand it, in the next version of ghc it will track the ABI of
each package so we would be able to detect when people replace packages
with ones with the same version but with a different ABI (as you've been
doing) and refuse to link or run in those cases rather than running and
ending up with segfaults.

Duncan

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


[Haskell-cafe] Re: appending an element to a list

2008-06-03 Thread apfelmus

Abhay Parvate wrote:

I somehow thought it would be easy to talk about complexity of calculating
individual elements in an infinite list should be sufficient, but that seems
to be involved, and my over-generalization doesn't seem to work. Thanks for
the link; particularly it has reference to Wadler's papers exactly on this
problem.


Note however that Wadler's and similar formalisms are still a 
unsatisfactory in that they are quite clumsy to work with, it's quite 
tedious/impossible to analyze examples with a lot of lazy evaluation. 
But they are a good guideline.


In his book about purely functional data structures [1], Okasaki takes a 
different approach; each node of a data structure is given a debit, a 
cost to evaluate it. For instance, consider


  xs = x1 : x2 : x3 : ... : xn : []
  111 ... 11  0

  ys = y1 : y2 : y3 : ... : ym : []
  111 ... 11  0

The numbers below indicate the time it takes to evaluate the node to 
weak head normal form. For demonstration purposes, I arbitrarily chose 1 
for each (:) here.


The combined list will then have debits like

  xs ++ ys = x1 : x2 : x3 : ... : xn : y1 : y2 : y3 : ... : ym : []
222 ... 22111 ... 11  0

In other words, the ys list is copied verbatim but each element of xs 
incurs an additional cost of 1, corresponding to one step in the 
evaluation of the concatenation with (++).


In order to force/inspect a constructor/node, you have to pay off its 
debits first. In the above example,  head (xs ++ ys)  would have to pay 
2 units of time (one unit for  head xs  and one for the (++)). Now, the 
thing about debits is that we can relocate them to the top and only 
overestimate the total running time if we do that. For instance, we 
could push all debits to the top


  xs ++ ys = x1   : x2 : x3 : ... : xn : y1 : y2 : y3 : ... : ym : []
2n+m   00 ... 00000 ... 00  0

so that evaluating  head (xs ++ ys)  is now estimated to cost (2n+m) 
units of time while the rest is free/fully evaluated.


The above example is rather useless, but consider the case  n == m  and

  xs = x1 : x2 : x3 : ... : xn : []
  000 ... 00  0

  ys = y1 : y2 : y3 : ... : yn : []
  000 ... 00  0

i.e. two fully evaluated lists of the same length. Then, we have

  xs ++ reverse ys =
 x1 : x2 : x3 : ... : xn : yn : y{n-1} : ... : y1 : []
111 ... 11n0 ... 00  0

because reversing the list ys is monolithic, i.e. looking at its  head 
 already forces the tail of the list. But now, we can distribute the 
debits upwards


  xs ++ reverse ys =
 x1 : x2 : x3 : ... : xn : yn : y{n-1} : ... : y1 : []
222 ... 2200 ... 00  0

and thereby amortize the cost of reversing the second lists over the n 
elements of the first list. This is used in the implementation of purely 
functional queues, see also Okasaki's book.



[1]: Chris Okasaki. Purely Function Data Structures.
 http://www.cs.cmu.edu/~rwh/theses/okasaki.pdf
 (This is the thesis on which the book is based.)


Regards,
apfelmus

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


Re[2]: [Haskell-cafe] Re: hmatrix

2008-06-03 Thread Bulat Ziganshin
Hello Alberto,

Tuesday, June 3, 2008, 12:56:50 PM, you wrote:

 Good! So you can easily hide the IO operations in the ST monad. I will
 definitely look into it.

from implementation POV ST monad is nothing but renamed IO monad which
exports only subset of its operations which are guaranteed to safe.
or, saying in other words, it's just type hackery around IO monad that
provides safe operations

it's possible to define ST monad and its operations as following:

newtype ST s a = forall s. ST_Constructor (IO a)

unsafeIOtoSt action = ST_Constructor action

runST (ST_Constructor action) = unsafePerformIO action

newtype STRef s a = forall s. STRef (IORef a)

readSTRef (STRef ref)  =  unsafeIOtoSt (readIORef ref)

and so on. GHC uses technically (but not ideologically!) different
implementation where both monads are specializations of one generic
type. while Hugs afair uses exactly this approach. you may also look
at ArrayRef lib which reimplements arrays/refs for both compilers in
more unified way

anyway, because ST is just IO monad modulo type tricks, you can
execute any IO action inside ST by lifting it with unsafeIOtoSt

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Rotating backdrop (aka learning Haskell)

2008-06-03 Thread Yann Golanski
First version is available at:
  http://www.kierun.org/backdropper-1.0.tbz2
It is minimal but does the trick of randomly rotating backgrounds.

Features to add are only rotate during work hours, making sure that all
images are shown within a day and a nice GUI. 

Criticism welcome.

-- 
[EMAIL PROTECTED] -= H+ =- www.kierun.org
   PGP:   009D 7287 C4A7 FD4F 1680  06E4 F751 7006 9DE2 6318


pgp1DQpdVc35O.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Implementing ParseChart with Data.Map

2008-06-03 Thread Krasimir Angelov
I actually made my own copy of Data.Map and added an extra:

alterLookúp :: Ord k = (Maybe a - (b,Maybe a)) - k - Map k a - (b,Map k a)

function. I also changed my data type to:

type ParseChart k v = Map k (Map v ())

so I don't have to copy the Data.Set module also. Unfortunately this
doesn't give much better performance - 5734 msec instead of 5828 msec.
Fortunately I found that there is a way to avoid to use Map at all in
one common case. This gave me time about 5024 msec.

Regards,
   Krasimir


On 6/3/08, Yitzchak Gale [EMAIL PROTECTED] wrote:
 Krasimir Angelov wrote:
  but notice that the set is still traversed twice.

 Neil Mitchell wrote:
  I don't see any way of reducing that

 Yeah, it looks like the Data.Set (and Data.IntSet) library
 is missing the functions

 insertMember :: Ord a = a - Set a - (Bool, Set a)
 deleteMember :: Ord a = a - Set a - (Bool, Set a)

 analagous to splitMember. It should be easy to write
 those functions. If you do that for yourself, consider
 making a patch of them and submitting the patch
 as a library proposal.

 But anyway, a set lookup is very cheap, even for a
 set that is quite large. You may want to try just doing
 the extra lookup, it might be good enough for you.
 At least you eliminated the Map lookup.

 Regards,
 Yitz

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


Re: [Haskell-cafe] Implementing ParseChart with Data.Map

2008-06-03 Thread Yitzchak Gale
Krasimir Angelov wrote:
 but notice that the set is still traversed twice.

Neil Mitchell wrote:
 I don't see any way of reducing that

Yeah, it looks like the Data.Set (and Data.IntSet) library
is missing the functions

insertMember :: Ord a = a - Set a - (Bool, Set a)
deleteMember :: Ord a = a - Set a - (Bool, Set a)

analagous to splitMember. It should be easy to write
those functions. If you do that for yourself, consider
making a patch of them and submitting the patch
as a library proposal.

But anyway, a set lookup is very cheap, even for a
set that is quite large. You may want to try just doing
the extra lookup, it might be good enough for you.
At least you eliminated the Map lookup.

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


Re: [Haskell-cafe] Implementing ParseChart with Data.Map

2008-06-03 Thread Adrian Hey

Hello Krasimir,

Krasimir Angelov wrote:

Hi,

I have to write ParseChart implementation with Data.Map/Set. The chart
is type like this:

type Chart k v = Map k (Set v)

now I need operation like:

insert :: k - v - Chart k v - Maybe (Chart k v)

where the result is (Just _) if the (k,v) is actually added to the
chart or Nothing if it was already there and nothing have to be done.
The straight forward implementation is:

case Map.lookup k chart of
  Nothing - Just (Map.insert k (Set.singleton v) chart)
  Just set | Set.member v set - Nothing
   | otherwise- Just (Map.insert k
(Set.insert v set) chart)



You can do this quite easily with the AVL library, something like this
(untested code)

import Data.Cordering
import Data.Tree.AVL

type Chart k v = AVL (k, AVL v)

insert :: (Ord k, Ord v) = k - v - Chart k v - Maybe (Chart k v)
insert k v tk =
  case genOpenPathWith cmpk tk of
  EmptyBP pthk- Just $! insertPath pthk (k, singleton v) tk
  FullBP  pthk tv -
   case genOpenPath (compare v) tv of
   EmptyBP pthv - let tv' = insertPath pthv v tv
   in tv' `seq` (Just $! writePath pthk (k, tv') tk)
   FullBP  _ _  - Nothing
 where cmpk (k',tv) = case compare k k' of
  LT - Lt
  EQ - Eq tv
  GT - Gt

..or something like that (maybe you don't want all that strictness)

The insertPath  writePath functions do involve a second traversal
but do not repeat all the comparisons. Also, provided not too much
has happened in between, they should be very fast as the nodes on
the path are probably still in cache. The important thing is that
in the case where Nothing is returned you'll have burned very little
heap.

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


RE: [Haskell-cafe] hs-plugins compile error

2008-06-03 Thread John O'Donnell
Hi,

What is the status of hs-plugins?  I recently tried to install the
version plugins-1.2 on hackage, using a Gnu/Linux box with Fedora 9
and ghc-6.8.2, but didn't get past the configure stage (see config.log
below).

The installation script is invoking gcc with a -V command line argument
but according to gcc documentation -V requires an argument.

Has anyone managed to get hs-plugins to work?  If so, what platform,
which version of ghc and gcc, and where did you find the hs-plugins
source?

Best wishes,
John O'Donnell


... from config.log...
gcc version 4.3.0 20080428 (Red Hat 4.3.0-8) (GCC) 
configure:1852: $? = 0
configure:1854: gcc -V /dev/null 5
gcc: '-V' option must have argument
configure:1857: $? = 1
configure:1880: checking for C compiler default output file name
configure:1883: gccconftest.c  5
conftest.c:9:13: warning: missing terminating  character
conftest.c:10: error: stray '\33' in program
conftest.c:10: error: expected identifier or '(' before '[' token
conftest.c:10:4: error: invalid suffix h on integer constant
conftest.c:10:9: warning: missing terminating  character
conftest.c:10: error: missing terminating  character
configure:1886: $? = 1
configure: failed program was:
| /* confdefs.h.  */
| 
| #define PACKAGE_NAME 
| #define PACKAGE_TARNAME 
| #define PACKAGE_VERSION 
| #define PACKAGE_STRING 
| #define PACKAGE_BUGREPORT 
| #define LEADING_UNDERSCORE 0
| #define TOP /home/jtod/system/installs/hs-plugins/hs-plugins-1.2
| ESC[?1034h
| #define WITH_GHC ghc
| #define GHC_LIB_PATH /usr/local/lib/ghc-6.8.2
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:1925: error: C compiler cannot create executables




-Original Message-
From: [EMAIL PROTECTED] on behalf of Edsko de Vries
Sent: Mon 2008-06-02 20:23
To: Don Stewart
Cc: haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] hs-plugins compile error
 
Hi Don,

Is this the kind of thing you mean (I'm not really a darcs user; this is
the patch created by darcs record):

[Hide some names to remove ambiguity errors
Edsko de Vries [EMAIL PROTECTED]**20080602202001] {
hunk ./src/System/Plugins/Env.hs 76
-import Distribution.Package
+import Distribution.Package hiding (packageName)
hunk ./src/System/Plugins/PackageAPI.hs 43
-import Distribution.Package
+import Distribution.Package hiding (depends, packageName)
hunk ./src/System/Plugins/ParsePkgConfCabal.hs 9
-import Distribution.Package
+import Distribution.Package hiding (depends)
}

Edsko
___
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] [ANNOUNCE] git-darcs-import 0.1

2008-06-03 Thread Loup Vaillant
2008/6/3 Darrin Thompson [EMAIL PROTECTED]:
 On Sun, Jun 1, 2008 at 2:44 PM, Bertram Felgenhauer
 [EMAIL PROTECTED] wrote:
 Hi,

 I'm pleased to announce yet another tool for importing darcs repositories
 to git. Unlike darcs2git [1] and darcs-to-git [2], it's written in
 Haskell, on top of the darcs2 source code. The result is a much faster
 program - it can convert the complete ghc 6.9 branch (without libraries)
 in less than 15 minutes on my slightly dated machine (Athlon XP 2500+),
 which is quite fast [3]. Incremental updates work, too.


 What's the appeal of this? I personally love git, but I thought all
 the cool kids at this school used darcs and that was that.

Disclaimer: I'm no expert, this is what I've heard. Anyone please
confirm or deny the following?

Basically, git is waaay faster than Darcs on a number of use cases.
So, maybe the point of using this converter is when you just cannot
use Darcs any more (too old/big project, merging huge branch with
loads of conflicts, I don't know).

Another point may be broadcast-ability: It is possible to expose two
repositories: one Darcs, one Git. If I use Git and not Darcs (please
don't sue me), it will be simpler for me to get the source from the
Git snapshot, provided there is one. Well, if I want to contribute
back... maybe I should switch.

I think the True Heresy (and most useful, if practical) would be to
convert back and forth between the two version control systems,
accepting patches from both :-)

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


Re: [Haskell-cafe] hs-plugins compile error

2008-06-03 Thread Edsko de Vries
On Tue, Jun 03, 2008 at 03:07:33PM +0100, John O'Donnell wrote:
 Hi,
 
 What is the status of hs-plugins?  I recently tried to install the
 version plugins-1.2 on hackage, using a Gnu/Linux box with Fedora 9
 and ghc-6.8.2, but didn't get past the configure stage (see config.log
 below).
 
 The installation script is invoking gcc with a -V command line argument
 but according to gcc documentation -V requires an argument.
 
 Has anyone managed to get hs-plugins to work?  If so, what platform,
 which version of ghc and gcc, and where did you find the hs-plugins
 source?

It's working fine for me (after applying the patch I submitted), on
Debian Lenny (which currently comes with ghc 6.8.2, gcc 4.2.4) and the
source from Hackage. Source from the darcs repository also works fine
(after applying the same patch).

I *am* getting an application crash sometimes when I close my
application, but I have not yet been able to track that down so I'm not
100% sure it's due to hs-plugins.

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


Re: [Haskell-cafe] [ANNOUNCE] git-darcs-import 0.1

2008-06-03 Thread Darrin Thompson
On Sun, Jun 1, 2008 at 2:44 PM, Bertram Felgenhauer
[EMAIL PROTECTED] wrote:
 Hi,

 I'm pleased to announce yet another tool for importing darcs repositories
 to git. Unlike darcs2git [1] and darcs-to-git [2], it's written in
 Haskell, on top of the darcs2 source code. The result is a much faster
 program - it can convert the complete ghc 6.9 branch (without libraries)
 in less than 15 minutes on my slightly dated machine (Athlon XP 2500+),
 which is quite fast [3]. Incremental updates work, too.


What's the appeal of this? I personally love git, but I thought all
the cool kids at this school used darcs and that was that.

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


RE: [Haskell-cafe] hs-plugins compile error

2008-06-03 Thread John O'Donnell
Thanks, Edsko.

My version of gcc is 4.3.0.  It may well be that some other piece of
software in the Fedora 9 distribution is incompatible with the hs-plugins
installation script.

Has anyone installed hs-plugins on Fedora?  I was able to get it to
compile on Fedora 4, using ghc-6.4, two or three years ago, but it's never
worked on any of my systems since then.

John


-Original Message-
From: Edsko de Vries [mailto:[EMAIL PROTECTED]
Sent: Tue 2008-06-03 15:35
To: John O'Donnell
Cc: Edsko de Vries; Don Stewart; haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] hs-plugins compile error
 
On Tue, Jun 03, 2008 at 03:07:33PM +0100, John O'Donnell wrote:
 Hi,
 
 What is the status of hs-plugins?  I recently tried to install the
 version plugins-1.2 on hackage, using a Gnu/Linux box with Fedora 9
 and ghc-6.8.2, but didn't get past the configure stage (see config.log
 below).
 
 The installation script is invoking gcc with a -V command line argument
 but according to gcc documentation -V requires an argument.
 
 Has anyone managed to get hs-plugins to work?  If so, what platform,
 which version of ghc and gcc, and where did you find the hs-plugins
 source?

It's working fine for me (after applying the patch I submitted), on
Debian Lenny (which currently comes with ghc 6.8.2, gcc 4.2.4) and the
source from Hackage. Source from the darcs repository also works fine
(after applying the same patch).

I *am* getting an application crash sometimes when I close my
application, but I have not yet been able to track that down so I'm not
100% sure it's due to hs-plugins.

Edsko

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


[Haskell-cafe] Rewrite class with fundeps in pure h98?

2008-06-03 Thread Darrin Thompson
I thought that I should be able to write something like the toHtml
function below with pure H98, but when I went to write it I ended up
needing fundeps. Is there a way to express this without using any
extensions?

The idea was to take a remotely Dom-like tree and flatten it into a
string, but not require any particular string type. Mostly I'm ripping
off HStringTemplate for the fun of it.

{-# OPTIONS -fglasgow-exts #-}
module Control.WebWidget where

import Data.Monoid
import Data.String

data (IsString s, Monoid s) = Dom s =
Element s [Attr s] [Dom s] |
Text s

data (IsString s, Monoid s) = Attr s = Attr s s

class (Monoid s, IsString s) = HTML d s | d - s where
toHtml :: d - s

instance (Monoid s, IsString s) = HTML (Dom s) s where
toHtml (Element name attrs children) =
mconcat [
fromString ,
name,
mconcat $ map toHtml attrs,
fromString ,
mconcat $ map toHtml children,
fromString /,
name,
fromString  ]
toHtml (Text s) = s

instance (Monoid s, IsString s) = HTML (Attr s) s where
toHtml (Attr key value) =
mconcat [
fromString  ',
key,
fromString '=',
value,
fromString '  ]


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


Re: [Haskell-cafe] Implementing ParseChart with Data.Map

2008-06-03 Thread Isaac Dupree

Duncan Coutts wrote:

modify :: k - Map k e - (e, Maybe e - Map k e)

so it's a lookup that returns the element at k and also a continuation
that lets you rebuild a new map with an altered element. I guess that
doesn't account for the element not existing. There's probably a
generalisation that does.


isn't it just adding the necessary Maybe?:
modify :: k - Map k e - (Maybe e, Maybe e - Map k e)
?

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


Re: [Haskell-cafe] ANN (2 Libs) -- hvac 0.1b, a lightweight web framework and HStringTemplate 0.3

2008-06-03 Thread Thomas Hartman
I just tried out hvac. I was trying to run the hvac examples
after following the readme in the samples directory.

sudo lighttpd -D -f lh.conf
[sudo] password for thartman:
2008-06-03 09:30:02: (log.c.75) server started

so that's okay, but

http://localhost:3000/hvac-board/board/1

in firefox attempted to open a binary file 1.

Same result for http://localhost:3000/hvac-board

I don't know if this is an hvac issue or a fastcgi issue (seems more
likely) but any
advice?

Thomas.

2008/3/22 Sterling Clover [EMAIL PROTECTED]:
 1) hvac 0.1b: transactional, declarative framework for lightweight web
 applications.
 2) HStringTemplate 0.3

 1) hvac 0.1b

 hvac (short for http view and controller) has been my project for the last
 little while, and is finally in a fairly usable state, so I'm opening up the
 repo (darcs get http://community.haskell.org/~sclv/hvac/) for folks to play
 with and to get some feedback. While not quite yet ready for hackage, the
 package as provided should be fully cabal installable. Documentation is
 available at http://community.haskell.org/~sclv/hvac/html_docs/hvac/

 The aim of hvac is to provide an environment that makes the creation of
 lightweight fastcgi based web applications as simple as possible, with an
 emphasis on concise, declarative style code, correct concurrent
 transactional logic, and transparency in adding caching combinators.

 There are two included example programs, naturally neither of which is
 feature complete. They share a common login module of about 50 lines of
 code, excluding imports, templates, and database schema.

 The first program is a classic, greenspun-style message board with basic
 login functionality. It totals roughly 40 lines and tends to use just under
 4mb of resident memory on my system.

 The second is a wiki based on Pandoc and the PandocWiki code. The code
 totals roughly 30 lines (rendering borrowed from PandocWiki aside) and uses
 about 5mb of memory.

 hvac processes all requests in the STM monad, with some bells attached to
 properly interleave STM with session, database and filesystem operations
 such that they all conceptually occur together in a single transaction per
 request. Currently it is only fully tested with sqlite, but it should
 operate, modulo a few tweaks, with any database accessible via HDBC.

 hvac is particularly designed to use the HStringTemplate library as an
 output layer, in a simple declarative fashion. As the StringTemplate grammar
 is explicitly sub-turing, this ensures a clean separation of program logic
 from presentation, while providing a nonetheless fairly powerful language to
 express typical display tasks.

 The included cache combinators, still experimental, should allow a simple
 and fine-grained control over the level of caching of various disk-bound
 operations. Phantom types are used to ensure that no functions that modify
 state may be cached.

 To give a flavor of hvac code, the following is the complete (twenty lines!)
 source of the wiki controller (due to sql statements, some lines are rather
 long):

 wikiController tmpl =
  h |/ login * login_plug tmpl
  |
  (h |/ wiki |\\ \pageName -h |// POST *
  withValidation [ (contents, return) ]
  (\ [contents] - do
 pageId - selectVal id from pages where name=? [toSql
 pageName]
 maybe (addErrors [(Login,must be logged in.)]  continue)
(\user - case fromSql pageId of
Just (_::Int) -
  execStat insert into
 page_hist(pageId,contents,author) values(?,?,?) [pageId, toSql contents,
 toSql . userName $ user]
Nothing - do
  execStat insert into pages(name,locked)
 values(?,?) [toSql pageName, toSql (0::Int)]
  pid - selectVal max(id) from pages []
  execStat insert into
 page_hist(pageId,contents,author) values(?,?,?) [pid, toSql contents, toSql
 . userName $ user]) = getSes
 continue)
   | do
 pageId - selectVal id from pages where name=? [toSql pageName]
 (join $ renderf (tmpl showPage) (pageName, pageName)
  $ pageContents |= selectRow * from page_hist where
 pageId=? order by time desc limit 1 [pageId] ))
  | (redirect . ( ++ /wiki/Index) = scriptName)

 Future directions for work on hvac include: Stress testing for correctness
 of transactional logic and benchmarks. Exploration of various efficiency
 tweaks. Unit tests. Further development of the cache combinator API.
 Improvement of the example apps and addition of a few others (a blog maybe).
 Expansion of the library of validator functions. Exploration of transferring
 hvac to the standard FastCGI bindings (currently it uses a custom modified
 version to work properly with STM). Improvement of the database layer,
 particularly with regards to common paging functions. Creation of a set of
 simple combinators for generating CRUD 

[Haskell-cafe] Re: Rewrite class with fundeps in pure h98?

2008-06-03 Thread apfelmus

Darrin Thompson wrote:

I thought that I should be able to write something like the toHtml
function below with pure H98, but when I went to write it I ended up
needing fundeps. Is there a way to express this without using any
extensions?

The idea was to take a remotely Dom-like tree and flatten it into a
string, but not require any particular string type.

data (IsString s, Monoid s) = Dom s =
Element s [Attr s] [Dom s] |
Text s

data (IsString s, Monoid s) = Attr s = Attr s s

class (Monoid s, IsString s) = HTML d s | d - s where
toHtml :: d - s

instance (Monoid s, IsString s) = HTML (Dom s) s where

instance (Monoid s, IsString s) = HTML (Attr s) s where


The H98 way is to make a class for type constructors:

  class HTML d where
toHTML :: (Monoid s, IsString s) = d s - s

  instance HTML Dom where ...

  instance HTML Attr where ...


Btw, naming the class HTML is feels wrong, something like Serialize is 
probably a better fit.



Regards,
apfelmus

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


Re: [Haskell-cafe] What is the maturity of Haskell Web Frameworks

2008-06-03 Thread Thomas Hartman
Note however that hpaste runs off an earlier version of HAppS, which
has changed radically from v8 to v9.

I seem to remember discussion of porting hpaste to the latest HAppS as
a demo app... are there still plans to do that?

Thomas.

2008/6/2 Don Stewart [EMAIL PROTECTED]:
 aditya_siram:

 I am building a web-app that, in broad strokes, allows a leader to
 assign tasks to team members and allows team members to
 accept/reject/pick tasks that they want to do.

 I really like Haskell and I would like to use it to implement the
 solution. Are frameworks like Happs ready? Not so much in terms of
 documentation, but in functionality and stability.

 HAppS is nice (see hpaste.org for example, which is nice and simple, and
 has been running for over a year).

 Another nice option in Haskell is using something like HStringTemplate
 or the xhtml combinators  with fastcgi hooked into GHC's concurrency
 mechanisms.

 You can find *many* more things here,

http://hackage.haskell.org/packages/archive/pkg-list.html#cat:Network
http://hackage.haskell.org/packages/archive/pkg-list.html#cat:Web
 ___
 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] What is the maturity of Haskell Web Frameworks

2008-06-03 Thread Thomas Hartman
note to the curious that this is a git and not a darcs repo

git clone http://code.haskell.org/hpaste.git

thomas.

2008/6/3 Don Stewart [EMAIL PROTECTED]:
 A new version of happs was written on a Monday a couple of months ago,
 using fastcgi and takusen. We're running it at galois, and you can
 find the code on code.haskell.org/hpaste. So not quite what you wanted,
 but another data point.

 -- Don

 tphyahoo:
 Note however that hpaste runs off an earlier version of HAppS, which
 has changed radically from v8 to v9.

 I seem to remember discussion of porting hpaste to the latest HAppS as
 a demo app... are there still plans to do that?

 Thomas.

 2008/6/2 Don Stewart [EMAIL PROTECTED]:
  aditya_siram:
 
  I am building a web-app that, in broad strokes, allows a leader to
  assign tasks to team members and allows team members to
  accept/reject/pick tasks that they want to do.
 
  I really like Haskell and I would like to use it to implement the
  solution. Are frameworks like Happs ready? Not so much in terms of
  documentation, but in functionality and stability.
 
  HAppS is nice (see hpaste.org for example, which is nice and simple, and
  has been running for over a year).
 
  Another nice option in Haskell is using something like HStringTemplate
  or the xhtml combinators  with fastcgi hooked into GHC's concurrency
  mechanisms.
 
  You can find *many* more things here,
 
 http://hackage.haskell.org/packages/archive/pkg-list.html#cat:Network
 http://hackage.haskell.org/packages/archive/pkg-list.html#cat:Web
  ___
  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


[Haskell-cafe] More on performance

2008-06-03 Thread Don Stewart
I wrote up the second part of the tour of understanding low level
performance in GHC here,

http://reddit.com/r/programming/info/6lx36/comments/

Follows on from the discussion last week about various performance
related things.

Enjoy.

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


[Haskell-cafe] Re: [ANNOUNCE] git-darcs-import 0.1

2008-06-03 Thread Aaron Denney
On 2008-06-03, Peter Hercek [EMAIL PROTECTED] wrote:
 Loup Vaillant wrote:
 2008/6/3 Darrin Thompson [EMAIL PROTECTED]:
 --cut--
 What's the appeal of this? I personally love git, but I thought all
 the cool kids at this school used darcs and that was that.
 
 Disclaimer: I'm no expert, this is what I've heard. Anyone please
 confirm or deny the following?
 
 Basically, git is waaay faster than Darcs on a number of use cases.

 Other reason can be git rebase. Of course there is a question
   how good practice it is ... but it is being used.

Darcs patches are pretty much an implicit rebase.

-- 
Aaron Denney
--

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


Re: [Haskell-cafe] What is the maturity of Haskell Web Frameworks

2008-06-03 Thread Don Stewart
Ah yes, the url was incorrect. Well spotted.

tphyahoo:
 note to the curious that this is a git and not a darcs repo
 
 git clone http://code.haskell.org/hpaste.git
 
 thomas.
 
 2008/6/3 Don Stewart [EMAIL PROTECTED]:
  A new version of happs was written on a Monday a couple of months ago,
  using fastcgi and takusen. We're running it at galois, and you can
  find the code on code.haskell.org/hpaste. So not quite what you wanted,
  but another data point.
 
  -- Don
 
  tphyahoo:
  Note however that hpaste runs off an earlier version of HAppS, which
  has changed radically from v8 to v9.
 
  I seem to remember discussion of porting hpaste to the latest HAppS as
  a demo app... are there still plans to do that?
 
  Thomas.
 
  2008/6/2 Don Stewart [EMAIL PROTECTED]:
   aditya_siram:
  
   I am building a web-app that, in broad strokes, allows a leader to
   assign tasks to team members and allows team members to
   accept/reject/pick tasks that they want to do.
  
   I really like Haskell and I would like to use it to implement the
   solution. Are frameworks like Happs ready? Not so much in terms of
   documentation, but in functionality and stability.
  
   HAppS is nice (see hpaste.org for example, which is nice and simple, and
   has been running for over a year).
  
   Another nice option in Haskell is using something like HStringTemplate
   or the xhtml combinators  with fastcgi hooked into GHC's concurrency
   mechanisms.
  
   You can find *many* more things here,
  
  http://hackage.haskell.org/packages/archive/pkg-list.html#cat:Network
  http://hackage.haskell.org/packages/archive/pkg-list.html#cat:Web
   ___
   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] What is the maturity of Haskell Web Frameworks

2008-06-03 Thread Don Stewart
A new version of happs was written on a Monday a couple of months ago,
using fastcgi and takusen. We're running it at galois, and you can
find the code on code.haskell.org/hpaste. So not quite what you wanted,
but another data point.

-- Don

tphyahoo:
 Note however that hpaste runs off an earlier version of HAppS, which
 has changed radically from v8 to v9.
 
 I seem to remember discussion of porting hpaste to the latest HAppS as
 a demo app... are there still plans to do that?
 
 Thomas.
 
 2008/6/2 Don Stewart [EMAIL PROTECTED]:
  aditya_siram:
 
  I am building a web-app that, in broad strokes, allows a leader to
  assign tasks to team members and allows team members to
  accept/reject/pick tasks that they want to do.
 
  I really like Haskell and I would like to use it to implement the
  solution. Are frameworks like Happs ready? Not so much in terms of
  documentation, but in functionality and stability.
 
  HAppS is nice (see hpaste.org for example, which is nice and simple, and
  has been running for over a year).
 
  Another nice option in Haskell is using something like HStringTemplate
  or the xhtml combinators  with fastcgi hooked into GHC's concurrency
  mechanisms.
 
  You can find *many* more things here,
 
 http://hackage.haskell.org/packages/archive/pkg-list.html#cat:Network
 http://hackage.haskell.org/packages/archive/pkg-list.html#cat:Web
  ___
  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


[Haskell-cafe] Re: type-level integers using type families

2008-06-03 Thread Alfonso Acosta
On Thu, May 29, 2008 at 5:15 AM, Peter Gavin [EMAIL PROTECTED] wrote:
 Has anyone else tried implementing type-level integers using type families?

When I started to work on thetype-level and parameterized data
packages,  I considered using type-families and GADTs, but I found
quite a few problems which have been nicely summarized by Benedikt in
this thread.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Rewrite class with fundeps in pure h98?

2008-06-03 Thread Sterling Clover
This was how it was originally done in HStringTemplate, as I recall.  
The mptcs were introduced in order to maintain lookup-maps of the  
correct type, and particularly to allow embedding of templates within  
one another. There may have been some other corner-cases involved as  
well. However, unless you run into them, the H98 way is certainly  
cleaner.


--Sterl

On Jun 3, 2008, at 1:17 PM, apfelmus wrote:


Darrin Thompson wrote:

I thought that I should be able to write something like the toHtml
function below with pure H98, but when I went to write it I ended up
needing fundeps. Is there a way to express this without using any
extensions?
The idea was to take a remotely Dom-like tree and flatten it into a
string, but not require any particular string type.
data (IsString s, Monoid s) = Dom s =
Element s [Attr s] [Dom s] |
Text s
data (IsString s, Monoid s) = Attr s = Attr s s
class (Monoid s, IsString s) = HTML d s | d - s where
toHtml :: d - s
instance (Monoid s, IsString s) = HTML (Dom s) s where
instance (Monoid s, IsString s) = HTML (Attr s) s where


The H98 way is to make a class for type constructors:

  class HTML d where
toHTML :: (Monoid s, IsString s) = d s - s

  instance HTML Dom where ...

  instance HTML Attr where ...


Btw, naming the class HTML is feels wrong, something like  
Serialize is probably a better fit.



Regards,
apfelmus

___
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] ANN (2 Libs) -- hvac 0.1b, a lightweight web framework and HStringTemplate 0.3

2008-06-03 Thread Sterling Clover
Probably best not to keep this discussion in -cafe after this, as  
this is more of a debugging-type issue, but in my experience, I bet  
the lighttpd server is trying to serve the hvac-board fcgi file  
directly as a binary, rather than launching it as a fastcgi instance  
at all.  The configurations files I've built have worked fine for me,  
but your milage may vary -- getting fastcgi up and running can be a  
bit of a bear at times. At a minimum, you should make sure that the  
lh.conf file points correctly to your binary in the fastcgi.server  
variable, and that you have all the proper fastcgi libraries  
installed on your system.


Regards,
Sterl

On Jun 3, 2008, at 1:08 PM, Thomas Hartman wrote:


I just tried out hvac. I was trying to run the hvac examples
after following the readme in the samples directory.

sudo lighttpd -D -f lh.conf
[sudo] password for thartman:
2008-06-03 09:30:02: (log.c.75) server started

so that's okay, but

http://localhost:3000/hvac-board/board/1

in firefox attempted to open a binary file 1.

Same result for http://localhost:3000/hvac-board

I don't know if this is an hvac issue or a fastcgi issue (seems more
likely) but any
advice?

Thomas.

2008/3/22 Sterling Clover [EMAIL PROTECTED]:
1) hvac 0.1b: transactional, declarative framework for lightweight  
web

applications.
2) HStringTemplate 0.3

1) hvac 0.1b

hvac (short for http view and controller) has been my project for  
the last
little while, and is finally in a fairly usable state, so I'm  
opening up the
repo (darcs get http://community.haskell.org/~sclv/hvac/) for  
folks to play
with and to get some feedback. While not quite yet ready for  
hackage, the
package as provided should be fully cabal installable.  
Documentation is

available at http://community.haskell.org/~sclv/hvac/html_docs/hvac/

The aim of hvac is to provide an environment that makes the  
creation of
lightweight fastcgi based web applications as simple as possible,  
with an

emphasis on concise, declarative style code, correct concurrent
transactional logic, and transparency in adding caching combinators.

There are two included example programs, naturally neither of  
which is
feature complete. They share a common login module of about 50  
lines of

code, excluding imports, templates, and database schema.

The first program is a classic, greenspun-style message board with  
basic
login functionality. It totals roughly 40 lines and tends to use  
just under

4mb of resident memory on my system.

The second is a wiki based on Pandoc and the PandocWiki code. The  
code
totals roughly 30 lines (rendering borrowed from PandocWiki aside)  
and uses

about 5mb of memory.

hvac processes all requests in the STM monad, with some bells  
attached to
properly interleave STM with session, database and filesystem  
operations
such that they all conceptually occur together in a single  
transaction per

request. Currently it is only fully tested with sqlite, but it should
operate, modulo a few tweaks, with any database accessible via HDBC.

hvac is particularly designed to use the HStringTemplate library  
as an
output layer, in a simple declarative fashion. As the  
StringTemplate grammar
is explicitly sub-turing, this ensures a clean separation of  
program logic
from presentation, while providing a nonetheless fairly powerful  
language to

express typical display tasks.

The included cache combinators, still experimental, should allow a  
simple
and fine-grained control over the level of caching of various disk- 
bound
operations. Phantom types are used to ensure that no functions  
that modify

state may be cached.

To give a flavor of hvac code, the following is the complete  
(twenty lines!)
source of the wiki controller (due to sql statements, some lines  
are rather

long):

wikiController tmpl =
 h |/ login * login_plug tmpl
 |
 (h |/ wiki |\\ \pageName -h |// POST *
 withValidation [ (contents, return) ]
 (\ [contents] - do
pageId - selectVal id from pages where name=? [toSql
pageName]
maybe (addErrors [(Login,must be logged in.)]   
continue)

   (\user - case fromSql pageId of
   Just (_::Int) -
 execStat insert into
page_hist(pageId,contents,author) values(?,?,?) [pageId, toSql  
contents,

toSql . userName $ user]
   Nothing - do
 execStat insert into pages(name,locked)
values(?,?) [toSql pageName, toSql (0::Int)]
 pid - selectVal max(id) from pages []
 execStat insert into
page_hist(pageId,contents,author) values(?,?,?) [pid, toSql  
contents, toSql

. userName $ user]) = getSes
continue)
  | do
pageId - selectVal id from pages where name=? [toSql  
pageName]

(join $ renderf (tmpl showPage) (pageName, pageName)
 $ pageContents |= selectRow * from page_hist where
pageId=? order 

[Haskell-cafe] Re: [ANNOUNCE] git-darcs-import 0.1

2008-06-03 Thread Peter Hercek

Aaron Denney wrote:

On 2008-06-03, Peter Hercek [EMAIL PROTECTED] wrote:

Loup Vaillant wrote:

2008/6/3 Darrin Thompson [EMAIL PROTECTED]:

--cut--
What's the appeal of this? I personally love git, but I thought all
the cool kids at this school used darcs and that was that.

Disclaimer: I'm no expert, this is what I've heard. Anyone please
confirm or deny the following?

Basically, git is waaay faster than Darcs on a number of use cases.

Other reason can be git rebase. Of course there is a question
  how good practice it is ... but it is being used.


Darcs patches are pretty much an implicit rebase.


You cannot push patch B if it depends on patch A without also
 pushing A. And darcs currently does not alow you to reorder
 B before A (which is what git rebase actually does). Git rebase
 works quite well even in cloned repositories.

See: http://bugs.darcs.net/issue891
Some discussin about it is also here:
http://lists.osuosl.org/pipermail/darcs-users/2008-February/011564.html

When the issue is fixed then darcs will be really patch based and
 will become the ultimate DSCM :-)

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


[Haskell-cafe] HDBC-odbc 1.1.4.4 fixes Windows linking problems

2008-06-03 Thread John Goerzen
Hi,

HDBC-odbc version 1.1.4.4 has been uploaded to Hackage.  It fixes the
problems some here have encountered regarding ODBC crashes or other
similar odd behavior on Windows.  Thanks to Andrew Appleyard for
tracking down the problem and sending me a patch.

The detailed explanation, if you're interested, is a ccall vs. stdcall
issue in FFI.  Details here:

http://git.complete.org/hdbc-odbc?a=commit;h=cca312d9891d227094494dcee518f436042e14b4

People that are not using HDBC-odbc on Windows will not find any
difference or other changes in this version.

-- 
John Goerzen
Author, Foundations of Python Network Programming
http://www.amazon.com/exec/obidos/tg/detail/-/1590593715
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ghc 6.8.2 issue

2008-06-03 Thread Galchin, Vasili
 Something like that yes.

 You're running runhaskell Setup.lhs and that loads and runs code from
 the Cabal library. The Cabal library depends on the process library
 which depends on the unix library. So by replacing the same version of
 the unix package you're breaking everything else which depends on it,
 including Cabal and thus runhaskell Setup.lhs.

 So the solution is to not do that. Don't re-install the exact same
 version of any of the core libs that come with ghc. Adding new versions
 is fine, replacing existing versions is not fine because it breaks all
 the other packages that were already built against that package.


 But Duncan, let's suppose I build unix putting in a local directory
with a different version number than the released version of unix.

 1) How do I get the local package.conf built and populated?

 2) How do I get a test case to link against this experimental local
version of unix? Is there a --prefix or something like that I pass on
runhaskell Setup.hs build?

Regards, Vasili


 Duncan


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


[Haskell-cafe] Re: [ANNOUNCE] git-darcs-import 0.1

2008-06-03 Thread Aaron Denney
This is drifting off-topic, but...
On 2008-06-03, Peter Hercek [EMAIL PROTECTED] wrote:
 Aaron Denney wrote:
 On 2008-06-03, Peter Hercek [EMAIL PROTECTED] wrote:
 Loup Vaillant wrote:
 2008/6/3 Darrin Thompson [EMAIL PROTECTED]:
 --cut--
 What's the appeal of this? I personally love git, but I thought all
 the cool kids at this school used darcs and that was that.
 Disclaimer: I'm no expert, this is what I've heard. Anyone please
 confirm or deny the following?

 Basically, git is waaay faster than Darcs on a number of use cases.
 Other reason can be git rebase. Of course there is a question
   how good practice it is ... but it is being used.
 
 Darcs patches are pretty much an implicit rebase.

 You cannot push patch B if it depends on patch A without also
   pushing A. And darcs currently does not alow you to reorder
   B before A

True.  This is a *feature* not a bug.  You shouldn't be able to do this
automatically, because it can't be done right.  You need to do this sort
of thing manually.  If you don't, the heuristics used will bite you at
some point.  When they do commute, there is no problem.

 Git rebase works quite well even in cloned repositories.

Meh.  It can, if you're really really lucky.

 See: http://bugs.darcs.net/issue891
 Some discussin about it is also here:
 http://lists.osuosl.org/pipermail/darcs-users/2008-February/011564.html

 When the issue is fixed then darcs will be really patch based and
   will become the ultimate DSCM :-)

Rebasing is doable in git as a one-repository operation because each
repository has multiple branches.  As darcs has one repo per branch,
it fundamentally needs to be done in multiple repos.

There are naturally two repos, upstream, and your-feature-development.

your-feature-development has a patch A that you want to rebase.

What you should do is pull upstream into new-tracking, then pull patch A
from your-feature-development into new-tracking.

If it applies with no problem, great: mv your-feature-development
your-feature-development-old; new-tracking your-feature-development.
Of course, in this case, you could have just pulled into
your-feature-development.  If there weren't any other patches to save in
the old your-feature-development, you can delete it instead of moving
it.

When there is a conflict, then you need to handle it somehow.  Neither
git nor darcs can do it automatically.  You can just record the merge
conflict and your resolution.  This keeps repos that pulled from you
valid, but this won't give you the clean history that you presumably
want.  So you need to combine the merger and cleanup into a new patch
with the same log message, etc.  It's true that git does make *this*
process very nice.

There is one thing that git rebase does easily (and correctly) that darcs
doesn't do nicely: rewriting history by merging commits prior to the
head.  I put prior in quotes, because darcs doesn't preserve history
in the first place.  I don't find that a compelling use, as opposed to
maintaing topic branches.

-- 
Aaron Denney
--

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


Re: [Haskell-cafe] Re: appending an element to a list

2008-06-03 Thread Ronald Guida
Thank you, apfelmus.  That was a wonderful explanation; the debit
method in [1] finally makes sense.

[1]: Chris Okasaki. Purely Function Data Structures.
 http://www.cs.cmu.edu/~rwh/theses/okasaki.pdf
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Laziness leaks

2008-06-03 Thread Ronald Guida
I was looking at the real time queues in [1] and I wanted to see what
would happen if I tried to write one in Haskell.  The easy part was
translating the real time queue from [1], p43 into Haskell.

The hard part is testing to see if the rotations really happen what
they should.  Basically, I decided to use Debug.Trace.trace to see
when rotations were actually occurring.

I pushed the numbers 1 to 10 into the queue, and then I popped the
queue ten times.  What I found is that none of the rotations would
actually take place until the first time I actually tried to /display
the value/ of a popped element.  What I realized is that my test
driver is lazy.  I figured out that I could put a bunch of 'seq'
functions in the test driver to get the rotations to happen.

My demonstration code is in:
http://hpaste.org/8080

This leads to two questions:

1. If I find a laziness leak, is 'seq' the appropriate way to plug it?

2. Is there any way to systematically search for or detect laziness
   leaks?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] hs-plugins compile error

2008-06-03 Thread Timo B. Hübel
 What is the status of hs-plugins?  I recently tried to install the
 version plugins-1.2 on hackage, using a Gnu/Linux box with Fedora 9
 and ghc-6.8.2, but didn't get past the configure stage (see config.log
 below).

I am getting exactly the same error on a Gentoo box. I've tracked it down to 
some awkward escape character sequence in the TOP variable defined in 
config.h.

The following patch makes it work for me, but I've no idea if this is the 
right way to fix this problem:

hunk ./configure 1385
-TOP=`echo Directory.getCurrentDirectory = putStrLn.init.tail.show  | 
ghc --interactive -ignore-dot-ghci -v0 | tr -d '\r'`
+TOP=`echo Directory.getCurrentDirectory = putStr. | 
ghc --interactive -ignore-dot-ghci -v0`
hunk ./configure.ac 66
-TOP=`echo Directory.getCurrentDirectory = putStrLn.init.tail.show  | 
ghc --interactive -ignore-dot-ghci -v0 | tr -d '\r'`
+TOP=`echo Directory.getCurrentDirectory = putStr | 
ghc --interactive -ignore-dot-ghci -v0`

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


Re: [Haskell-cafe] ghc 6.8.2 issue

2008-06-03 Thread Brandon S. Allbery KF8NH


On 2008 Jun 3, at 16:40, Galchin, Vasili wrote:


 1) How do I get the local package.conf built and populated?

 2) How do I get a test case to link against this experimental  
local version of unix? Is there a --prefix or something like  
that I pass on runhaskell Setup.hs build?


both cases the answer is the same:  --user --prefix=whatever

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


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


Re: [Haskell-cafe] What is the maturity of Haskell Web Frameworks

2008-06-03 Thread Duncan Coutts

On Tue, 2008-06-03 at 10:23 -0700, Don Stewart wrote:
 A new version of happs was written on a Monday a couple of months ago,
 using fastcgi and takusen. We're running it at galois, and you can
 find the code on code.haskell.org/hpaste. So not quite what you wanted,
 but another data point.

That's very interesting. I hope we will also see a version with the same
feature set implemented with the latest HAppS. It would give an
interesting comparison of the web frameworks to see the same app
implemented in both.

Duncan

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


[Haskell-cafe] Re: [ANN] bloomfilter 1.0 - Fast immutable and mutable Bloom filters

2008-06-03 Thread Scott Cruzen
* Jim Snow [EMAIL PROTECTED] [080531 15:23]:
 Without looking at the code to verify that this is how it has really  
 been implemented, a bloom filter is like a series of hash tables, where  
 the hash table entries are one bit.  The bit is set if there is an item  
 that hashes to that value in the bloom filter.  So, assuming a single  
 hash table where half the bits are set, there's a 50% false positive  
 rate and no false negatives when you do a membership test.

 To reduce the false positives, we can add another hash table with a  
 different hash function.  Assuming it also is half full, we can check if  
 an item is in both tables, and our false positive rate drops to 25%.

 In practice, one might use something like 32 hash tables.  This yields a  
 false positive rate of 1/(2^32).  Their most obvious application is to  
 store the dictionary for a spell checker in a space-efficient way,  
 though I have a friend who wrote a paper on using them for router caches.

 There was a google tech talk on bloom filters awhile ago:  
 http://www.youtube.com/watch?v=947gWqwkhu0

One other use:

LOAF is a simple extension to email that lets you append your entire
address book to outgoing mail message without compromising your privacy.
Correspondents can use this information to prioritize their mail, and
learn more about their social networks. The LOAF home page is at
http://loaf.cantbedone.org.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Laziness leaks

2008-06-03 Thread Albert Y. C. Lai

Ronald Guida wrote:

I was looking at the real time queues in [1] and I wanted to see what
would happen if I tried to write one in Haskell.  The easy part was
translating the real time queue from [1], p43 into Haskell.

The hard part is testing to see if the rotations really happen what
they should.  Basically, I decided to use Debug.Trace.trace to see
when rotations were actually occurring.

I pushed the numbers 1 to 10 into the queue, and then I popped the
queue ten times.  What I found is that none of the rotations would
actually take place until the first time I actually tried to /display
the value/ of a popped element.  What I realized is that my test
driver is lazy.  I figured out that I could put a bunch of 'seq'
functions in the test driver to get the rotations to happen.

My demonstration code is in:
http://hpaste.org/8080

This leads to two questions:

1. If I find a laziness leak, is 'seq' the appropriate way to plug it?

2. Is there any way to systematically search for or detect laziness
   leaks?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



I want to point out several non-causes of laziness. For a no-magic, 
no-surprise understanding, it is important to know both what causes 
laziness and what does not.


A. The lazy list at rtqRear, which is originally a strict list. It is an 
invariant that every thunk you put there is [] or x:y. (As a result, it 
is unnecessary to make RTQueue a strict record, since you want two of 
the fields to be lazy, and the remaining field rtqRear is de facto strict.)


B. rtqueue's thunked call to rotate, i.e.,

   rtqueue f r []= let f' = rotate f r [] in RTQueue f' [] f'

Originally f' is forced before the record is returned (SML convention). 
In Haskell the rotate call is thunked as f' and the record is returned. 
But there will not be an accumulation of such rotate thunks. For example 
if you snoc twice in succession and the first instance builds a rotate 
thunk:


   snoc p (snoc q (RTQueue f r []))
- snoc p (rtqueue f (q:r) [])
- snoc p (RTQueue f' [] f')  where f' = thunk
- rtqueue f' p:[] f'  where f' = thunk
- f' is now forced by rtqueue's pattern matching on the 3rd param

So if one snoc builds a rotate thunk, the next snoc kills it. And 
similarly any interleaving of queue operations. (head and tail add their 
extra pattern matching.) Thus it can be proved that Haskell lags behind 
the original by just one step in this regard. This is ok unless you're 
done with reducing asymptotic cost and start looking at constant factor 
cost.


A true cause of laziness is in accumulating a chain of tail's and snocs 
without intermediate forcing, as observed.

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


[Haskell-cafe] A simple beginner question

2008-06-03 Thread Adam Smyczek

Example:

data SampleType = A | B Int | C String | D --  etc.

sampleTypes = [A, B 5, C test] :: [SampleType]

How do I find for example element A in the sampleTypes list?
Do I have to create e.g.:

isA :: SampleType - Bool
isA A = True
isA _ = False

for every constructor and use find?
It feels like this is not the quicker method.

Thanks,
Adam


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


Re: [Haskell-cafe] Laziness leaks

2008-06-03 Thread Ronald Guida
Don Stewart wrote:
 2. Is there any way to systematically search for or detect laziness
leaks?

 Profiling, and looking at the Core. Being explicit about the
 evaluation strategy you want is a fine idea though.

Albert Y. C. Lai wrote
 A true cause of laziness is in accumulating a chain of tail's and
 snocs without intermediate forcing, as observed.

So I just thought of something.  If laziness leads to laziness leaks,
then is there such a thing as a strictness leak?  I realized that the
answer is yes.

A lazy leak is a situation where I'm wasting resources to delay a
sequence of calculations instead of just doing them now.  But in a
strict language, I might waste resources to compute things that I'll
never need.  I would call that a strictness leak.

Now I could ask the dual question, How do I detect strictness leaks,
and I would probably get the same answers: profiling, looking at
object code, and being explicit about the evaluation strategy.

Both types of leaks share a lot in common.  In both cases, I'm wasting
resources.  If I have a real-time system, then either type of leak can
cause me to a miss a deadline.

With a strict evaluation strategy, I might miss a nearby deadline
because I'm busy calculating things that I don't need until the
distant future.

With a lazy evaluation strategy, I might miss a distant deadline
because I'm lazily putting off a calculation now.

If I were a college student, then this would be a laziness leak:

  Professor X assigns a report, due in a month.  Two days before the
  report is due, I'll head to the drugstore, load up on caffeine, and
  work for 48 hours straight to get it done.

And this would be a strictness leak:

  Professor X assigns a report, due in a month.  As soon as I leave
  the classroom, I'll head to the drugstore, load up on caffeine, and
  work for 48 hours straight to get it done.

And this would be an effective solution:

  Professor X assigns a report, due in a month.  I'll select 15 days,
  spaced out over the next month, and allocate four hours per day to
  work on the report.

By default, a lazy language will procrastinate.  By default, a strict
language will anticrastinate.  Either way, I can waste resources by
blindly accepting the default time management plan.

So the real question is How do I avoid laziness leaks or strictness
leaks and apparently, the real answers are (1) learn how to
recognize when the default plan will waste resources, and (2) learn
how to express reasonable evaluation strategies in code.

I would ask, how do I examine the evaluation order of my code, but
the answer is already available: use a debugger.  Haskell already has
debugging tools that do exactly what I need.
(http://www.haskell.org/haskellwiki/Debugging)

In particular, HOOD looks extremely interesting.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] More on performance

2008-06-03 Thread Ryan Ingram
I think it's hard to overstate how awesome the RULES pragma is.

Thanks for the example.

  -- ryan

On 6/3/08, Don Stewart [EMAIL PROTECTED] wrote:
 I wrote up the second part of the tour of understanding low level
 performance in GHC here,

http://reddit.com/r/programming/info/6lx36/comments/

 Follows on from the discussion last week about various performance
 related things.

 Enjoy.

 -- Don
 ___
 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 simple beginner question

2008-06-03 Thread Philip Weaver
On Tue, Jun 3, 2008 at 5:11 PM, Adam Smyczek [EMAIL PROTECTED] wrote:
 Example:

 data SampleType = A | B Int | C String | D --  etc.

 sampleTypes = [A, B 5, C test] :: [SampleType]

 How do I find for example element A in the sampleTypes list?
 Do I have to create e.g.:

 isA :: SampleType - Bool
 isA A = True
 isA _ = False

 for every constructor and use find?

isA is already defined for every constructor, so all you have to do is
find isA

 It feels like this is not the quicker method.

 Thanks,
 Adam


 ___
 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 simple beginner question

2008-06-03 Thread Ronald Guida
Adam Smyczek wrote:
 data SampleType = A | B Int | C String | D --  etc.

 sampleTypes = [A, B 5, C test] :: [SampleType]

 How do I find for example element A in the sampleTypes list?

Here's one way to do it:

filter (\x - case x of A - True; otherwise - False) sampleTypes
  == [A]

filter (\x - case x of B _ - True; otherwise - False) sampleTypes
  == [B 5]

filter (\x - case x of C _ - True; otherwise - False) sampleTypes
  == [C test]

Your idea works just as well:
 isA :: SampleType - Bool
 isA A = True
 isA _ = False

filter isA sampleTypes
  == [A]

There is a third possibility:  Have you learned about the maybe
function or the either function yet?
  maybe :: b - (a - b) - Maybe a - b
  either :: (a - c) - (b - c) - Either a b - c

I would call these mediating morphisms, where morphism is techno-
babble for function. You could write your own version of one of these
for SampleType.  Assuming you have:

  data SampleType = A | B Int | C String

You could write:

  sampletype :: t
- (Int - t)
- (String - t)
- SampleType - t
  sampletype a bf cf s =
 case s of
   A - a
   B n - bf n
   C s - cf s

  isA = sampletype True (const False) (const False)
  isB = sampletype False (const True) (const False)
  isC = sampletype False (const False) (const True)

filter isA sampleTypes
  == [A]

This (the mediating morphism) is probably overkill for what you want
to do, though.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: A simple beginner question

2008-06-03 Thread Achim Schneider
Adam Smyczek [EMAIL PROTECTED] wrote:

 data SampleType = A | B Int | C String | D --  etc.
deriving (Eq)

 sampleTypes = [A, B 5, C test] :: [SampleType]
 

If you derive from Eq, you can do

isA = (==) A

filter isA sampleTypes

or ad-hoc:
filter ((==) A) sampleTypes

things like 
filter (\x - case x of 
{ A - True
; B b | b  2 - True
; C c | c == foo - True
; _ - False}) sampleTypes
work, too. Admittedly, I'm lambda-spoilt.

-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 

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


[Haskell-cafe] Re: A simple beginner question

2008-06-03 Thread Achim Schneider
Achim Schneider [EMAIL PROTECTED] wrote:

 filter (\x - case x of 
   { A - True
   ; B b | b  2 - True
   ; C c | c == foo - True
   ; _ - False}) sampleTypes
 
coming to think of it: Why can't I write

filter (\A - True
\B b | b  2 - True
\C c | c == foo - True
_ - False 
   ) sampleTypes

? AFAICT it's syntactically unambiguous.

-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 

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


Re: [Haskell-cafe] Laziness leaks

2008-06-03 Thread Derek Elkins
On Tue, 2008-06-03 at 20:12 -0400, Ronald Guida wrote:
 Don Stewart wrote:
  2. Is there any way to systematically search for or detect laziness
 leaks?
 
  Profiling, and looking at the Core. Being explicit about the
  evaluation strategy you want is a fine idea though.
 
 Albert Y. C. Lai wrote
  A true cause of laziness is in accumulating a chain of tail's and
  snocs without intermediate forcing, as observed.
 
 So I just thought of something.  If laziness leads to laziness leaks,
 then is there such a thing as a strictness leak?  I realized that the
 answer is yes.

I ask a similar question here albeit for a much narrower and more
technical notion:
http://lambda-the-ultimate.org/node/2273#comment-40156
and come to the same conclusion (at least for an even more narrow
notion).

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


Re: [Haskell-cafe] A simple beginner question

2008-06-03 Thread Dan Weston

There's always one more way to do things in Haskell! :)

Here's yet another way to get at the payloads in a list. You don't have 
to know how this works to use it:


data SampleType = A | B Int | C String

unA :: SampleType - [()]
unA A = return ()
unA _ = fail Not an A

unB :: SampleType - [Int]
unB (B b) = return b
unB _ = fail Not a B

unC :: SampleType - [String]
unC (C c) = return c
unC _ = fail Not a C

-- I can check for more than one constructor...
-- Note that a single type must be returned,
-- so for C I return e.g. the length of the string
unBorC :: SampleType - [Int]
unBorC (B b) = return b
unBorC (C c) = return (length c)
unBorC _ = fail Not a B or C

For lists, the = operator knows to ignore failure and collect anything 
else into a new list. The technobabble for this is that [] is a Monad.


*Main let sampleTypes = [A, B 5, C test, A, A, B 7, C go]
*Main sampleTypes = unA
[(),(),()]
*Main sampleTypes = unB
[5,7]
*Main sampleTypes = unC
[test,go]
*Main sampleTypes = unBorC
[5,4,7,2]

Adam Smyczek wrote:

Example:

data SampleType = A | B Int | C String | D --  etc.

sampleTypes = [A, B 5, C test] :: [SampleType]

How do I find for example element A in the sampleTypes list?
Do I have to create e.g.:

isA :: SampleType - Bool
isA A = True
isA _ = False

for every constructor and use find?
It feels like this is not the quicker method.

Thanks,
Adam


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





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


[Haskell-cafe] Re: A simple beginner question

2008-06-03 Thread Achim Schneider
Dan Weston [EMAIL PROTECTED] wrote:

 There's always one more way to do things in Haskell! :)
 
 Here's yet another way to get at the payloads in a list. You don't
 have to know how this works to use it:
 
Bastard. He's going to try and find out how it works. 

To get back to the filters:

module Main where
import Control.Monad

data SampleType = A | B Int | C String deriving Show

noA :: SampleType - [SampleType]
noA A = mzero
noA e = return e

noB :: SampleType - [SampleType]
noB (B _) = mzero
noB e = return e

noAB :: SampleType - [SampleType]
noAB m = [m] = noA = noB

sampleTypes = [A, B 5, C test, A, A, B 7, C go]

*Main sampleTypes = noA
[B 5,C test,B 7,C go]
*Main sampleTypes = noB
[A,C test,A,A,C go]
*Main sampleTypes = noAB
[C test,C go]

-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 

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


Re: [Haskell-cafe] HDBC-odbc 1.1.4.4 fixes Windows linking problems

2008-06-03 Thread Greg Matheson
On Tue, 03 Jun 2008, John Goerzen wrote:

 Hi,

 HDBC-odbc version 1.1.4.4 has been uploaded to Hackage.  It fixes the
 problems some here have encountered regarding ODBC crashes or other
 similar odd behavior on Windows. 

I'm getting a 'Parse error in pattern' error.

C:\Documents and Settings\Administratorghci
GHCi, version 6.8.2: http://www.haskell.org/ghc/  :? for help
Loading package base ... linking ... done.
Prelude :m Database.HDBC.ODBC Database.HDBC
Prelude Database.HDBC Database.HDBC.ODBC conn - connectODBC dictation
Loading package array-0.1.0.0 ... linking ... done.
Loading package containers-0.1.0.1 ... linking ... done.
Loading package bytestring-0.9.0.1 ... linking ... done.
Loading package old-locale-1.0.0.0 ... linking ... done.
Loading package old-time-1.0.0.0 ... linking ... done.
Loading package mtl-1.1.0.0 ... linking ... done.
Loading package HDBC-1.1.4 ... linking ... done.
Loading package HDBC-odbc-1.1.4.4 ... linking ... done.
*** Exception: (unknown)
Prelude Database.HDBC Database.HDBC.ODBC handleSqlError $ conn - connectODBC 
dictation
interactive:1:0: Parse error in pattern



-- 
Dr Bean  If there is one thing we learn from the 
 study of language learning, it is that
 language learners learn more than we learn.  
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] HDBC-odbc 1.1.4.4 fixes Windows linking problems

2008-06-03 Thread Andrew Appleyard

On 4/06/2008 1:05 PM, Greg Matheson wrote:

I'm getting a 'Parse error in pattern' error.

C:\Documents and Settings\Administratorghci
GHCi, version 6.8.2: http://www.haskell.org/ghc/  :? for help
Loading package base ... linking ... done.
Prelude :m Database.HDBC.ODBC Database.HDBC
[...]
Prelude Database.HDBC Database.HDBC.ODBC handleSqlError $ conn - connectODBC 
dictation
interactive:1:0: Parse error in pattern


Try:

  conn - handleSqlError $ connectODBC dictation

You can only use '-' in a do expression, or at the GHCi prompt.

-- Andrew

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


Re: [Haskell-cafe] A simple beginner question

2008-06-03 Thread Don Stewart
adam.smyczek:
 Example:
 
 data SampleType = A | B Int | C String | D --  etc.
 
 sampleTypes = [A, B 5, C test] :: [SampleType]
 
 How do I find for example element A in the sampleTypes list?
 Do I have to create e.g.:
 
 isA :: SampleType - Bool
 isA A = True
 isA _ = False
 
 for every constructor and use find?
 It feels like this is not the quicker method.

This is where the implicit filtering in a list comprehension comes in
really handy,

data T = A | B Int | C String | D
deriving Show

xs = [A, B 5, C test, D]

main = do print [ A | A   - xs ] -- filter A's
  print [ x | x@(C _) - xs ] -- filter C's

{-

*Main main
[A]
[C test]

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


Re: [Haskell-cafe] A simple beginner question

2008-06-03 Thread Luke Palmer
On Tue, Jun 3, 2008 at 6:48 PM, Ronald Guida [EMAIL PROTECTED] wrote:
 filter (\x - case x of A - True; otherwise - False) sampleTypes
  == [A]

 filter (\x - case x of B _ - True; otherwise - False) sampleTypes
  == [B 5]

There's a neat little mini-trick for these types of pattern matches:

filter (\x - case x of B {} - True; otherwise - False) sampleTypes

Does the same thing, but works no matter how many arguments the
constructor B takes.

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


Re: [Haskell-cafe] [ANNOUNCE] git-darcs-import 0.1

2008-06-03 Thread Bertram Felgenhauer
Darrin Thompson wrote:
 On Sun, Jun 1, 2008 at 2:44 PM, Bertram Felgenhauer
 [EMAIL PROTECTED] wrote:
  I'm pleased to announce yet another tool for importing darcs repositories
  to git. [...]

 What's the appeal of this? I personally love git, but I thought all
 the cool kids at this school used darcs and that was that.

For myself, git-darcs-import itself is an opportunity to learn more
about both darcs and git. It wasn't meant to be argument in the git
vs. darcs discussion, although it was inevitable that it would be
seen as such.

I really like darcs' concepts, but in my opinion, darcs doesn't get
enough power out of the theory of patches to really shine so far.

This is a hard problem, and I can't offer solutions. Ideally, you'd have
semantic patches which just commute with virtually all other patches
because they know what they are about. The only thing that darcs
offers in that direction - besides handling conflicts, mergers and
undos gracefully, which is quite useful in itself - is a keyword
substitution patch type.

In the meantime, I prefer git to darcs, mainly because I'm sort of
attached to seeing the development history, i.e. I prefer to think of
patches as (partially) ordered instead of being a cloud of patches
that darcs uses as a model.

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