Re: [Haskell-cafe] Small question about something easy

2008-03-18 Thread iliali16
Thanks to all of you I got it I was missing the notation. Thanks again! iliali16 wrote: > > Hi guys I am a bit new to haskell but I am doing good till now. I have to > write a function that takes 2 inputs and then reutns one composite output. > Now my problem is that I have to make composition

Re: [Haskell-cafe] Small question about something easy

2008-03-18 Thread Thomas Schilling
On 18 mar 2008, at 13.51, Luke Palmer wrote: On Tue, Mar 18, 2008 at 12:24 PM, iliali16 <[EMAIL PROTECTED]> wrote: Now the problem comes here: play (p1 :>: p2) state |play p1 state == (i1,state1) && play p2 state1 == (i2,state2) = (i1+++i2,state2) I know that if I manage t

Re: [Haskell-cafe] Small question about something easy

2008-03-18 Thread Luke Palmer
On Tue, Mar 18, 2008 at 12:24 PM, iliali16 <[EMAIL PROTECTED]> wrote: > Now the problem comes here: > play (p1 :>: p2) state > |play p1 state == (i1,state1) && play p2 state1 == (i2,state2) > = (i1+++i2,state2) > > I know that if I manage to do that function the one above with this

Re: [Haskell-cafe] Small question

2007-08-10 Thread Stefan O'Rear
On Sat, Aug 11, 2007 at 12:06:23AM -0400, David Menendez wrote: > On 8/10/07, Andrew Coppin <[EMAIL PROTECTED]> wrote: > > > > My program needs to make decisions based on a pair of boolean values. > > Encoding both values as a single algebraic data type means I have to > > keep "taking it apart" so

Re: [Haskell-cafe] Small question

2007-08-10 Thread David Menendez
On 8/10/07, Andrew Coppin <[EMAIL PROTECTED]> wrote: > > My program needs to make decisions based on a pair of boolean values. > Encoding both values as a single algebraic data type means I have to > keep "taking it apart" so I can work with it. I'm not sure how much time > this wastes... Incident

Re: [Haskell-cafe] Small question

2007-08-10 Thread Andrew Coppin
Stefan O'Rear wrote: or, if you used the (correct and unintuitive) argument order to testBit: GAH! >_< Do you have ANY IDEA how many times I've got that wrong so far?? All I can say is thank God that Haskell is a statically-typed language! The type checker has saved my life here more time

Re: [Haskell-cafe] Small question

2007-08-10 Thread Stefan O'Rear
On Fri, Aug 10, 2007 at 06:12:03PM +0100, Andrew Coppin wrote: > > [big blob of simplifier output] > > Mmm. See, now, I have *no idea* what GHC is saying. But I would have > expected that if I do something like > > x = if testBit 3 q ... > > then the definition of testBit would get inlined, and t

Re: [Haskell-cafe] Small question

2007-08-10 Thread Andrew Coppin
Stefan O'Rear wrote: On Fri, Aug 10, 2007 at 07:26:28AM +0100, Andrew Coppin wrote: My program needs to make decisions based on a pair of boolean values. Encoding both values as a single algebraic data type means I have to keep "taking it apart" so I can work with it. I'm not sure how much t

Re: [Haskell-cafe] Small question

2007-08-10 Thread Andrew Coppin
Stefan O'Rear wrote: Just wait 12 years, and if the price of processors follows Moore's extrapolation and the Haskell keeps its parallelism, Haskell will win :) Nice idea. Unfortunately, writing code in Haskell does not [yet] magically cause it to become "parallel". It's just that writing

Re: [Haskell-cafe] Small question

2007-08-10 Thread Josef Svenningsson
On 8/10/07, John Meacham <[EMAIL PROTECTED]> wrote: > On Thu, Aug 09, 2007 at 06:37:32PM +0100, Andrew Coppin wrote: > > Which of these is likely to go faster? > > type Quad = (Bool,Bool) > ... > > data Quad = BL | BR | TL | TR > ... > > I'm hoping that the latter one will more more strict / use

Re: [Haskell-cafe] Small question

