Re: [Haskell-cafe] Unicode workaround for getDirectoryContents under Windows?

2009-06-14 Thread Bulat Ziganshin
Hello Shu-yu,

Sunday, June 14, 2009, 7:41:46 AM, you wrote:

 It seems like getDirectoryContents applies codepage conversion based

it's not a bug, but old-fashioned architecture of entire file apis

you may find my Win32Files.hs module useful - it adopts UTF-16
versions of file operations

http://downloads.sourceforge.net/freearc/FreeArc-0.51-sources.tar.bz2



-- 
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] I need a hint in list processing

2009-06-14 Thread Fernan Bolando
Hi all

If I have a number of list
example
list1 = [2,3]
list2 = [1,2]
list3 = [2,3,4]
list4 = [1,2,3]

I want to create a list from the list above with n elements,
non-repeating and each elements index represents 1 of the elements
from the corresponding list so for the above input I would get.

a = [3,2,4,1]

ofcourse there may be several set that will satisfy the problem, so a
list of list that satisfies would be good.

How do I do this in haskell? or is there a code snippet that seems to
work similarly?

thanks
fernan

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


Re: [Haskell-cafe] I need a hint in list processing

2009-06-14 Thread Erik de Castro Lopo
Fernan Bolando wrote:

 Hi all
 
 If I have a number of list
 example
 list1 = [2,3]
 list2 = [1,2]
 list3 = [2,3,4]
 list4 = [1,2,3]
 
 I want to create a list from the list above with n elements,
 non-repeating and each elements index represents 1 of the elements
 from the corresponding list so for the above input I would get.
 
 a = [3,2,4,1]
 
 ofcourse there may be several set that will satisfy the problem, so a
 list of list that satisfies would be good.
 
 How do I do this in haskell? or is there a code snippet that seems to
 work similarly?

Well you could simply concatenate all the lists using the (++) operator
and then use Data.List.nub:

http://haskell.org/ghc/docs/latest/html/libraries/base/Data-List.html#v:nub

to remove duplicates.

Erik
-- 
--
Erik de Castro Lopo
http://www.mega-nerd.com/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] install problems ...

2009-06-14 Thread Duncan Coutts
On Thu, 2009-06-11 at 23:50 -0500, Vasili I. Galchin wrote:
 Hello,
 
   As I have said before I a, cabalizing Swish (a semantic web
 toolkit). I have it built and have run most of the original author's
 tests by and they pass. There are numerous warnings which seem to be
 either lack of a function type signature or unreferenced symbols ...
 I will go through one-by-one and clean these up. However, now I am
 getting the following install-time errors  any advice on how to
 track down will be greatly apprecriated  the following is the
 result of cabal build -v:
 
 Preprocessing executables for swish-0.2.1...
 Building swish-0.2.1...
 /usr/bin/ar: creating dist/build/libHSswish-0.2.1.a
 Warning: output was redirected with -o, but no output will be
 generated because there is no Main module.

This warning is very suspicious. Perhaps you can post your .cabal file.
I suspect that it's using an inappropriate ghc flag.

Duncan

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


Re: [Haskell-cafe] I need a hint in list processing

2009-06-14 Thread Fernan Bolando
On Sun, Jun 14, 2009 at 4:13 PM, Erik de Castro
Lopomle...@mega-nerd.com wrote:
 Fernan Bolando wrote:

 Hi all

 If I have a number of list
 example
 list1 = [2,3]
 list2 = [1,2]
 list3 = [2,3,4]
 list4 = [1,2,3]

 I want to create a list from the list above with n elements,
 non-repeating and each elements index represents 1 of the elements
 from the corresponding list so for the above input I would get.

 a = [3,2,4,1]

 ofcourse there may be several set that will satisfy the problem, so a
 list of list that satisfies would be good.

 How do I do this in haskell? or is there a code snippet that seems to
 work similarly?

 Well you could simply concatenate all the lists using the (++) operator
 and then use Data.List.nub:

    http://haskell.org/ghc/docs/latest/html/libraries/base/Data-List.html#v:nub

 to remove duplicates.

Using Data.List.nub
Data.List nub [2,3,1,2,2,3,4,1,2,3]
[2,3,1,4]

that is not exactly what I want. list1 only has 2,3 has elements and list2 only
has elements 1,2...this means the first element should only be 2 or 3 and
the second element should only have 1 or 2...etc

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


Re: [Haskell-cafe] I need a hint in list processing

2009-06-14 Thread Miguel Mitrofanov
ghci map reverse $ foldM (\answer list - [x:answer | x - list, not  
$ x `elem` answer]) [] [[2,3], [1,2], [2,3,4], [1,2,3]]

[[2,1,4,3],[3,1,4,2],[3,2,4,1]]

On 14 Jun 2009, at 12:06, Fernan Bolando wrote:


Hi all

If I have a number of list
example
list1 = [2,3]
list2 = [1,2]
list3 = [2,3,4]
list4 = [1,2,3]

I want to create a list from the list above with n elements,
non-repeating and each elements index represents 1 of the elements
from the corresponding list so for the above input I would get.

a = [3,2,4,1]

ofcourse there may be several set that will satisfy the problem, so a
list of list that satisfies would be good.

How do I do this in haskell? or is there a code snippet that seems to
work similarly?

thanks
fernan

--
http://www.fernski.com
___
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] install problems ...

2009-06-14 Thread Vasili I. Galchin
Hi Duncan,

 Actually it was do to a typo on an Executable

I specified N3Parser where I meant N3ParserTest = DUH . I am
totally ashamed .

Vasili

On Sun, Jun 14, 2009 at 3:31 AM, Duncan Coutts
duncan.cou...@worc.ox.ac.ukwrote:

 On Thu, 2009-06-11 at 23:50 -0500, Vasili I. Galchin wrote:
  Hello,
 
As I have said before I a, cabalizing Swish (a semantic web
  toolkit). I have it built and have run most of the original author's
  tests by and they pass. There are numerous warnings which seem to be
  either lack of a function type signature or unreferenced symbols ...
  I will go through one-by-one and clean these up. However, now I am
  getting the following install-time errors  any advice on how to
  track down will be greatly apprecriated  the following is the
  result of cabal build -v:
 
  Preprocessing executables for swish-0.2.1...
  Building swish-0.2.1...
  /usr/bin/ar: creating dist/build/libHSswish-0.2.1.a
  Warning: output was redirected with -o, but no output will be
  generated because there is no Main module.

 This warning is very suspicious. Perhaps you can post your .cabal file.
 I suspect that it's using an inappropriate ghc flag.

 Duncan


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


