Re: [Haskell-cafe] Is this a useful higher-order function, or should I RTFM?

2004-12-08 Thread Tom Pledger
Steven Huwig wrote: On Dec 6, 2004, at 11:05 PM, Tom Pledger wrote: import Data.Char(isSpace) import Data.List(groupBy) (op `on` f) x y = f x `op` f y wordsAndSpaces = groupBy ((==) `on` isSpace) `on` is a handy little function in this instance. Does it have a technical name?

Re: [Haskell-cafe] ghc has problems with 'zipWith' ?

2004-12-08 Thread Tomasz Zielonka
On Tue, Dec 07, 2004 at 06:44:33PM +0100, Daniel Fischer wrote: ms :: [Integer] - [Integer] ms as = zipWith (+) (zipWith (*) as (1:ms as)) (0:1:ms as) This version seems to be faster, but I don't know if it addresses your concern: ms as = let l = zipWith (+) (zipWith (*) as (1:l)) (0:1:l)

Re: [Haskell-cafe] ghc has problems with 'zipWith' ?

2004-12-08 Thread Tom Pledger
Daniel Fischer wrote: Hi, I have recently come across the curious phenomenon that ghci is sometimes much slower than hugs. [...] ms as = zipWith (+) (zipWith (*) as (1:ms as)) (0:1:ms as) Hugs has(**) a specific optimisation for the case where the left hand side of the declaration occurs as a

Re: [Haskell-cafe] numerical subtyping

2004-12-08 Thread Keean Schupke
You can also do this in a way that statically guarantees the property... First you need to lift the numeric argument to the type level... This is harder for a double than an integer, but not impossible... First convert the double to a pair of Integers (an infintite precision rational number)...

Re: [Haskell-cafe] ghc has problems with 'zipWith' ?

2004-12-08 Thread Daniel Fischer
Am Mittwoch, 8. Dezember 2004 10:22 schrieben Sie: On Tue, Dec 07, 2004 at 06:44:33PM +0100, Daniel Fischer wrote: ms :: [Integer] - [Integer] ms as = zipWith (+) (zipWith (*) as (1:ms as)) (0:1:ms as) This version seems to be faster, but I don't know if it addresses your concern: ms

Re: [Haskell-cafe] numerical subtyping

2004-12-08 Thread David Roundy
On Wed, Dec 08, 2004 at 11:11:44AM +, Keean Schupke wrote: You can also do this in a way that statically guarantees the property... First you need to lift the numeric argument to the type level... This is harder for a double than an integer, but not impossible... First convert the double

Re: [Haskell-cafe] ghc has problems with 'zipWith' ?

2004-12-08 Thread Henning Thielemann
On Wed, 8 Dec 2004, Daniel Fischer wrote: Am Mittwoch, 8. Dezember 2004 10:22 schrieben Sie: On Tue, Dec 07, 2004 at 06:44:33PM +0100, Daniel Fischer wrote: ms :: [Integer] - [Integer] ms as = zipWith (+) (zipWith (*) as (1:ms as)) (0:1:ms as) This version seems to be faster, but I

[Haskell-cafe] ghc has problems with 'zipWith' ?

2004-12-08 Thread Derek Elkins
Is it possible and senseful for a compiler to extract common sub-expressions? Naively I think that for a given tree of an expression it is efficiently possible to find all common sub-trees. Referential transparency would assure that equal expressions have the same value, so they can be

[Haskell-cafe] namespacing?

2004-12-08 Thread azrael
I've got a general new person type question. I understand that I can hide a function in a module that I am importing if it conflicts with another identical function name. But if the situation arises that I would like to use two identically named functions from two different modules is there

Re: [Haskell-cafe] namespacing?

2004-12-08 Thread Henning Thielemann
On Wed, 8 Dec 2004 [EMAIL PROTECTED] wrote: But if the situation arises that I would like to use two identically named functions from two different modules is there anyway for me to specify that I want to use the function from module A rather then the function from module B. A.func B.func

Re: [Haskell-cafe] namespacing?

2004-12-08 Thread Matthew Walton
[EMAIL PROTECTED] wrote: I've got a general new person type question. I understand that I can hide a function in a module that I am importing if it conflicts with another identical function name. But if the situation arises that I would like to use two identically named functions from two

Re: [Haskell-cafe] namespacing?

2004-12-08 Thread Duncan Coutts
On Wed, 2004-12-08 at 07:58 -0700, [EMAIL PROTECTED] wrote: I've got a general new person type question. I understand that I can hide a function in a module that I am importing if it conflicts with another identical function name. But if the situation arises that I would like to use two

RE: [Haskell-cafe] namespacing?

2004-12-08 Thread Jason Bailey
I'm appreciating the feedback. I discovered where I was going wrong. The library I was using allowed me to import a module, which in turn allowed me to use functions from other modules. So even though I could use func directly I couldn't use B.func because I hadn't explicitly imported B. I

[Haskell-cafe] Re: Haskell and qualified identifiers

2004-12-08 Thread Duncan Coutts
On Wed, 2004-12-08 at 17:04 +0100, Henning Thielemann wrote: On Wed, 8 Dec 2004, Duncan Coutts wrote: There are actually several options here, you can import modules only qualified, then every value from that module needs to be qualified. Some modules are designed to be used this way, see

[Haskell-cafe] Re: Haskell and qualified identifiers

2004-12-08 Thread Henning Thielemann
On Wed, 8 Dec 2004, Duncan Coutts wrote: I use HashTable like so: import Data.HashTable (HashTable) import qualified Data.HashTable as HashTable If you give a generic name for the type, you can leave out the first 'import' and can stick completely to qualified identifiers, like

Re: [Haskell-cafe] Re: Non-technical Haskell question

2004-12-08 Thread Gour
John Goerzen ([EMAIL PROTECTED]) wrote: I think the two main things to do that would be: 1. Write Haskell code that has a wide appeal (example: darcs) Agree. One individual wrote an application of the (very) general interest 'educating' programmers about Haskell's adequacy as a general

Re: [Haskell-cafe] Re: Non-technical Haskell question

2004-12-08 Thread Sebastian Sylvan
On Wed, 8 Dec 2004 19:27:56 +0100, Gour [EMAIL PROTECTED] wrote: Three of us also have a very rough start on a hands-on, practical introduction to Haskell aimed at the experienced imperative programmer. This is *very* important - bringing new people from the imperative (I do not mean they