2007-08-10 Thread Jon Harrop
On Friday 10 August 2007 07:46:36 Donald Bruce Stewart wrote: > Doesn't look too good for your assertion :( Poor benchmark design forces the authors of the shootout to subjectively reject or cripple submissions. In fact, counting primes and printing pi are among the worst possible benchmark task

RE: [Haskell-cafe] Small question

2007-08-10 Thread Simon Peyton-Jones
| And, of course, if it's a strict argument, then the values stored are | ALWAYS one of two possibilities. So as a matter of curiosity, would | there be any advantage at all for "unboxing" enumeration types? (Apart | from, I suppose, the possibility of using fewer than 32/64 bits to store | a fla

Re: [Haskell-cafe] Small question

2007-08-10 Thread Stefan O'Rear
On Fri, Aug 10, 2007 at 07:26:28AM +0100, Andrew Coppin wrote: > Stefan O'Rear wrote: >> I like pretty pictures. > > ...and have lots of spare time, apparently. ;-) Indeed. :) >> Probably none. The STG-machine was designed to make user-defined >> algebraic types very fast. > > My program needs t

Re: [Haskell-cafe] Small question

2007-08-09 Thread Stefan O'Rear
On Fri, Aug 10, 2007 at 02:28:09PM +0800, Hugh Perkins wrote: > On 8/10/07, Stefan O'Rear <[EMAIL PROTECTED]> wrote: > > > > Haskell's purpose: To be a generally cool language > > Haskell's competition: C++, SML, ... hundreds of thousands more and I make > > no assertion of a representative sample

Re: [Haskell-cafe] Small question

2007-08-09 Thread Donald Bruce Stewart
hughperkins: > You'll find by the way that the imperative >GC'd, stack/heap protected languages run *significantly* >faster for many (not all I guess?) algorithms and >applications. Wow. Big claims. It must be silly hat day on the Haskell lists. We're trying hard

Re: [Haskell-cafe] Small question

2007-08-09 Thread Thomas Conway
On 8/10/07, Hugh Perkins <[EMAIL PROTECTED]> wrote: > On 8/10/07, Stefan O'Rear <[EMAIL PROTECTED]> wrote: > > Haskell's purpose: To be a generally cool language > > Haskell's competition: C++, SML, ... hundreds of thousands more and I make > no assertion of a representative sample ... > > > > Well

Re: [Haskell-cafe] Small question

2007-08-09 Thread Hugh Perkins
On 8/10/07, Stefan O'Rear <[EMAIL PROTECTED]> wrote: > > Haskell's purpose: To be a generally cool language > Haskell's competition: C++, SML, ... hundreds of thousands more and I make > no assertion of a representative sample ... > Well, C++ is not really competitive with Haskell, because C++ doe

Re: [Haskell-cafe] Small question

2007-08-09 Thread Andrew Coppin
Stefan O'Rear wrote: I like pretty pictures. ...and have lots of spare time, apparently. ;-) [I actually meant to write (Bool,Bool), but anyway...] Whereas my Quad object is going to be a pointer to one of 4 values... so it looks like Quads save space. (And they're more strict.) OTOH, I'

Re: [Haskell-cafe] Small question

2007-08-09 Thread Stefan O'Rear
On Fri, Aug 10, 2007 at 02:08:42PM +0800, Hugh Perkins wrote: > On 8/10/07, Stefan O'Rear <[EMAIL PROTECTED]> wrote: > > > > Good idea! Maybe it could be fit into the GHC Performance Resource > > somehow? (http://www.haskell.org/haskellwiki/Performance/GHC) > > > > >From the wiki: "Since GHC

Re: [Haskell-cafe] Small question

2007-08-09 Thread Hugh Perkins
On 8/10/07, Stefan O'Rear <[EMAIL PROTECTED]> wrote: > > Good idea! Maybe it could be fit into the GHC Performance Resource > somehow? (http://www.haskell.org/haskellwiki/Performance/GHC) > >From the wiki: "Since GHC doesn't have any credible competition

Re: [Haskell-cafe] Small question