Re: [Haskell-cafe] install problems ...

2009-06-14 Thread Vasili I. Galchin
BTW is TimeDate a Hugism?


Vasili

On Sun, Jun 14, 2009 at 3:58 AM, Vasili I. Galchin vigalc...@gmail.comwrote:

 Hi Duncan,

  Actually it was do to a typo on an Executable

 I specified N3Parser where I meant N3ParserTest = DUH . I am
 totally ashamed .

 Vasili


 On Sun, Jun 14, 2009 at 3:31 AM, Duncan Coutts 
 duncan.cou...@worc.ox.ac.uk wrote:

 On Thu, 2009-06-11 at 23:50 -0500, Vasili I. Galchin wrote:
  Hello,
 
As I have said before I a, cabalizing Swish (a semantic web
  toolkit). I have it built and have run most of the original author's
  tests by and they pass. There are numerous warnings which seem to be
  either lack of a function type signature or unreferenced symbols ...
  I will go through one-by-one and clean these up. However, now I am
  getting the following install-time errors  any advice on how to
  track down will be greatly apprecriated  the following is the
  result of cabal build -v:
 
  Preprocessing executables for swish-0.2.1...
  Building swish-0.2.1...
  /usr/bin/ar: creating dist/build/libHSswish-0.2.1.a
  Warning: output was redirected with -o, but no output will be
  generated because there is no Main module.

 This warning is very suspicious. Perhaps you can post your .cabal file.
 I suspect that it's using an inappropriate ghc flag.

 Duncan



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


[Haskell-cafe] [cabal] How to deal with build-depency that not under cabal's control?

2009-06-14 Thread Magicloud Magiclouds
Hi,
  I use gtk2hs in linux. Well, I have no idea how to install gtk2hs by
cabal, but my program needs it, and I want my program cabalized. So
how to do this?
Thanks.
-- 
竹密岂妨流水过
山高哪阻野云飞
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Logo fun

2009-06-14 Thread Tim Attwood

Graphics are fun.

Here's my version.
http://s201.photobucket.com/albums/aa280/Zakardis/?action=viewcurrent=lambda_haskell_platform.png 



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


Re: [Haskell-cafe] How to know the build dependencies?

2009-06-14 Thread Deniz Dogan
2009/6/14 Gwern Branwen gwe...@gmail.com:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA512

 On Sat, Jun 13, 2009 at 10:22 PM, Magicloud Magiclouds wrote:
 Hi,
  I am learning to use cabal for my code.
  Just when I start, I met a question, is there an easy way to find
 out what packages my code depends?

 Thanks.

 Not really. The easiest way is to just build your code and add every
 package Cabal complains about being hid into your build-depends.
 (Usually this won't take more than a minute or 3 if you're toggling
 between a terminal and an editor.)

 - --
 gwern

Someone really ought to write a tool for this...

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


[Haskell-cafe] Running Hoogle as a cgi script.

2009-06-14 Thread Erik de Castro Lopo
Hi all,

I'd like to run my own version of Hoogle:

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

as a CGI script much like this:

   http://www.haskell.org/hoogle/

but there doesn't seem to be any documentation on how to do this.
Clues anyone?

Cheers,
Erik
-- 
--
Erik de Castro Lopo
http://www.mega-nerd.com/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to know the build dependencies?

2009-06-14 Thread Claus Reinke

 I am learning to use cabal for my code.
 Just when I start, I met a question, is there an easy way to find
out what packages my code depends?


If you've managed to get your code to compile,

   ghc --show-iface Main.hi

is perhaps the easiest way (ghc --make and ghci will also report 
package dependencies as they encounter them).


If you're looking for the package for a particular module, ghc-pkg
can help

   ghc-pkg find-module Control.Concurrent
   c:/ghc/ghc-6.10.3\package.conf:
   base-3.0.3.1, base-4.1.0.0

   ghc-pkg find-module Data.Map
   c:/ghc/ghc-6.10.3\package.conf:
   containers-0.2.0.1

If you're looking for a minimal set of imports before hunting for 
packages, ghc's -ddump-minimal-imports will create a file Main.imports 
with that information. You could then run ghc-pkg find-module over

that list.

These are not the only options. Perhaps the available tools 
need to be advertized more?-)


Claus


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


Re: [Haskell-cafe] [cabal] How to deal with build-depency that not under cabal's control?

2009-06-14 Thread Roman Cheplyaka
* Magicloud Magiclouds magicloud.magiclo...@gmail.com [2009-06-14 
17:30:33+0800]
 Hi,
   I use gtk2hs in linux. Well, I have no idea how to install gtk2hs by
 cabal, but my program needs it, and I want my program cabalized. So
 how to do this?
 Thanks.

gtk2hs consists of several cabal packages, e.g. gtk, glib and so on.
(See `ghc-pkg list`)
Specify those of them you need as dependencies in cabal file.

-- 
Roman I. Cheplyaka :: http://ro-che.info/
Don't let school get in the way of your education. - Mark Twain
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] curious about sum

2009-06-14 Thread Roman Cheplyaka
* Deniz Dogan deniz.a.m.do...@gmail.com [2009-06-13 16:17:57+0200]
 I remember needing a non-strict sum at least once, but I do not
 remember the exact application.

We may agree that lazy sum is sometimes (rarely) needed, but then it can
be always written as fold. However, in most cases user wants strict sum.

So it's not really an excuse.

-- 
Roman I. Cheplyaka :: http://ro-che.info/
Don't let school get in the way of your education. - Mark Twain
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] [cabal] How to deal with build-depency that not under cabal's control?

2009-06-14 Thread Roman Cheplyaka
* Magicloud Magiclouds magicloud.magiclo...@gmail.com [2009-06-14 
18:48:26+0800]
 My gtk2hs is install manually, `configure  make  make install`. So

It's okay.

 when I add gtk to build-dependency, it tells me
 Setup.hs: At least the following dependencies are missing:
 gtk -any

