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

2007-03-12 Thread Bulat Ziganshin
Hello Claus, Monday, March 12, 2007, 3:35:43 AM, you wrote: the problems was mainly due to 2 factors: 1) readArray m (i,j) yes, indeed. since we are dealing in bulk operations, we might as well take advantage of that, so dropping the repeated bounds-checks inside the loops makes a lot of

[Haskell-cafe] Maybe and partial functions

2007-03-12 Thread Dougal Stanton
The Maybe construction is very useful for explicitly handling circumstances where the function cannot produce a sensible answer. But how far should this notion be taken? When you're writing a function which you realise may not produce what you want, in what circumstances would you use a Maybe,

[Haskell-cafe] A valuable new combinator for Parsec?

2007-03-12 Thread Maxime Henrion
Hello all, While using the very nice option combinator of Parsec recently, it seemed to me that it would be useful to have a more specific kind of combinator for optional tokens that wraps the token into a Maybe type. So, that gives: pmaybe :: GenParser tok st a - GenParser tok st

Re: [Haskell-cafe] Performance Help

2007-03-12 Thread Neil Mitchell
Hi I notice that there's not much user-accessible documentation of what you can expect GHC (or some other Haskell implementation) to do and not do with a given piece of code. Yhc/nhc/Hugs - nothing GHC - inlining, simplification, fusion if you use the build in functions in a specified way,

Re: [Haskell-cafe] A valuable new combinator for Parsec?

2007-03-12 Thread Tomasz Zielonka
On Mon, Mar 12, 2007 at 11:24:48AM +0100, Maxime Henrion wrote: While using the very nice option combinator of Parsec recently, it seemed to me that it would be useful to have a more specific kind of combinator for optional tokens that wraps the token into a Maybe type. So, that gives:

Re: [Haskell-cafe] Maybe and partial functions

2007-03-12 Thread Neil Mitchell
Hi head [] return Nothing? I guess it's a bit of a silly suggestion, but it helps to highlight why we use Maybe in the first place. So --- where's the cutoff point in your code? If that is what you want, then see my Safe library:

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

2007-03-12 Thread Claus Reinke
1) readArray m (i,j) yes, indeed. since we are dealing in bulk operations, we might as well take advantage of that, so dropping the repeated bounds-checks inside the loops makes a lot of sense. no, i say here only about memory leaks. of course, unsafeRead omits bounds checking but more

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

