[Haskell-cafe] System.Random StdGen read fails on some strings?

2007-03-13 Thread Fritz Ruehr
According to the documentation for System.Random (see http:// haskell.org/ghc/docs/latest/html/libraries/base/System-Random.html): In addition, read may be used to map an arbitrary string (not necessarily one produced by show) onto a value of type StdGen. In general, the read instance of

RE: [Haskell-cafe] Re: idea for avoiding temporaries

2007-03-13 Thread Simon Peyton-Jones
| Perhaps A section of the wiki is in order that lists the most recent | paper that describes various parts of what is actually used in the | production ghc. | | perhaps something like | | type checker : boxy types and impredicativity paper + Wobbly type GADT | inference paper |

[Haskell-cafe] Random/StdGen/read: there is something unclear (or misunderstood!)

2007-03-13 Thread Zara
Sorry if this question is too basic, but I am trying to learn Haskell and from tiem to time I get stuck. (And forgive me, I haev a heavy procedural background, so functional programming is hard for me) I am trying to use 'read' to create a random generator, applying it on some text. As the

Re[2]: [Haskell-cafe] Re: idea for avoiding temporaries

2007-03-13 Thread Bulat Ziganshin
Hello John, Tuesday, March 13, 2007, 3:21:46 AM, you wrote: garbage collector: non-stop collection for haskell paper this is not implemented and btw exists as one of haskell SoC tasks. implemented only *multithreading* for old GC -- Best regards, Bulat

Re: [Haskell-cafe] Random/StdGen/read: there is something unclear (or misunderstood!)

2007-03-13 Thread Kirsten Chevalier
This does seem to be a bug; see: http://www.haskell.org/pipermail/libraries/2007-March/007034.html (from a few minutes ago) Cheers, Kirsten -- Kirsten Chevalier* [EMAIL PROTECTED] *Often in error, never in doubt and the things I'm working on are invisible to everyone--Meg Hutchinson

[Haskell-cafe] GHC optimization changes evaluation strategy?

2007-03-13 Thread Dusan Kolar
Hello all, the following program changes behavior if translated using different options for ghc compiler. Is this correct or not? I used The Glorious Glasgow Haskell Compilation System, version 6.6. And I would expect in both cases behavior 1. But I may be wrong... Thanks for any

[Haskell-cafe] Re: idea for avoiding temporaries

2007-03-13 Thread Simon Marlow
Bulat Ziganshin wrote: Hello Simon, Friday, March 9, 2007, 7:44:46 PM, you wrote: Looking at the implementation of DiffArrays, there are some obvious optimisations that aren't done. and don't forget that it uses MVar instead of IORef to be thread-safe I don't see any obvious

[Haskell-cafe] Maybe and partial functions

2007-03-13 Thread oleg
Neil Mitchell wrote: I suggest you try rewriting this program to be complete: http://darcs.haskell.org/nofib/imaginary/digits-of-e2/Main.lhs (if you do, please post the result to the list) As Gen Zhang noted, the problem seems to be quite straightforward: just express in types the fact

[Haskell-cafe] Re: Maybe and partial functions

2007-03-13 Thread Neil Mitchell
Hi -- There are no pattern-matching failures here. -- The totality is harder to see: all digits are roughly of the same range, -- but each recursive call increments base. Eventually, base becomes bigger -- than d+9 and so the first alternative will be selected, which is in the -- WHNF and so

[Haskell-cafe] Re[2]: idea for avoiding temporaries

2007-03-13 Thread Bulat Ziganshin
Hello Simon, Tuesday, March 13, 2007, 1:00:46 PM, you wrote: Looking at the implementation of DiffArrays, there are some obvious and don't forget that it uses MVar instead of IORef to be I don't see any obvious optimisations there - some kind of thread-safety is essential. for general

[Haskell-cafe] Re: ANN: HSH 1.2.0

2007-03-13 Thread Simon Marlow
John Goerzen wrote: On 2007-03-06, Simon Marlow [EMAIL PROTECTED] wrote: John Goerzen wrote: possible to create a pipe going directly from program A to program B. You certainly can pipe directly from one process to another: That only works for 2 processes. What if I have 4 processes, and

Re: [Haskell-cafe] Re: idea for avoiding temporaries

2007-03-13 Thread Claus Reinke
Looking at the implementation of DiffArrays, there are some obvious optimisations that aren't done. and don't forget that it uses MVar instead of IORef to be thread-safe I don't see any obvious optimisations there - some kind of thread-safety is essential. We could try IORef and

Re: [Haskell-cafe] Re: Maybe and partial functions

2007-03-13 Thread Gen Zhang
On Tue, 13 Mar 2007 10:17:05 + Neil Mitchell [EMAIL PROTECTED] wrote: Hi -- There are no pattern-matching failures here. -- The totality is harder to see: all digits are roughly of the same range, -- but each recursive call increments base. Eventually, base becomes bigger -- than

Re[2]: [Haskell-cafe] Re: idea for avoiding temporaries

2007-03-13 Thread Bulat Ziganshin
Hello Claus, Tuesday, March 13, 2007, 2:10:49 PM, you wrote: how big is the impact of those MVars anyway, compared to a version that wouldn't have to worry about threads? on my 1GHz cpu, withMVar locking makes 2*10^6 cycles/sec, compared with 10-100x faster IORef operation -- Best

[Haskell-cafe] Ann: regex-base-0.91

2007-03-13 Thread Chris Kuklewicz
I have updated the darcs repository and the hackage repository to have regex-base-0.91 Changes: GHC uses late instance overlap detection, whereas Hugs demands no potential overlap. Thus Hugs rejected some of the polymorphic results for matching given by RegexContext instances. The solution

Re: [Haskell-cafe] GHC optimization changes evaluation strategy?

2007-03-13 Thread Chris Kuklewicz
Dusan Kolar wrote: Hello all, the following program changes behavior if translated using different options for ghc compiler. Is this correct or not? I used The Glorious Glasgow Haskell Compilation System, version 6.6. And I would expect in both cases behavior 1. But I may be wrong...

[Haskell-cafe] Re: [Haskell] Haskell Weekly News: March 12, 2007

2007-03-13 Thread Conrad Parker
On 13/03/07, Wolfgang Jeltsch [EMAIL PROTECTED] wrote: Am Montag, 12. März 2007 03:52 schrieb Donald Bruce Stewart: * [41]Why Publish CS Papers Without Code? 41. http://billmill.org/why_no_code Interesting! This leads me to the question how copyright of code fragments included in

Re: [Haskell-cafe] Re: Maybe and partial functions

2007-03-13 Thread Neil Mitchell
Hi Note: Total = total ignoring non-termination, for this post Surely we can assume them total given that base is never zero? They are not total, they are called in a manner which does not cause them to raise an error. If you want every function to be total, you need to fix div. If you are

Re: [Haskell-cafe] Re: [Haskell] Haskell Weekly News: March 12, 2007

2007-03-13 Thread Dougal Stanton
Quoth Conrad Parker, nevermore, Besides, tshirtIf it's not open source, it's not computer science/tshirt. Science demands repeatable results, computer science demands literate programming. The solution is not to shy away from including code, or else the IP lawyers have won, science is banned

Re: [Haskell-cafe] Type and State Confusion

2007-03-13 Thread Hans van Thiel
On Tue, 2007-03-13 at 00:47 -0400, Albert Y. C. Lai wrote: Hans van Thiel wrote: sequence :: Monad m = [m a] - m [a] You write: The = used by sequence is the same = in the MyState monad, since you instantiate m to MyState String. Therefore, sequence performs all the state

[Haskell-cafe] Re: ANN: HSH 1.2.0

2007-03-13 Thread John Goerzen
On Tue, Mar 13, 2007 at 10:51:47AM +, Simon Marlow wrote: Before I answer the question, if you don't mind I'll quote from my own message: [ snip ] So ideally we'd have a version of runInteractiveProcess that didn't create all three pipes, and then it would be easy to program your

[Haskell-cafe] Re: System.Random StdGen read fails on some strings? [also continues: Random/StdGen/read: there is something unclear (or misunderstood!)]

2007-03-13 Thread Zara
On Tue, 13 Mar 2007 00:37:46 -0700, Fritz Ruehr [EMAIL PROTECTED] wrote: According to the documentation for System.Random (see http:// haskell.org/ghc/docs/latest/html/libraries/base/System-Random.html): In addition, read may be used to map an arbitrary string (not necessarily one produced

[Haskell-cafe] haskell and webapplications + a WASH and a WebFunction question

2007-03-13 Thread Marc Weber
Hello, I've noticed that the summer of code tickets contain one item: lightweight web framework. I've dropped out university one year ago. So I can't participate, right? Do you want to explore with me how this might be done propably using HAppS or fastcgi ? I just need another person to talk to

[Haskell-cafe] Consequences of newtype deriving implementation w.r.t. base classes

2007-03-13 Thread Twan van Laarhoven
I just noticed some unexpected consequences of the way newtype deriving is implemented in GHC. Because the dictionary of the underlying type is reused, so are base classes. This message is a literate Haskell program illustrating the problem. {-# OPTIONS_GHC -fglasgow-exts #-} This problem

[Haskell-cafe] Parallelism on concurrent?

2007-03-13 Thread Dusan Kolar
Hello all, I'm googling around haskell.org to get some deeper knowledge about Control.Parallel.Strategies than it is presented on http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Parallel-Strategies.html BTW, could someone point me to some more deeper doc. about it?

Re: [Haskell-cafe] Parallelism on concurrent?

2007-03-13 Thread Jefferson Heard
Simon will probably chime in on it as well, but his paper on the subject is the best there is: http://research.microsoft.com/~simonpj/Papers/strategies.ps.gz If you have questions about the paper, I'd be happy to help, too. I worked through it myself fairly recently. -- Jeff On Tuesday 13

RE: [Haskell-cafe] Consequences of newtype deriving implementation w.r.t. base classes

2007-03-13 Thread Simon Peyton-Jones
| I just noticed some unexpected consequences of the way newtype deriving | is implemented in GHC. Because the dictionary of the underlying type is | reused, so are base classes. This message is a literate Haskell program | illustrating the problem. Excellent point. | As a solution I would

Re: [Haskell-cafe] Parallelism on concurrent?

2007-03-13 Thread Pepe Iborra
On 13/03/2007, at 17:46, Jefferson Heard wrote: Simon will probably chime in on it as well, but his paper on the subject is the best there is: http://research.microsoft.com/~simonpj/Papers/strategies.ps.gz It does work in GHC 6.6 very nicely. You can try it with the following naive fib

Re: [Haskell-cafe] Parallelism on concurrent?

2007-03-13 Thread Dusan Kolar
Yes, it works for operator /par/. That's what I've reported. But should it work for forkIO and forkOS? Could anybody give more detailed answer than yes, no? :-) (Link to the Web is OK.) BTW, thanks for the link to the paper (moreover, I can see, that googling over haskell.org is not

Re: [Haskell-cafe] Parallelism on concurrent?

2007-03-13 Thread Pepe Iborra
Excuse me, I read too quick. It works for forkIO too, although I'm not sure about forkOS. I don't have a demo around, but you can verify with the concurrency demos in the wiki: http://haskell.org/haskellwiki/Concurrency_demos/Zeta If it doesn't work, perhaps you are in an unsupported

Re: [Haskell-cafe] Parallelism on concurrent?

2007-03-13 Thread Jefferson Heard
forkOS should work as well, assuming you have OS threads, like in linux 2.6. You should probably be using the -smp compiler flag and not the -threaded compiler flag, I'm guessing, and make sure that your +RTS arguments indicate that you want to use X total concurrent threads... -- Jeff On

Re: [Haskell-cafe] Re: Maybe and partial functions

2007-03-13 Thread Nicolas Frisby
It seems like we could refine the first parameter of carryPropagate just as the second: make an= type N1 that only admits values [1..]. Would not that suffice to prove that base is never 0 and not have to go beyond the type-checker for a proof? On 3/13/07, Neil Mitchell [EMAIL PROTECTED] wrote:

Re: [Haskell-cafe] Re: Maybe and partial functions

2007-03-13 Thread Neil Mitchell
Hi Nicolas, It seems like we could refine the first parameter of carryPropagate just as the second: make an= type N1 that only admits values [1..]. How? newtype N1 = N1 Int (put that in a module and don't export N1) define the constant 2, define the increment operator, change div and mod.

Re: [Haskell-cafe] Re: ANN: HSH 1.2.0

2007-03-13 Thread Brandon Michael Moore
On Mon, Mar 12, 2007 at 05:14:57PM -0500, John Goerzen wrote: On 2007-03-06, Simon Marlow [EMAIL PROTECTED] wrote: John Goerzen wrote: possible to create a pipe going directly from program A to program B. You certainly can pipe directly from one process to another: That only works for

Re[2]: [Haskell-cafe] Parallelism on concurrent?

2007-03-13 Thread Bulat Ziganshin
Hello Jefferson, Tuesday, March 13, 2007, 9:06:31 PM, you wrote: forkOS should work as well, assuming you have OS threads, like in linux 2.6. You should probably be using the -smp compiler flag and not the -threaded compiler flag, I'm guessing, and make sure that your +RTS arguments indicate

[Haskell-cafe] ICFP07 Final CFP Note from the Program Chair

2007-03-13 Thread Matthew Fluet (ICFP Publicity Chair)
Call for Papers ICFP 2007: International Conference on Functional Programming Freiburg, Germany, 1-3 October 2007 Important Dates ~~~ Submission:11:00 6 April 2007, Samoa time (AST) Author response: 11:00 23 May to 11:00 25

[Haskell-cafe] Mixed-type arithmetic, or type coercion

2007-03-13 Thread Dave Hinton
Arithmetic operators in haskell appear to require their operands to have the same type. How can I do arithmetic between operands of different types? Alternatively, how do I coerce a value from being an Int to being a Double? I am new to haskell. I have read a few tutorials but they do not

Re: [Haskell-cafe] Mixed-type arithmetic, or type coercion

2007-03-13 Thread Neil Mitchell
Hi Arithmetic operators in haskell appear to require their operands to have the same type. How can I do arithmetic between operands of different types? You probably don't want to. Alternatively, how do I coerce a value from being an Int to being a Double? You ask Hoogle:

Re: [Haskell-cafe] Mixed-type arithmetic, or type coercion

2007-03-13 Thread Henk-Jan van Tuyl
On Tue, 13 Mar 2007 21:41:00 +0100, Dave Hinton [EMAIL PROTECTED] wrote: how do I coerce a value from being an Int to being a Double? calc :: Int - Double - Double calc count weight = count * weight Use: calc count weight = fromIntegral count * weight If you want an Int result, use:

Re: [Haskell-cafe] Mixed-type arithmetic, or type coercion

2007-03-13 Thread Albert Y. C. Lai
Dave Hinton wrote: Arithmetic operators in haskell appear to require their operands to have the same type. How can I do arithmetic between operands of different types? Alternatively, how do I coerce a value from being an Int to being a Double? fromIntegral can do this coercion. It is more

Re: [Haskell-cafe] Re: [Haskell] Haskell Weekly News: March 12, 2007

2007-03-13 Thread Donald Bruce Stewart
ithika: Quoth Conrad Parker, nevermore, Besides, tshirtIf it's not open source, it's not computer science/tshirt. Science demands repeatable results, computer science demands literate programming. The solution is not to shy away from including code, or else the IP lawyers have won,

[Haskell-cafe] c2hs and pthreadtypes.h

2007-03-13 Thread Magnus Therning
I'm trying to use c2hs but get stuck when including sys/types.h (though the problem really resides in pthreadtypes.h): % ./Setup.hs build -v Preprocessing executables for kowasu-0.1... /usr/bin/c2hs -C -D__GLASGOW_HASKELL__=606 -C -Icsrc -o src/Kowasu/PTrace.hs src/Kowasu/PTrace.chs c2hs:

Re: [Haskell-cafe] c2hs and pthreadtypes.h

2007-03-13 Thread Donald Bruce Stewart
magnus: I'm trying to use c2hs but get stuck when including sys/types.h (though the problem really resides in pthreadtypes.h): % ./Setup.hs build -v Preprocessing executables for kowasu-0.1... /usr/bin/c2hs -C -D__GLASGOW_HASKELL__=606 -C -Icsrc -o src/Kowasu/PTrace.hs

Re: [Haskell-cafe] c2hs and pthreadtypes.h

2007-03-13 Thread David Brown
Magnus Therning wrote: I'm trying to use c2hs but get stuck when including sys/types.h (though the problem really resides in pthreadtypes.h): /usr/include/bits/pthreadtypes.h:69: (column 6) [FATAL] Syntax error! The symbol `;' does not fit here. 65 __extension__ union 66

Re: [Haskell-cafe] Parallelism on concurrent?

2007-03-13 Thread Ian Lynagh
On Tue, Mar 13, 2007 at 09:41:47PM +0300, Bulat Ziganshin wrote: Tuesday, March 13, 2007, 9:06:31 PM, you wrote: forkOS should work as well, assuming you have OS threads, like in linux 2.6. You should probably be using the -smp compiler flag and not the -threaded compiler flag, I'm

Re: [Haskell-cafe] Maybe and partial functions

2007-03-13 Thread Steve Downey
This isn't just a question about Haskell. It applies to any language with an exception mechanism, including C++ and Java. Even C (segv is an exception mechanism...) The question is really how to communicate failure to the caller, in a way the caller can not ignore, without unduely inconvienencing

Re: [Haskell-cafe] Haskell Weekly News: March 12, 2007

2007-03-13 Thread Steve Downey
One of my editors at somepoint, told me that he had asked his lawyers about this (i.e. don't think this is anything like real legal advice), and the answer was 'If you publish an article and advise someone that the way to do something is X, no judge will be happy if you sue them for taking your

[Haskell-cafe] Foralls in records

2007-03-13 Thread Adde
Hi. I'm experimenting with implementing database transactions as monads but I'm getting stuck on how to store a generic connection (only constrained by a typeclass) inside the transaction. The reason I'm doing it this way is that the connection could be a different kind of structure depending

Re: [Haskell-cafe] c2hs and pthreadtypes.h

2007-03-13 Thread Duncan Coutts
On Wed, 2007-03-14 at 09:56 +1100, Donald Bruce Stewart wrote: magnus: I'm trying to use c2hs but get stuck when including sys/types.h (though the problem really resides in pthreadtypes.h): % ./Setup.hs build -v Preprocessing executables for kowasu-0.1... /usr/bin/c2hs -C

Re: [Haskell-cafe] Defining types (newbie)

2007-03-13 Thread Bryan O'Sullivan
John Fouhy wrote: In Haskell, I envisage writing something like: data ThingCompare = TC Op Field This wants to be a bit more concrete: data ThingCompare = TC (a - a - Bool) (Thing - a) so that you could then have something to execute your comparison thingy: runTC :: ThingCompare - Thing -

Re: [Haskell-cafe] Defining types (newbie)

2007-03-13 Thread John Fouhy
On 14/03/07, Bryan O'Sullivan [EMAIL PROTECTED] wrote: John Fouhy wrote: In Haskell, I envisage writing something like: data ThingCompare = TC Op Field This wants to be a bit more concrete: data ThingCompare = TC (a - a - Bool) (Thing - a) Hi Bryan, I actually had to write: data

[Haskell-cafe] Re: Maybe and partial functions

2007-03-13 Thread oleg
Neil Mitchell wrote: newtype N1 = N1 Int (put that in a module and don't export N1) define the constant 2, define the increment operator, change div and mod. That is precisely what I would have done. Now we've mainly got a proof in the type checker, but we still don't actually have a

[Haskell-cafe] Read Instance for UArray won't port to linux

2007-03-13 Thread SevenThunders
I have the pleasure of porting a good sized Haskell application to linux. So far the Haskell code has compiled without incident, however some code that I hacked to implement a Read instance for Unboxed Arrays does not compile on linux even though it compiles just fine on Windows XP in Haskell

Re: [Haskell-cafe] Defining types (newbie)

2007-03-13 Thread John Fouhy
On 14/03/07, Bryan O'Sullivan [EMAIL PROTECTED] wrote: This wants to be a bit more concrete: data ThingCompare = TC (a - a - Bool) (Thing - a) so that you could then have something to execute your comparison thingy: runTC :: ThingCompare - Thing - Thing - Bool runTC (TC compare extract) a b =

Re: [Haskell-cafe] Foralls in records

2007-03-13 Thread Matthew Brecknell
Adde: data TransactionT = forall c. (Connection c) = TransactionT c data Transaction a = Transaction (TransactionT - (a, TransactionT)) getConnection :: Transaction c getConnection = Transaction (\t@(TransactionT c) - (c, t)) class Connection c where connectionExecute :: c - String -

Re: [Haskell-cafe] Read Instance for UArray won't port to linux

2007-03-13 Thread Spencer Janssen
It looks like you forgot to pass a compiler flag, namely -fglasgow-exts. Cheers, Spencer Janssen On Tue, 13 Mar 2007 22:20:20 -0700 (PDT) SevenThunders [EMAIL PROTECTED] wrote: I have the pleasure of porting a good sized Haskell application to linux. So far the Haskell code has compiled

Re: [Haskell-cafe] Defining types (newbie)

2007-03-13 Thread Matthew Brecknell
John Fouhy: But if I want to combine tcEqOne and tcGtThree I run into type problems, because one of them uses Strings and the other Integers. I want to break the type dependence between the arguments of And; can I do this? Try this. You'll also need to change ThingCompare a to ThingCompare

Re: [Haskell-cafe] Defining types (newbie)

2007-03-13 Thread Matthew Brecknell
I said: Try this. You'll also need to change ThingCompare a to ThingCompare in all your function type signatures. data ThingCompare = forall a. TC (BooleanOp a) (Field a) | And ThingCompare ThingCompare | Or ThingCompare ThingCompare Sorry. For that to work, you would need