Installation of gtk2hs registers these packages for you.
Again, check `ghc-pkg list gtk`. If you installed gtk2hs, it must be
there. If you, say, upgraded your ghc after you installed gtk2hs, you
have to reinstall gtk2hs. 

 How to register my manual-installed gtk2hs to cabal?
 
 On Sun, Jun 14, 2009 at 6:25 PM, Roman Cheplyakar...@ro-che.info wrote:
  * Magicloud Magiclouds magicloud.magiclo...@gmail.com [2009-06-14 
  17:30:33+0800]
  Hi,
    I use gtk2hs in linux. Well, I have no idea how to install gtk2hs by
  cabal, but my program needs it, and I want my program cabalized. So
  how to do this?
  Thanks.
 
  gtk2hs consists of several cabal packages, e.g. gtk, glib and so on.
  (See `ghc-pkg list`)
  Specify those of them you need as dependencies in cabal file.
 
  --
  Roman I. Cheplyaka :: http://ro-che.info/
  Don't let school get in the way of your education. - Mark Twain
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 
 
 
 -- 
 竹密岂妨流水过
 山高哪阻野云飞

-- 
Roman I. Cheplyaka :: http://ro-che.info/
Don't let school get in the way of your education. - Mark Twain
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to know the build dependencies?

2009-06-14 Thread Krzysztof Skrzętnicki
If your module compiles, you can get the info by passing '-ddump-types':

TYPE SIGNATURES
numbersTests :: Test
testAverage :: Test
testBindInt :: Test
TYPE CONSTRUCTORS
Dependent modules: [(MoresmauJP.Util.Numbers, False)]
Dependent packages: [HUnit-1.2.0.3, base, ghc-prim, integer]

It is, however, available only after your code has successfully compiled.

Best regards

Krzysztof Skrzętnicki

On Sun, Jun 14, 2009 at 04:22, Magicloud
Magicloudsmagicloud.magiclo...@gmail.com wrote:
 Hi,
  I am learning to use cabal for my code.
  Just when I start, I met a question, is there an easy way to find
 out what packages my code depends?

 Thanks.
 ___
 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] How to know the build dependencies?

2009-06-14 Thread Gwern Branwen
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

On Sun, Jun 14, 2009 at 6:05 AM, Deniz Dogan wrote:
 Someone really ought to write a tool for this...

Well, it's an issue of time. Just building and adding the deps is fast
and straightforward. A tool I'd need to know about, have installed,
and remember to use in the middle of a Cabalizing session. The people
who most need such a tool are those who are least likely to use it.
And given the overhead, it's unclear that it would actually save time.
Sometimes, somethings aren't worth automating.

Now, if someone were to create such a tool and integrate it into
'mkcabal', then it might make sense. You could create the basic .cabal
with the build-depends filled in. But as a separate tool it's too
small a task to handle. Even memorizing the -show-iface or
- -ddump-types options may not be worthwhile - how often does one create
Cabal packages from scratch?

- --
gwern
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEAREKAAYFAko1BWEACgkQvpDo5Pfl1oKvigCeO7ABRVr/9+kT62dIFpo0k5+f
y/AAnR6wLaDpX5/lZPqQzB/Wb4kuj8i9
=L2iA
-END PGP SIGNATURE-
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to know the build dependencies?

2009-06-14 Thread Deniz Dogan
2009/6/14 Gwern Branwen gwe...@gmail.com:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA512

 On Sun, Jun 14, 2009 at 6:05 AM, Deniz Dogan wrote:
 Someone really ought to write a tool for this...

 Well, it's an issue of time. Just building and adding the deps is fast
 and straightforward. A tool I'd need to know about, have installed,
 and remember to use in the middle of a Cabalizing session. The people
 who most need such a tool are those who are least likely to use it.
 And given the overhead, it's unclear that it would actually save time.
 Sometimes, somethings aren't worth automating.

 Now, if someone were to create such a tool and integrate it into
 'mkcabal', then it might make sense. You could create the basic .cabal
 with the build-depends filled in. But as a separate tool it's too
 small a task to handle. Even memorizing the -show-iface or
 - -ddump-types options may not be worthwhile - how often does one create
 Cabal packages from scratch?

I'm sorry, I was not aware of those flags when I wrote my message. You're right.

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


[Haskell-cafe] Haskell - string to list isusses, and more

2009-06-14 Thread Gjuro Chensen

Hello everyone! 

Im a Haskell newbie, and Ive have few unanswered questions. For someone more
experienced (at least I think so) its a very simple task, but I just cant
get a grip on it and its pretty frustrating. It wouldn't be that bad if I
haven't browse thru bunch of pages and tutorials and still nothing...
The problem is: take a string, and if every words starts with uppercase
letter then print yes, else no.
Forum Text Bold - yes
Frog image File - no

Ive had my share of approaches to this, but I just cant make it work. 
Standard one seemed the most simple:

search :: String - String
search [] = []


and then use words (splits string on space) to split the string so I could
get a list and go through it recursively. But how to apply words to entered
string in this form? 

To find the first letter I came up with: first = take 1 (head x). And
compare it with elem or ASCII values to determine if its upper case.

Any help, advice or suggestion is appreciated.

Thanks in advance!

-- 
View this message in context: 
http://www.nabble.com/Haskell---string-to-list-isusses%2C-and-more-tp24022673p24022673.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] Haskell - string to list isusses, and more

2009-06-14 Thread Deniz Dogan
2009/6/14 Gjuro Chensen daim...@gmail.com:

 Hello everyone!

 Im a Haskell newbie, and Ive have few unanswered questions. For someone more
 experienced (at least I think so) its a very simple task, but I just cant
 get a grip on it and its pretty frustrating. It wouldn't be that bad if I
 haven't browse thru bunch of pages and tutorials and still nothing...
 The problem is: take a string, and if every words starts with uppercase
 letter then print yes, else no.
 Forum Text Bold - yes
 Frog image File - no

 Ive had my share of approaches to this, but I just cant make it work.
 Standard one seemed the most simple:

 search :: String - String
 search [] = []


 and then use words (splits string on space) to split the string so I could
 get a list and go through it recursively. But how to apply words to entered
 string in this form?

 To find the first letter I came up with: first = take 1 (head x). And
 compare it with elem or ASCII values to determine if its upper case.

 Any help, advice or suggestion is appreciated.

 Thanks in advance!

 --
 View this message in context: 
 http://www.nabble.com/Haskell---string-to-list-isusses%2C-and-more-tp24022673p24022673.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


As you say, there are a number of possible approaches to take here.
I'd say take a look at functions all [1] and isUpper [2], those
should be all you need.

