Re: [Haskell-cafe] Syntax for modifying nested product types

2004-04-23 Thread Tomasz Zielonka
On Fri, Apr 23, 2004 at 10:11:40AM +0100, Malcolm Wallace wrote: If the pattern is very common, how about just naming it? perhaps cond f field = if cond then f field else field foo { bar = perhaps cond0 f (bar foo) , wib = perhaps cond1 g (wib foo) } Good idea, but I think

Re: [Haskell-cafe] Syntax for modifying nested product types

2004-04-23 Thread Christian Maeder
Malcolm Wallace wrote: perhaps cond f field = if cond then f field else field foo { bar = perhaps cond0 f (bar foo) , wib = perhaps cond1 g (wib foo) } I tend to write functions: upd_bar f x = x { bar = f (bar x) } upd_wib f x = x { wib = f (wib x) } in order to avoid mentioning

Re: [Haskell-cafe] Syntax for modifying nested product types

2004-04-23 Thread MR K P SCHUPKE
I would just do: f' = if cond0 then f else id g' = if cond1 then g else id foo { bar = f' (bar foo) , wib = g' (wib foo) } I like seeing the record updated, rather than hiding it in a function. Regards, Keean.

Re: [Haskell-cafe] Syntax for modifying nested product types

2004-04-23 Thread Graham Klyne
At 18:18 22/04/04 -0400, Mark Carroll wrote: I have data objects where each component is a labelled field through which I access or modify it. Wading into the labelled field debate... I have found that using the labelled field update syntax can lead to difficulties in changing the underlying

Re: [Haskell-cafe] Splitting a list

2004-04-23 Thread Steve Schafer
On Wed, 21 Apr 2004 14:57:57 +0100, you wrote: How about implementing a directly recursive solution? Simply accumulate the sum so far, together with the list elements you have already peeled off. Once the sum plus the next element would exceed the threshold, emit the accumulated elements, and

[Haskell-cafe] Re: Syntax for modifying nested product types

2004-04-23 Thread Ferenc Wagner
Graham Klyne [EMAIL PROTECTED] writes: At 18:18 22/04/04 -0400, Mark Carroll wrote: I have data objects where each component is a labelled field through which I access or modify it. Wading into the labelled field debate... I have found that using the labelled field update syntax can lead

[Haskell-cafe] FiniteMap, Map, FiniteSet, Set

2004-04-23 Thread haskell
Here's a really elementary question: Why does the library have [FiniteMap and Set] instead of [FiniteMap and FiniteSet] or just [Map and Set]? Is there some reason for this inconsistency? Thanks, James ___ Haskell-Cafe mailing list [EMAIL PROTECTED]

Re: [Haskell-cafe] FiniteMap, Map, FiniteSet, Set

2004-04-23 Thread John Meacham
On Fri, Apr 23, 2004 at 08:02:47PM -0500, [EMAIL PROTECTED] wrote: Why does the library have [FiniteMap and Set] instead of [FiniteMap and FiniteSet] or just [Map and Set]? Is there some reason for this inconsistency? Historical accident mainly. There is discussion going on in the haskell