2007-03-12 Thread Claus Reinke
to handle the 2d indexing, i replaced readArray m (i,j) by readMatrix m (i,j): {-# INLINE readMatrix #-} readMatrix m ij = unsafeRead m (unsafeIndex matrixBounds ij) matrixBounds :: ((Int,Int),(Int,Int)) matrixBounds = ((1,1),(n,n)) i'm still trying to understand why unsafeIndex

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

2007-03-12 Thread Bulat Ziganshin
Hello Claus, Monday, March 12, 2007, 6:03:28 PM, you wrote: readMatrix calls index: 16s readMatrix calls myindex: 9s so just calling an in-module copy of the default code for index, with bounds-check, is almost as fast as calling unsafeIndex, and almost twice as fast as calling

[Haskell-cafe] Re: Type and State Confusion

2007-03-12 Thread Hans van Thiel
Albert, Thanks very much for your explanation. I see now that I confused the state function with the f, but it's still not quite clear. data MyState a b = MyStateC ([a] - ([a], b)) This defines an algebraic data type (...why is it called algebraic?) with two type variables and a unary

Re: [Haskell-cafe] Maybe and partial functions

2007-03-12 Thread Gen Zhang
On Mon, 12 Mar 2007 11:37:43 + Neil Mitchell [EMAIL PROTECTED] wrote: Catch also checks division by zero, explicit patterns etc. To see the world of pain you would be in if you go down the make everything total route, I suggest you try rewriting this program to be complete:

Re: [Haskell-cafe] A valuable new combinator for Parsec?

2007-03-12 Thread Jeremy Shaw
At Mon, 12 Mar 2007 11:24:48 +0100, Maxime Henrion wrote: pmaybe :: GenParser tok st a - GenParser tok st (Maybe a) pmaybe p = option Nothing (p = return . Just) I've been using it happily with some code of mine. Do people think that it would be generally useful to have in Parsec? I

[Haskell-cafe] CFP: Prog. Lang for Mechanized Mathematics Workshop

2007-03-12 Thread Jacques Carette
Programming Languages for Mechanized Mathematics Workshop As part of Calculemus 2007 http://www.risc.uni-linz.ac.at/about/conferences/Calculemus2007/ Hagenberg, Austria [http://www.cas.mcmaster.ca/plmms07/] The intent of this workshop is to examine more closely the intersection between

[Haskell-cafe] Re: ANN: HSH 1.2.0

2007-03-12 Thread John Goerzen
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 want to pipe from one

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

2007-03-12 Thread John Meacham
On Fri, Mar 09, 2007 at 10:24:14AM +, Simon Marlow wrote: GHC doesn't have any kind of uniqueness analysis right now. It's pretty hard to do in general: imagine a function that takes an array as an argument and delivers an array as a result. It'll probably need two versions: one when

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

2007-03-12 Thread Stefan O'Rear
On Mon, Mar 12, 2007 at 05:21:46PM -0700, John Meacham wrote: type checker : boxy types and impredicativity paper + Wobbly type GADT inference paper Both of those seem to take basic Hindley-Damas-Milner as a prerequisite ... While I've invented two closely related typechecking algorithms, and

Re: [Haskell-cafe] Re: HS-Plugins 1.0 chokes on simple test, WinXP GHC-6.6

2007-03-12 Thread Iain Alexander
I'm running cygwin on WinXP and got a different failure (below) from the latest darcs hs-plugins. Line 11 is right after the TOP definition. Does anyone have a theory about what's going on here? - Conal looks like the TOP and GHC_LIB_PATH values are the output of external commands,

Re: [Haskell-cafe] idea for avoiding temporaries

2007-03-12 Thread John Meacham
On Fri, Mar 09, 2007 at 10:58:43AM -0500, Jan-Willem Maessen wrote: * Linear or Uniqueness types are almost what we want. I think Josef Svenningson was the one who captured this the best: Uniqueness type *require* that the *caller* of these routines make sure that it is not sharing the

Re: [Haskell-cafe] Church Encoding Function

2007-03-12 Thread Jim Apple
On 3/10/07, Robert Dockins [EMAIL PROTECTED] wrote: I'm pretty sure you can define a catamorphism for any regular algebraic data type. I'm not 100% sure what the story is for non-regular (AKA nested) datatypes. They do exist: Initial Algebra Semantics is Enough! Patricia Johann and Neil

Re: [Haskell-cafe] Haskell for Accessibility

2007-03-12 Thread Derek Elkins
Tom Hawkins wrote: I love programming in Haskell, yet even its concise expressions have not saved my tendons from chronic RSI. Has anyone put any thought into building an accessible Haskell development interface for those who may not be able to use a keyboard? One inspirational program is

Re: [Haskell-cafe] Type and State Confusion

2007-03-12 Thread Albert Y. C. Lai
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 transformations correctly, since = is correct. So the m becomes MyState String,

Re: [Haskell-cafe] Maybe and partial functions

2007-03-12 Thread Albert Y. C. Lai
Dougal Stanton wrote: The Maybe construction is very useful for explicitly handling circumstances where the function cannot produce a sensible answer. But how far should this notion be taken? When you're writing a function which you realise may not produce what you want, in what circumstances

Re: [Haskell-cafe] Re: Church Encoding Function

2007-03-12 Thread Derek Elkins
Joachim Breitner wrote: Hi, Am Samstag, den 10.03.2007, 14:52 -0500 schrieb Stefan Monnier: I'm pretty sure you can define a catamorphism for any regular algebraic data type. Actually, so-called negative occurrences in (regular) data types cause problems. Try to define the catamorphism of