* all takes a predicate (a function) and a list of elements. It
  returns True if that predicate holds for all of the elements in the
  list, otherwise False.

* isUpper takes a Char and returns True if that character is an
  uppercase letter, otherwise False.

[1] http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html
[2] http://haskell.org/ghc/docs/latest/html/libraries/base/Data-Char.html

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


Re: [Haskell-cafe] Haskell - string to list isusses, and more

2009-06-14 Thread Jochem Berndsen
Gjuro Chensen wrote:
 Hello everyone! 
 
 Im a Haskell newbie, and Ive have few unanswered questions. For someone more
 experienced (at least I think so) its a very simple task, but I just cant
 get a grip on it and its pretty frustrating. It wouldn't be that bad if I
 haven't browse thru bunch of pages and tutorials and still nothing...
 The problem is: take a string, and if every words starts with uppercase
 letter then print yes, else no.
 Forum Text Bold - yes
 Frog image File - no
 
 Ive had my share of approaches to this, but I just cant make it work. 
 Standard one seemed the most simple:
 
 search :: String - String
 search [] = []
 
 
 and then use words (splits string on space) to split the string so I could
 get a list and go through it recursively. But how to apply words to entered
 string in this form? 
 
 To find the first letter I came up with: first = take 1 (head x). And
 compare it with elem or ASCII values to determine if its upper case.

The idea of using `words' is very good.
If we want to use a bottom-up approach, we should have a function that
determines if a word starts with an upper-case letter, i.e. a function
of type
startsWithUppercase :: String - Bool
startsWithUppercase  = ...

(Hint: look at 'isUpper' from Data.Char)

Now we need a way to see if for each word, some predicate is satisfied.
There is a standard function for this, all.
You can also do this by using map and and.

The resulting function can be very concise if you get the hang of it :)

Regards,
-- 
Jochem Berndsen | joc...@functor.nl
GPG: 0xE6FABFAB
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell - string to list isusses, and more

2009-06-14 Thread Deniz Dogan
2009/6/14 Deniz Dogan deniz.a.m.do...@gmail.com:
 I'd say take a look at functions all [1] and isUpper [2], those
 should be all you need.

Sorry, words is also needed for the idea I was thinking of.

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


Re: [Haskell-cafe] Haskell - string to list isusses, and more

2009-06-14 Thread Daniel Fischer
Am Sonntag 14 Juni 2009 17:19:22 schrieb Gjuro Chensen:
 Hello everyone!

 Im a Haskell newbie, and Ive have few unanswered questions. For someone
 more experienced (at least I think so) its a very simple task, but I just
 cant get a grip on it and its pretty frustrating. It wouldn't be that bad
 if I haven't browse thru bunch of pages and tutorials and still nothing...
 The problem is: take a string, and if every words starts with uppercase
 letter then print yes, else no.
 Forum Text Bold - yes
 Frog image File - no

 Ive had my share of approaches to this, but I just cant make it work.
 Standard one seemed the most simple:

 search :: String - String
 search [] = []


 and then use words (splits string on space) to split the string so I could

That's good.
So you have

everyWordStartsWithAnUppercaseLetter string = doSomething (words string)

doSomething :: [String] - Bool

checks

wordStartsWithAnUppercaseLetter :: String - Bool

for each word in the list and returns True if all words satisfy the condition, 
False if 
not.

There's a handy function in the prelude for that:

Prelude :t all
all :: (a - Bool) - [a] - Bool

 get a list and go through it recursively. But how to apply words to entered
 string in this form?

 To find the first letter I came up with: first = take 1 (head x). And

No, I don't think that's what you want:

Prelude :t (take 1 . head)
(take 1 . head) :: [[a]] - [a]

Since String is a synonym for [Char], head gets the first letter of a word.

 compare it with elem or ASCII values to determine if its upper case.

What about unicode strings?

Prelude :t Data.Char.isUpper
Data.Char.isUpper :: Char - Bool

is what you want.


 Any help, advice or suggestion is appreciated.

 Thanks in advance!

How to assemble that is left to you.

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


Re: [Haskell-cafe] Haskell - string to list isusses, and more

2009-06-14 Thread Toby Miller
Here's what I came up with.  I especially like the 2nd version, even  
though it's longer, as it seems very declarative.


caps1 s = all (\x - isUpper (head x)) (words s)

caps2 s = all startsWithUpper (words s) where
startsWithUpper w = isUpper (head w)


I'm also fairly new to Haskell, so I would appreciate feedback from  
the more experienced.


Thanks.


On Jun 14, 2009, at 11:19 AM, Gjuro Chensen wrote:



Hello everyone!

Im a Haskell newbie, and Ive have few unanswered questions. For  
someone more
experienced (at least I think so) its a very simple task, but I just  
cant
get a grip on it and its pretty frustrating. It wouldn't be that bad  
if I

haven't browse thru bunch of pages and tutorials and still nothing...
The problem is: take a string, and if every words starts with  
uppercase

letter then print yes, else no.
Forum Text Bold - yes
Frog image File - no

Ive had my share of approaches to this, but I just cant make it work.
Standard one seemed the most simple:

search :: String - String
search [] = []


and then use words (splits string on space) to split the string so I  
could
get a list and go through it recursively. But how to apply words to  
entered

string in this form?

To find the first letter I came up with: first = take 1 (head x). And
compare it with elem or ASCII values to determine if its upper case.

Any help, advice or suggestion is appreciated.

Thanks in advance!

--
View this message in context: 
http://www.nabble.com/Haskell---string-to-list-isusses%2C-and-more-tp24022673p24022673.html
Sent from the Haskell - Haskell-Cafe mailing list archive at  
Nabble.com.


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


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


Re: [Haskell-cafe] Haskell - string to list isusses, and more

2009-06-14 Thread Jochem Berndsen
Toby Miller wrote:
 Here's what I came up with.  I especially like the 2nd version, even
 though it's longer, as it seems very declarative.
 
 caps1 s = all (\x - isUpper (head x)) (words s)
 
 caps2 s = all startsWithUpper (words s) where
 startsWithUpper w = isUpper (head w)
 
 
 I'm also fairly new to Haskell, so I would appreciate feedback from the
 more experienced.

This seems fine, but you need to check that words never returns a list
containing the empty string (otherwise `head' will fail).

I prefer in this case a point free style though, but some might disagree.