2007-08-09 Thread Stefan O'Rear
On Thu, Aug 09, 2007 at 11:09:36PM -0400, [EMAIL PROTECTED] wrote: > Quoting Stefan O'Rear <[EMAIL PROTECTED]>: > > In general, GHC doesn't do "unboxing". Instead it has a simpler and > > more general approach, [...] > > I'm not convinced that the phrase "more general" is appropriate here. :-) No

Re: [Haskell-cafe] Small question

2007-08-09 Thread ajb
G'day all. Quoting Stefan O'Rear <[EMAIL PROTECTED]>: > In general, GHC doesn't do "unboxing". Instead it has a simpler and > more general approach, [...] I'm not convinced that the phrase "more general" is appropriate here. :-) > As far as actual heap usage goes, GHC creates single static val

Re: [Haskell-cafe] Small question

2007-08-09 Thread John Meacham
On Thu, Aug 09, 2007 at 06:37:32PM +0100, Andrew Coppin wrote: > Which of these is likely to go faster? > type Quad = (Bool,Bool) ... > data Quad = BL | BR | TL | TR ... > I'm hoping that the latter one will more more strict / use less space. > But I don't truely know... The second one will be

Re: [Haskell-cafe] Small question

2007-08-09 Thread Stefan O'Rear
On Thu, Aug 09, 2007 at 10:19:59PM +0100, Andrew Coppin wrote: > Right. So a Bool is a 32 or 64 bit quantity. (Rather like Smalltalk...) > > That presumably means that a (Double,Double) is going to be a thunk that > evaluates to a (,) pointing to two thunks that evaluate to pointers... IOW, > som

Re: [Haskell-cafe] Small question

2007-08-09 Thread Andrew Coppin
Stefan O'Rear wrote: On Thu, Aug 09, 2007 at 09:27:23PM +0100, Andrew Coppin wrote: OOC, in what way is Bool not "primitive enough"? You mean because it's an algebraic data type, rather than a bunch of bits in the machine? For that matter, just how much space does such a type typically use?

Re: [Haskell-cafe] Small question

2007-08-09 Thread Stefan O'Rear
On Thu, Aug 09, 2007 at 09:27:23PM +0100, Andrew Coppin wrote: > OOC, in what way is Bool not "primitive enough"? You mean because it's an > algebraic data type, rather than a bunch of bits in the machine? For that > matter, just how much space does such a type typically use? Yes. data Bool = F

Re: [Haskell-cafe] Small question

2007-08-09 Thread Andrew Coppin
Stefan O'Rear wrote: On Thu, Aug 09, 2007 at 07:12:12PM +0100, Sebastian Sylvan wrote: {-#OPTIONS -funbox-strict-fields #-} data Quad = Quad !Bool !Bool foo True True = ... foo True False = ... etc... The GHC option just causese GHC to unbox primitive types when they're strict in the

Re: [Haskell-cafe] Small question

2007-08-09 Thread Sebastian Sylvan
On 09/08/07, Stefan O'Rear <[EMAIL PROTECTED]> wrote: > On Thu, Aug 09, 2007 at 07:12:12PM +0100, Sebastian Sylvan wrote: > > {-#OPTIONS -funbox-strict-fields #-} > > > > data Quad = Quad !Bool !Bool > > > > foo True True = ... > > foo True False = > > ... etc... > > > > > > The GHC option jus

Re: [Haskell-cafe] Small question

2007-08-09 Thread Stefan O'Rear
On Thu, Aug 09, 2007 at 07:12:12PM +0100, Sebastian Sylvan wrote: > {-#OPTIONS -funbox-strict-fields #-} > > data Quad = Quad !Bool !Bool > > foo True True = ... > foo True False = > ... etc... > > > The GHC option just causese GHC to unbox primitive types when they're > strict in the data

Re: [Haskell-cafe] Small question

2007-08-09 Thread Sebastian Sylvan
On 09/08/07, Andrew Coppin <[EMAIL PROTECTED]> wrote: > Which of these is likely to go faster? > > type Quad = (Bool,Bool) > > foo (r,t) = > let > x = if r ... > y = if t ... > in ... > > > > data Quad = BL | BR | TL | TR > > foo q = > let > x = if q == TL | q