Re: [Haskell-cafe] Execution of external command

2007-12-16 Thread Jonathan Cast
On 14 Dec 2007, at 1:21 AM, Jules Bean wrote: Evan Laforge wrote: it seems that script may be not terminated if its output isn't read, so better code should be (_, h, g, _) - runInteractiveCommand script params result - hGetLine h hGetContents h = evaluate.length hGetContents g =

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-16 Thread Dominic Steinitz
keep in mind that Haskell composition (.) is not really composition in the category-theoretic sense, because it adds extra laziness. Use this Do you have a counter-example of (.) not being function composition in the categorical sense? ___

Re: [Haskell-cafe] Questions about the Functor cl ass and it's use in Data types à la carte

2007-12-16 Thread Jonathan Cast
On 16 Dec 2007, at 2:23 AM, Dominic Steinitz wrote: keep in mind that Haskell composition (.) is not really composition in the category-theoretic sense, because it adds extra laziness. Use this Do you have a counter-example of (.) not being function composition in the categorical sense? Let

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-16 Thread Dominic Steinitz
Do you have a counter-example of (.) not being function composition in the categorical sense? Let bot be the function defined by bot :: alpha - beta bot = bot By definition, (.) = \ f - \ g - \ x - f (g x) Then bot . id = ((\ f - \ g - \ x - f (g x)) bot) id = (\ g - \ x

Re: [Haskell-cafe] Questions about the Functor cl ass and it's use in Data types à la carte

2007-12-16 Thread Jonathan Cast
On 16 Dec 2007, at 3:21 AM, Dominic Steinitz wrote: Do you have a counter-example of (.) not being function composition in the categorical sense? Let bot be the function defined by bot :: alpha - beta bot = bot By definition, (.) = \ f - \ g - \ x - f (g x) Then bot . id = ((\ f - \

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-16 Thread Roberto Zunino
Yitzchak Gale wrote: When using seq and _|_ in the context of categories, keep in mind that Haskell composition (.) is not really composition in the category-theoretic sense, because it adds extra laziness. Use this instead: (.!) f g x = f `seq` g `seq` f (g x) id .! undefined == \x -

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-16 Thread Roberto Zunino
Dominic Steinitz wrote: This would give = \x - bot x and by eta reduction This is the point: eta does not hold if seq exists. undefined `seq` 1 == undefined (\x - undefined x) `seq` 1 == 1 The (.) does not form a category argument should be something like: id . undefined == (\x -

[Haskell-cafe] Re: Monads that are Comonads and the role of Adjunction

2007-12-16 Thread apfelmus
Dan Weston wrote: newtype O f g a = O (f (g a)) -- Functor composition: f `O` g instance (Functor f, Functor g) = Functor (O f g) where ... instance Adjunction f g = Monad (O g f) where ... instance Adjunction f g = Comonad (O f g) where ... class (Functor f, Functor g)

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-16 Thread Yitzchak Gale
I wrote: (.!) f g x = f `seq` g `seq` f (g x) Roberto Zunino wrote: id .! undefined == \x - undefined /= undefined Probably you meant (.!) f g = f `seq` g `seq` (f . g) Yes, thank you. -Yitz ___ Haskell-Cafe mailing list

Re: Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-16 Thread jerzy . karczmarczuk
Roberto Zunino writes: without seq, there is no way to distinguish between undefined and (const undefined), no way to distinguish is perhaps too strong. They have slightly different types. Jerzy Karczmarczuk ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] Implementing a MUD server in haskell

2007-12-16 Thread Jules Bean
Jack Kelly wrote: struct room{ ... struct player * players; ... }; struct player{ ... struct room * room; ... }; From what I can see, I'd use a record type for players and rooms, but I'm not sure how to replicate the pointer effects: Essentially you have to choose some form of

Re: [Haskell-cafe] Questions about the Fu nctor class and it's use in Data types à la c arte

2007-12-16 Thread Jules Bean
[EMAIL PROTECTED] wrote: Roberto Zunino writes: without seq, there is no way to distinguish between undefined and (const undefined), no way to distinguish is perhaps too strong. They have slightly different types. At a particular type which they both inhabit, such as (a-b) or, to be

Re: [Haskell-cafe] Implementing a MUD server in haskell

2007-12-16 Thread Jack Kelly
Jules Bean wrote: Jack Kelly wrote: -snip- Essentially you have to choose some form of identity (relational DB fans might call it a key) for your players and rooms. My gut feeling is that String will do fine; it's nice for debugging, gives rise to a natural way to write your admin commands

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-16 Thread Dominic Steinitz
Roberto Zunino wrote: Dominic Steinitz wrote: This would give = \x - bot x and by eta reduction This is the point: eta does not hold if seq exists. undefined `seq` 1 == undefined (\x - undefined x) `seq` 1 == 1 Ok I've never used seq and I've never used unsavePerformIO.

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-16 Thread Dominic Steinitz
Jonathan Cast wrote: On 16 Dec 2007, at 3:21 AM, Dominic Steinitz wrote: Do you have a counter-example of (.) not being function composition in the categorical sense? Let bot be the function defined by bot :: alpha - beta bot = bot By definition, (.) = \ f - \ g - \ x - f (g x)

Re: [Haskell-cafe] Questions about the Functor cl ass and it's use in Data types à la carte

2007-12-16 Thread Sterling Clover
Am I correct in assuming that if my program doesn't contain seq then I can reason using eta reduction? You may be well aware of this, but the wiki page on the correctness of short cut fusion (http://haskell.org/haskellwiki/ Correctness_of_short_cut_fusion) really helped me to get at least a

Re: [Haskell-cafe] Implementing a MUD server in haskell

2007-12-16 Thread Luke Palmer
On Dec 16, 2007 1:45 PM, Jules Bean [EMAIL PROTECTED] wrote: This needs to stand up to concurrent modification of a shared world structure, but I think I'll set up the concurrency controls after I get my head around this.t The simplest way to do this is to bundle all your big shared mutable

Re: [Haskell-cafe] Questions about the Functor cl ass and it's use in Data types à la carte

2007-12-16 Thread Jonathan Cast
On 16 Dec 2007, at 9:47 AM, Dominic Steinitz wrote: Jonathan Cast wrote: On 16 Dec 2007, at 3:21 AM, Dominic Steinitz wrote: Do you have a counter-example of (.) not being function composition in the categorical sense? Let bot be the function defined by bot :: alpha - beta bot = bot By

[Haskell-cafe] announcing darcs 2.0.0pre2

2007-12-16 Thread David Roundy
I am pleased to announce the availability of the second prerelease of darcs two, darcs 2.0.0pre2. This release fixes several severe performance bugs that were present in the first prerelease. These issues were identified and fixed thanks to the helpful testing of Simon Marlow and Peter Rockai.

Re: [Haskell-cafe] [RFC] benchmarks of bytestrings, teaser

2007-12-16 Thread Roman Leshchinskiy
Don Stewart wrote: cnt:: B.ByteString - Int64 cnt bs = B.length (B.filter (== ' ') bs) [...] Now, this memory result is suspicious, I wonder if the now obsolete 'array fusion' is messing things up. In Data.ByteString.Lazy, we have: Are you sure you have a fusible length? I think I

Re: [Haskell-cafe] [RFC] benchmarks of bytestrings, teaser

2007-12-16 Thread Don Stewart
rl: Don Stewart wrote: cnt:: B.ByteString - Int64 cnt bs = B.length (B.filter (== ' ') bs) [...] Now, this memory result is suspicious, I wonder if the now obsolete 'array fusion' is messing things up. In Data.ByteString.Lazy, we have: Are you sure you have a fusible

Re: [Haskell-cafe] [RFC] benchmarks of bytestrings, teaser

2007-12-16 Thread Don Stewart
I've had a look at how some of the code was being compiled for strict and lazy bytestrings, and also which rules weren't firing. With some small tweaks the code seems back in good shape. An updated bytestring library is at :

Re: [Haskell-cafe] Re: Monads that are Comonads and the role of Adjunction

2007-12-16 Thread Derek Elkins
On Sun, 2007-12-16 at 13:49 +0100, apfelmus wrote: Dan Weston wrote: newtype O f g a = O (f (g a)) -- Functor composition: f `O` g instance (Functor f, Functor g) = Functor (O f g) where ... instance Adjunction f g = Monad (O g f) where ... instance Adjunction f g =

[Haskell-cafe] Patter matching beginner question

2007-12-16 Thread Adam Smyczek
Hi all, I assume the following behavior has a trivial explanation. When I write: case name of a - ... b - ... everything works fine. But when I extract a and b to constants: c_a = a :: String c_b = b :: String case name of c_a - ... c_b - ... I get Patterns

Re: [Haskell-cafe] Patter matching beginner question

2007-12-16 Thread Brandon S. Allbery KF8NH
On Dec 16, 2007, at 23:35 , Adam Smyczek wrote: case name of c_a - ... c_b - ... I get Patterns match(es) are overlapped. You can't use arbitrary expressions in patterns; any name (not a data constructor) used in one creates a new lambda binding (shadowing any existing