Cheers,
-- 
Jochem Berndsen | joc...@functor.nl
GPG: 0xE6FABFAB
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell - string to list isusses, and more

2009-06-14 Thread Deniz Dogan
2009/6/14 Toby Miller t...@miller.ms:
 Here's what I came up with.  I especially like the 2nd version, even though
 it's longer, as it seems very declarative.

 caps1 s = all (\x - isUpper (head x)) (words s)

 caps2 s = all startsWithUpper (words s) where
    startsWithUpper w = isUpper (head w)


 I'm also fairly new to Haskell, so I would appreciate feedback from the more
 experienced.

 Thanks.

Not that I'm very experienced myself, but I came up with the first idea as well:

caps1 = all (isUpper . head) . words

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


Re: [Haskell-cafe] Haskell - string to list isusses, and more

2009-06-14 Thread Andrew Coppin

Toby Miller wrote:
Here's what I came up with.  I especially like the 2nd version, even 
though it's longer, as it seems very declarative.


caps1 s = all (\x - isUpper (head x)) (words s)

caps2 s = all startsWithUpper (words s) where
startsWithUpper w = isUpper (head w)


I'm also fairly new to Haskell, so I would appreciate feedback from 
the more experienced.


Thanks.


caps = all (isUpper . head) . words

But then, I'm strange like that...

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


Re: [Haskell-cafe] Haskell - string to list isusses, and more

2009-06-14 Thread Deniz Dogan
2009/6/14 Jochem Berndsen joc...@functor.nl:
 Toby Miller wrote:
 caps1 s = all (\x - isUpper (head x)) (words s)
 This seems fine, but you need to check that words never returns a list
 containing the empty string (otherwise `head' will fail).

Is there any such case? I was thinking about that as well, but
couldn't think of any case where head would be called on an empty
list.

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


Re: [Haskell-cafe] Haskell - string to list isusses, and more

2009-06-14 Thread Jochem Berndsen
Deniz Dogan wrote:
 2009/6/14 Jochem Berndsen joc...@functor.nl:
 Toby Miller wrote:
 caps1 s = all (\x - isUpper (head x)) (words s)
 This seems fine, but you need to check that words never returns a list
 containing the empty string (otherwise `head' will fail).
 
 Is there any such case? I was thinking about that as well, but
 couldn't think of any case where head would be called on an empty
 list.

Not that I know of; but I tested this in order to make sure that I
didn't overlook something obvious. (At least, it's a potential issue
that we need to check, since `head' is partial.)

Regards,

-- 
Jochem Berndsen | joc...@functor.nl
GPG: 0xE6FABFAB
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to know the build dependencies?

2009-06-14 Thread Toby Miller


On Jun 14, 2009, at 6:05 AM, Deniz Dogan wrote:


2009/6/14 Gwern Branwen gwe...@gmail.com:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

On Sat, Jun 13, 2009 at 10:22 PM, Magicloud Magiclouds wrote:

Hi,
 I am learning to use cabal for my code.
 Just when I start, I met a question, is there an easy way to find
out what packages my code depends?

Thanks.


Not really. The easiest way is to just build your code and add every
package Cabal complains about being hid into your build-depends.
(Usually this won't take more than a minute or 3 if you're toggling
between a terminal and an editor.)

- --
gwern


Someone really ought to write a tool for this...





Visualising the Haskell Universe « Control.Monad.Writer___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell - string to list isusses, and more

2009-06-14 Thread Gjuro Chensen



Gjuro Chensen wrote:
 
 
 /cut
 
 

I dont know everyone will see this, but I would like thank everyone who
found time to help, and not spam too much doing it:D. 
Well, I did it! Its not great (especially comparing to those one line
solutions, wow!), but it works.

module Main where

startsWithUpper :: String - Bool
startsWithUpper []= False
startsWithUpper string =
if myIsUpper(head(string)) then True 
else False

myIsUpper :: Char - Bool
myIsUpper x =
if x='A'  x = 'Z' then True 
else False

checkAll string = check (words string)

check :: [String] - Bool
check []=False
check x = 
if all startsWithUpper x then True
else False


Since importing modules isnt allowed, I made my own isUpper. And thats it,
for few days of Haskell, Im happy.

Once again, many many thanks to everyone!


-- 
View this message in context: 
http://www.nabble.com/Haskell---string-to-list-isusses%2C-and-more-tp24022673p24023759.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] Haskell - string to list isusses, and more

2009-06-14 Thread Jochem Berndsen
Gjuro Chensen wrote:
 startsWithUpper :: String - Bool
 startsWithUpper []= False
 startsWithUpper string =
   if myIsUpper(head(string)) then True 
   else False

It is very good that you caught the issue of taking the head of an empty
list :)
I saw here and also below, that you did things like
if P then True else False
You can shorten this to 'P'.

Also, normally Haskellers like to pattern match, changing the second
clause of your function into
startsWithUpper (x:xs) = myIsUpper x

 check :: [String] - Bool
 check []=False

Why is this False and not True? Certainly in the empty string all words
start with an uppercase letter, don't they? (If it's True, you can even
remove this clause, and let the other one take care of the rest.)

Regards,

-- 
Jochem Berndsen | joc...@functor.nl
GPG: 0xE6FABFAB
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] slow code

2009-06-14 Thread brian

Haskell Gurus,

I have tried to use profiling to tell me what's going on here, but it  
hasn't helped much, probably because I'm not interpreting the results  
correctly.


Empirically I have determined that the show's are pretty slow, so an  
alternative to them would be helpful.  I replaced the show's with ,  
and compiled with -O2 and not much improvement.


I need to write _a lot_ of code in this style.  A few words about how  
best to do this would be helpful.  Laziness, infinite lists, uvector ??


Help...

Thanks,

Brian


import Complex
import System.IO

genData :: Double - Int - (Double - Complex Double) - ([Double],  
[Complex Double])

genData tstop n f =
let deltat = tstop / (fromIntegral n)
t = [ fromIntegral(i) * deltat | i - [0..n-1]]
in
  (t, map f t)

main =
do let (t, y) = genData 100.0E-6 (2 ^ 15) (\x - x :+ 0.0)
   h - openFile data.txt WriteMode
   mapM_ (\(x, y) -
  do hPutStr h (show t)
 hPutStr h  
 hPutStrLn h (show (realPart y)))
 (zip t y)
   hClose h
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Fwd: [Haskell-cafe] curious about sum

2009-06-14 Thread Alberto G. Corona
Once more I forgot to send my messages to the haskell cafe list. All the
rest of the list which I´m suscribed to, send  the mail replies to the list
automatically, but this doesn´t. Please, can this be changed?.

-- Forwarded message --
From: Alberto G. Corona agocor...@gmail.com
Date: 2009/6/13
Subject: Re: [Haskell-cafe] curious about sum
To: Deniz Dogan deniz.a.m.do...@gmail.com


first, I was completely wrong. It is foldl what is neccesary. sum is
defined in terms of foldl:

sum= foldl (+) 0

but
Prelude foldl (+)  0 [1..100]
*** Exception: stack overflow

that is not because + is non strict, but because foldl is:

foldl f z0 xs0 = lgo z0 xs0
where
   lgo z [] =  z
   lgo z (x:xs) = lgo (f z x) xs

this version of foldl IS strict:

foldlStrict f z0 xs0 = lgo z0 xs0
where
   lgo z [] =  z
   lgo z (x:xs) =let t= f z x in t `seq` lgo t xs

main= print $  foldlStrict (+) 0 [1..100]
5050

so the garbage collector do the job in freeing the consumed part of the
list.

2009/6/13 Alberto G. Corona agocor...@gmail.com

 Prelude let strictplus x y= let z=x +y in z `seq` z; sum1= foldr
 strictplus 0 in sum1[0..100]
 *** Exception: stack overflow
 I suppose that strictplus is strict, so the garbage collector would free
the consumed part of the list.
 Then, why the stack overflow?
 2009/6/13 Deniz Dogan deniz.a.m.do...@gmail.com

 2009/6/13 Jochem Berndsen joc...@functor.nl:
  Keith Sheppard wrote:
  Is there any reason that sum isn't strict? I can't think of any case
  where that is a good thing.
 
  Prelude sum [0 .. 100]
  *** Exception: stack overflow
 
  It is useful if the (+) is nonstrict; although I cannot think of any
  useful mathematical structure where (+) would be nonstrict.

 I remember needing a non-strict sum at least once, but I do not
 remember the exact application. But imagine having a (very) long list
 of numbers and you want to do A if the sum exceeds a small number,
 otherwise B.

 if sum [0..10]  10 then A else B

 However, this idea didn't work, because of strictness.

 --
 Deniz Dogan
 ___
 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] curious about sum

2009-06-14 Thread Thomas Davie


On 14 Jun 2009, at 12:47, Roman Cheplyaka wrote:


* Deniz Dogan deniz.a.m.do...@gmail.com [2009-06-13 16:17:57+0200]

I remember needing a non-strict sum at least once, but I do not
remember the exact application.


We may agree that lazy sum is sometimes (rarely) needed, but then it  
can
be always written as fold. However, in most cases user wants strict  
sum.


So it's not really an excuse.


How's this for an excuse - Haskell is a lazy language.  It also  
happens to have support for strictifying things when necessary.  The  
Haskell API is designed to be lazy, like the rest of the language,  
similarly though, where commonly used, strict versions are provided,  
like for example foldl'.


A much better idea than making sum strict, would simply be to add a  
sum'.


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


Re: Fwd: [Haskell-cafe] curious about sum

2009-06-14 Thread Jochem Berndsen
Alberto G. Corona wrote:
 Once more I forgot to send my messages to the haskell cafe list. All the
 rest of the list which I´m suscribed to, send  the mail replies to the list
 automatically, but this doesn´t. Please, can this be changed?.

This comes up every so often, but I would be against this. Your e-mail
client should support mailing lists.

 this version of foldl IS strict:
 
 foldlStrict f z0 xs0 = lgo z0 xs0
 where
lgo z [] =  z
lgo z (x:xs) =let t= f z x in t `seq` lgo t xs
 
 main= print $  foldlStrict (+) 0 [1..100]
 5050
 
 so the garbage collector do the job in freeing the consumed part of the
 list

This is correct; the function you defined is equivalent to foldl' in
Data.List, if I'm not mistaken.

Regards,
-- 
Jochem Berndsen | joc...@functor.nl
GPG: 0xE6FABFAB
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] curious about sum

2009-06-14 Thread Claus Reinke
A much better idea than making sum strict, would simply be to add a  
sum'.


Even better to abstract over strictness, to keep a lid on code duplication?

   {-# LANGUAGE TypeOperators #-}

   sum  = foldlS ($)  (+) 0
   sum' = foldlS ($!) (+) 0

   -- identity on constructors of t (from a), modulo strictness in a
   type a :-? t = (a - t) - (a - t)

   foldlS ::  (b :-? ([a] - b)) - (a - b - b) - (b - [a] - b)
   foldlS ($) op n []= n
   foldlS ($) op n (h:t) = (foldlS ($) op $ (op h n)) t

Strictness is encoded as a constructor transformer - ($) keeps the
constructor in question unchanged, ($!) makes it strict. Also works 
with container types (Maps strict or not strict in their elements can
share the same strictness-abstracted code, for instance). Though 
sometimes there is more than one strictness choice to make in the 
same piece of code..


Claus


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


[Haskell-cafe] traversal transformations

2009-06-14 Thread Sjoerd Visscher

Hi,

While playing with Church Encodings of data structures, I realized  
there are generalisations in the same way Data.Foldable and  
Data.Traversable are generalisations of lists.


The normal Church Encoding of lists is like this:

 newtype List a = L { unL :: forall b. (a - b - b) - b - b }

It represents a list by a right fold:

 foldr f z l = unL l f z

List can be constructed with cons and nil:

 nil  = L $ \f - id
 cons a l = L $ \f - f a . unL l f

Oleg has written about this: http://okmij.org/ftp/Haskell/zip-folds.lhs

Now function of type (b - b) are endomorphisms which have a  
Data.Monoid instance, so the type can be generalized:


 newtype FM a = FM { unFM :: forall b. Monoid b = (a - b) - b }
 fmnil  = FM $ \f - mempty
 fmcons a l = FM $ \f - f a `mappend` unFM l f

Now lists are represented by (almost) their foldMap function:

 instance Foldable FM where
   foldMap = flip unFM

But notice that there is now nothing list specific in the FM type,  
nothing prevents us to add other constructor functions.


 fmsnoc l a = FM $ \f - unFM l f `mappend` f a
 fmlist = fmcons 2 $ fmcons 3 $ fmnil `fmsnoc` 4 `fmsnoc` 5

*Main getProduct $ foldMap Product fmlist
120

Now that we have a container type represented by foldMap, there's  
nothing stopping us to do a container type represented by traverse  
from Data.Traversable:


{-# LANGUAGE RankNTypes #-}

import Data.Monoid
import Data.Foldable
import Data.Traversable
import Control.Monad
import Control.Applicative

newtype Container a = C { travC :: forall f b . Applicative f = (a -  
f b) - f (Container b) }


czero :: Container a
cpure :: a - Container a
ccons :: a - Container a - Container a
csnoc :: Container a - a - Container a
cpair :: Container a - Container a - Container a
cnode :: Container a - a - Container a - Container a
ctree :: a - Container (Container a) - Container a
cflat :: Container (Container a) - Container a

czero   = C $ \f - pure czero
cpure x = C $ \f - cpure $ f x
ccons x l   = C $ \f - ccons $ f x * travC l f
csnoc l x   = C $ \f - csnoc $ travC l f * f x
cpair l r   = C $ \f - cpair $ travC l f * travC r f
cnode l x r = C $ \f - cnode $ travC l f * f x * travC r f
ctree x l   = C $ \f - ctree $ f x * travC l (traverse f)
cflat l = C $ \f - cflat $ travC l (traverse f)

instance Functor Container where
  fmap g c = C $ \f - travC c (f . g)
instance Foldable Container where
  foldMap  = foldMapDefault
instance Traversable Container where
  traverse = flip travC
instance Monad Container where
  return   = cpure
  m = f  = cflat $ fmap f m
instance Monoid (Container a) where
  mempty   = czero
  mappend  = cpair

Note that there are all kinds of constructors, and they can all be  
combined. Writing their definitions is similar to how you would write  
Traversable instances.


So I'm not sure what we have here, as I just ran into it, I wasn't  
looking for a solution to a problem. It is also all quite abstract,  
and I'm not sure I understand what is going on everywhere. Is this  
useful? Has this been done before? Are there better implementations of  
foldMap and (=) for Container?


Finally, a little example. A Show instance (for debugging purposes)  
which shows the nesting structure.


newtype ShowContainer a = ShowContainer { doShowContainer :: String }
instance Functor ShowContainer where
  fmap _ (ShowContainer x) = ShowContainer $ ( ++ x ++ )
instance Applicative ShowContainer where
  pure _ = ShowContainer ()
  ShowContainer l * ShowContainer r = ShowContainer $ init l ++ ,  
++ r ++ )

instance Show a = Show (Container a) where
  show = doShowContainer . traverse (ShowContainer . show)

greetings,
--
Sjoerd Visscher
sjo...@w3future.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Wiki user accounts

2009-06-14 Thread Gwern Branwen
On Fri, Jun 12, 2009 at 12:46 PM, Gwern Branwengwe...@gmail.com wrote:
...
 If I might suggest some users we might give the bit to: myself, dons,
 Magnus Therning, Neil Mitchell, and byorgey. All have been editing the
 wiki for some time, some have administrator experience on Wikipedia,
 and all have commit bits for various Haskell repos (and so presumably
 can be trusted). (Of course, this list isn't intended to be
 exhaustive; they're just who comes to mind looking over Recent
 Changes.)

I've spoken with John Peterson (the other admin/bureaucrat besides
Ashley), and he has no problem with giving these people the bit. If
there aren't any objections by next Saturday/Sunday, I will email him
and ask him to do so.

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


[Haskell-cafe] Re: Wiki user accounts

2009-06-14 Thread Ashley Yakeley

Gwern Branwen wrote:

This runs on MediaWiki, right? How about adding a CAPTCHA for account
registrations?

http://www.mediawiki.org/wiki/Extension:ConfirmEdit


See http://haskell.org/haskellwiki/Special:Version

ConfirmEdit would require an upgrade.


This is the ideal solution. But it requires an update of the machine 
from an old Red Hat distro (RHEL AS release 3 update 9) to something a 
bit more modern, like Debian 5.0 or Ubuntu Server 9.04.


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


[Haskell-cafe] Re: Wiki user accounts

2009-06-14 Thread Ashley Yakeley

Gwern Branwen wrote:

 Presumably Ashley is busy.

Yes. Average request rate is about one each day; I tend to do them in a 
lump about once a week.



One solution would be to have Ashley re-enable user registrations.
This has been suggested before, but no one knows how bad the spam
would be.


Basically, someone was creating thousands of accounts automatically. It 
seems likely this will happen again.



Another solution would be to sysop a few users to
admin/bureaucrat, so that even if a few are inactive or away, the rest
can handle requests.


What would the process be?

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


Re: [Haskell-cafe] Runtime strictness analysis for polymorphic HOFs?

2009-06-14 Thread Eugene Kirpichov
2009/6/15 Paul Chiusano paul.chius...@gmail.com:
 Hello,
 I was recently trying to figure out if there was a way, at runtime, to do
 better strictness analysis for polymorphic HOFs, for which the strictness of
 some arguments might depend on the strictness of the strictness of function
 types that are passed as arguments [1]. As an example, consider foldl. The
 'seed' parameter of foldl can be made strict as long as the binary function
 used for the fold is strict in its arguments. Unfortunately, because
 strictness analysis is done statically, Haskell can't assume anything about
 the strictness of the binary function - assuming we only compile one
 instance of foldl, it must be the most conservative version possible, and
 that means making the seed parameter lazy. :-(
 I started thinking about ways you could to a check at runtime for this sort
 of thing, something to the effect of asking foldl, before heap-allocating a
 thunk for the seed parameter, whether that parameter could be made strict.
 foldl could then inspect other arguments that have been supplied, and based
 on these arguments, evaluate or go ahead with creating a thunk the seed
 parameter. It's a runtime cost, sure, but would it be more than the cost of
 having to do an additional heap allocation? In any case a small runtime cost
 might be worth it if the analysis becomes more uniform.
 So, my question is: does doing this sort of runtime analysis seem like a
 horrible idea? Is it even possible? Has anyone tried this in the past? (So
 far I haven't found anything, but would love references if people have
 them.)
 Note that I'm not suggesting Haskell should do anything like this. I'm
 playing around with the ideas because I'm interesting in creating a lazy
 language and I was hoping to have strictness analysis be very predictable
 and uniform, something the programmer can count on and use to simply reason
 about space usage ... which might be hopelessly unrealistic goal! I guess
 the more general question is - is perfect strictness analysis (however
 that is defined) possible, if we're willing to incur some runtime cost? What
 would that look like?

The idea looks cool, but perfect strictness analysis is not possible,
t.i. the problem of determining whether f _|_ = _|_ is undecidable,
since it is a non-trivial property of f (there exist f's for which it
is true, and ones for which it is false) and non-trivial properties
are undecidable, thanks to Rice theorem.

 Best,
 Paul
 [1]:
 More background on my thinking here - a bit half-baked, so bear with me!
   http://pchiusano.blogspot.com/2009/06/perfect-strictness-analysis-part-1.html
   http://pchiusano.blogspot.com/2009/06/perfect-strictness-analysis-part-2.html

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





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


[Haskell-cafe] Performance of functional priority queues

2009-06-14 Thread Richard O'Keefe

There's a current thread in the Erlang mailing list about
priority queues.  I'm aware of, for example, the Brodal/Okasaki
paper and the David King paper. I'm also aware of James Cook's
priority queue package in Hackage, have my own copy of Okasaki's
book, and have just spent an hour searching the web.

One of the correspondents in that thread claims that it is
provably impossible to have an efficient priority queue implementation
without mutability.  I think he's cuckoo.  But I'd like to have some
numbers to back me up.

Can anyone point me to some actual benchmark results comparing
priority queue performance *with* mutation and priority queue
performance *without* mutation, in the same functional or
mostly-functional language?




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


Re: [Haskell-cafe] I need a hint in list processing

2009-06-14 Thread Richard O'Keefe


On 14 Jun 2009, at 8:06 pm, Fernan Bolando wrote:


Hi all

If I have a number of list
example
list1 = [2,3]
list2 = [1,2]
list3 = [2,3,4]
list4 = [1,2,3]

I want to create a list from the list above with n elements,
non-repeating and each elements index represents 1 of the elements
from the corresponding list so for the above input I would get.

a = [3,2,4,1]


I have been staring at this off and on all day,
and I haven't the faintest idea what you want.

What is n.  What is it that doesn't repeat?
How does the index of an element represent 1 element?
Which list corresponds to what?

I'm beginning to suspect that what you want is a choice
function:
f [s1,...,sn] = [x1,...,xn]
when each xi is an element of the corresponding si
and no two xs are the same.

Instead of finding one answer, let's find them all.

all_choices :: Eq a = [[a]] - [[a]]
all_choices [] = [[]]
all_choices (set:sets) =
  [x:xs | xs - all_choices sets, x  - set, not(x `elem` xs)]

The test case

all_choices [[2,3], [1,2], [2,3,4], [1,2,3]]

has the answer

[[3,2,4,1], [3,1,4,2], [2,1,4,3]]

and you probably want to use it something like

case all_choices sets of
  [] - there are no such choices
  (first_choice:_) - first_choice is one such choice

For inputs like [[1,2],[2,1],[1]] there is of course no such
choice function.


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


Re: [Haskell-cafe] I need a hint in list processing

2009-06-14 Thread Tony Morris
nub . concat ?

Richard O'Keefe wrote:

 On 14 Jun 2009, at 8:06 pm, Fernan Bolando wrote:

 Hi all

 If I have a number of list
 example
 list1 = [2,3]
 list2 = [1,2]
 list3 = [2,3,4]
 list4 = [1,2,3]

 I want to create a list from the list above with n elements,
 non-repeating and each elements index represents 1 of the elements
 from the corresponding list so for the above input I would get.

 a = [3,2,4,1]

 I have been staring at this off and on all day,
 and I haven't the faintest idea what you want.

 What is n.  What is it that doesn't repeat?
 How does the index of an element represent 1 element?
 Which list corresponds to what?

 I'm beginning to suspect that what you want is a choice
 function:
 f [s1,...,sn] = [x1,...,xn]
 when each xi is an element of the corresponding si
 and no two xs are the same.

 Instead of finding one answer, let's find them all.

 all_choices :: Eq a = [[a]] - [[a]]
 all_choices [] = [[]]
 all_choices (set:sets) =
   [x:xs | xs - all_choices sets, x  - set, not(x `elem` xs)]

 The test case

 all_choices [[2,3], [1,2], [2,3,4], [1,2,3]]

 has the answer

 [[3,2,4,1], [3,1,4,2], [2,1,4,3]]

 and you probably want to use it something like

 case all_choices sets of
   [] - there are no such choices
   (first_choice:_) - first_choice is one such choice

 For inputs like [[1,2],[2,1],[1]] there is of course no such
 choice function.


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


-- 
Tony Morris
http://tmorris.net/


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


Re: [Haskell-cafe] I need a hint in list processing

2009-06-14 Thread Tony Morris
Just guessing. How do you know it's an accident?


Richard O'Keefe wrote:

 On 15 Jun 2009, at 4:26 pm, Tony Morris wrote:

 Prelude Data.List nub . concat $ [[2, 3], [1, 2], [2, 3, 4], [1, 2, 3]]
 [2,3,1,4]

 In this particular case.  But that's a lucky accident.\



-- 
Tony Morris
http://tmorris.net/


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


Re: [Haskell-cafe] Runtime strictness analysis for polymorphic HOFs?

2009-06-14 Thread Jason Dagit
On Sun, Jun 14, 2009 at 8:18 PM, Eugene Kirpichov ekirpic...@gmail.comwrote:

 The idea looks cool, but perfect strictness analysis is not possible,
 t.i. the problem of determining whether f _|_ = _|_ is undecidable,
 since it is a non-trivial property of f (there exist f's for which it
 is true, and ones for which it is false) and non-trivial properties
 are undecidable, thanks to Rice theorem.


Unless you remove _|_ from the language.  If you have a total functional
programming language[1] it becomes a trivial property, right?  I guess this
would also extend to some dependently typed languages too.

[1] http://lambda-the-ultimate.org/node/2003

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


[Haskell-cafe] a now abandoned experimental extension to Haskell?

2009-06-14 Thread Vasili I. Galchin
Hello,

In some code that I am cabalizing I ran into:

type DataLiteral  =  ref RDFgraph defs 
type URIReference =  ref RDFgraph defs 
type NonNegativeInteger =  ??? 

What is this?

Kind regards,

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