[Haskell-cafe] Re: map (-2) [1..5]

2006-09-19 Thread Aaron Denney
On 2006-09-11, Aaron Denney [EMAIL PROTECTED] wrote: See What About the Natural Numbers - Colin Runciman - it's a good read :) I will when I get the chance. Finally found a copy. It is a good read. I mostly agree with him. The biggest exception is about the need for highly optimized, near

RE: [Haskell-cafe] Re: map (-2) [1..5]

2006-09-11 Thread Simon Peyton-Jones
| Well, it seems a shame that we don't have postfix operators already. | I guess that means I am arguing we should introduce a unary postfix | operator, and not even have sugar for factorial, as it conflicts with | array access. | | We *almost* do: | Hugs.Base let (!) 0 = 1; (!) x = x*((!) (x-1))

Re: [Haskell-cafe] Re: map (-2) [1..5]

2006-09-11 Thread Henning Thielemann
On Sun, 10 Sep 2006, Aaron Denney wrote: Of course, there's always a typeclass, where we could add all sorts of other encodings of the Peano axioms, such as binary trees,, but I don't see that that buys us much if we don't also get access to operations beyond them, such as (an

[Haskell-cafe] Re: map (-2) [1..5]

2006-09-11 Thread Aaron Denney
On 2006-09-10, Neil Mitchell [EMAIL PROTECTED] wrote: Hi, I think in practice this wouldn't really be an issue. When you're using natural numbers, you tend to be in a situation where you're either numbering things statically, and not doing any calculations with them, or you're using them as

[Haskell-cafe] Re: map (-2) [1..5]

2006-09-11 Thread Aaron Denney
On 2006-09-11, Simon Peyton-Jones [EMAIL PROTECTED] wrote: | Well, it seems a shame that we don't have postfix operators already. Actually, the up-coming GHC 6.6 does allow this. Awesome. -- Aaron Denney -- ___ Haskell-Cafe mailing list

[Haskell-cafe] Re: map (-2) [1..5]

2006-09-11 Thread Aaron Denney
On 2006-09-11, Henning Thielemann [EMAIL PROTECTED] wrote: On Sun, 10 Sep 2006, Aaron Denney wrote: Of course, there's always a typeclass, where we could add all sorts of other encodings of the Peano axioms, such as binary trees,, but I don't see that that buys us much if we don't also

Re: [Haskell-cafe] Re: map (-2) [1..5]

2006-09-10 Thread David House
On 10/09/06, Aaron Denney [EMAIL PROTECTED] wrote: I still don't like having a plus without a minus. I think in practice this wouldn't really be an issue. When you're using natural numbers, you tend to be in a situation where you're either numbering things statically, and not doing any

Re: [Haskell-cafe] Re: map (-2) [1..5]

2006-09-10 Thread Neil Mitchell
Hi, I think in practice this wouldn't really be an issue. When you're using natural numbers, you tend to be in a situation where you're either numbering things statically, and not doing any calculations with them, or you're using them as a monoid, whereby things only increase. take? primes?

Re: [Haskell-cafe] Re: map (-2) [1..5]

2006-09-10 Thread Jim Apple
See also: torsors http://math.ucr.edu/home/baez/torsors.html Jim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Re: map (-2) [1..5]

2006-09-09 Thread David House
On 09/09/06, Cale Gibbard [EMAIL PROTECTED] wrote: When I first ran into the problem with (-) and sections, I was slightly annoyed with having to write (+ (-1)) Let's not forget that there is the library function 'subtract' for this purpose. What you wrote could be written as (subtract 1),

Re: [Haskell-cafe] Re: map (-2) [1..5]

2006-09-09 Thread Ross Paterson
On Sat, Sep 09, 2006 at 12:57:56AM -0400, Cale Gibbard wrote: Num itself needs to be split, but we can't do it sanely without something like class aliases. I think that a finer grain numeric hierarchy, while retaining Num, etc, is feasible without changing the language: unlike the case of

[Haskell-cafe] Re: map (-2) [1..5]

2006-09-09 Thread Aaron Denney
Cale Gibbard [EMAIL PROTECTED] writes: Another thing to note is that all the natural literals are not, as one might initially think, plain values, but actually represent the embedding of that natural number into the ring (instance of Num), by way of 0 and 1. Excellent point, and good

[Haskell-cafe] Re: map (-2) [1..5]

2006-09-09 Thread Aaron Denney
On 2006-09-08, Jón Fairbairn [EMAIL PROTECTED] wrote: Brian Hulley [EMAIL PROTECTED] writes: In the context of programming, I don't see the problem of just thinking of the integers as a primitive built-in data type which contains some range of positive and negative integers which I'd argue

[Haskell-cafe] Re: map (-2) [1..5]

2006-09-09 Thread Aaron Denney
On 2006-09-08, Brian Hulley [EMAIL PROTECTED] wrote: Leaving aside the question of negative literals for the moment, what's so special about unary minus that it warrants a special syntax? For example in mathematics we have x! to represent (factorial x), which is also an important function,

[Haskell-cafe] Re: map (-2) [1..5]

2006-09-09 Thread Jón Fairbairn
Aaron Denney [EMAIL PROTECTED] writes: We already have this great syntax, parsing semanticsi for precedence, and so forth for declaring infix operators. Couldn't we add to that slightly by declaring postfix operators as well? Actually, declaring a unary operator infix yielding a postfix

[Haskell-cafe] Re: map (-2) [1..5]

2006-09-09 Thread Jón Fairbairn
Aaron Denney [EMAIL PROTECTED] writes: Jón Fairbairn [EMAIL PROTECTED] wrote: I think the present design is wrong because we don't have a type for naturals. Meh. Naturals are reasonably useful sometimes, but not often enough, in my opinion. Any sort of numeric hierarchy designed to

[Haskell-cafe] Re: map (-2) [1..5]

2006-09-09 Thread Jón Fairbairn
Aaron Denney [EMAIL PROTECTED] writes: On 2006-09-08, Jón Fairbairn [EMAIL PROTECTED] wrote: Why shouldn't Naturals be more primitive than Integers? Certainly they're more primitive. Too primitive to have reasonable algebraic properties. Hmph. Naturals obey (a+b)+c == a+(b+c), which is

[Haskell-cafe] Re: map (-2) [1..5]

2006-09-09 Thread Jón Fairbairn
Brian Hulley [EMAIL PROTECTED] writes: Jón Fairbairn wrote: [1] “-” is a varsym. The logical way of achieving what you suggest (ie -1 -2... as constructors for Integer) would be to make it introduce a consym the way “:” does, but then it couldn't be an infix operator anymore. I don't

Re: [Haskell-cafe] Re: map (-2) [1..5]

2006-09-09 Thread Brian Hulley
Jón Fairbairn wrote: Brian Hulley [EMAIL PROTECTED] writes: I imagine that almost every editor at least does lexical fontification, and if so, then I don't think there could be much confusion in practice between these uses of '-'. I think that unnecessarily disadvantages people with poorer

[Haskell-cafe] Re: map (-2) [1..5]

2006-09-09 Thread Aaron Denney
On 2006-09-09, Jón Fairbairn [EMAIL PROTECTED] wrote: Aaron Denney [EMAIL PROTECTED] writes: Meh. Naturals are reasonably useful sometimes, but not often enough, in my opinion. Any sort of numeric hierarchy designed to deal with them would be totally broken from my point of view -- if you

[Haskell-cafe] Re: map (-2) [1..5]

2006-09-08 Thread Jón Fairbairn
Cale Gibbard [EMAIL PROTECTED] writes: Another thing to note is that all the natural literals are not, as one might initially think, plain values, but actually represent the embedding of that natural number into the ring (instance of Num), by way of 0 and 1. I wasn't sure where to add this,

[Haskell-cafe] Re: map (-2) [1..5]

2006-09-08 Thread Jón Fairbairn
Brian Hulley [EMAIL PROTECTED] writes: Leaving aside the question of negative literals for the moment, what's so special about unary minus that it warrants a special syntax? For example in mathematics we have x! to represent (factorial x), which is also an important function, yet no-one is

Re: [Haskell-cafe] Re: map (-2) [1..5]

2006-09-08 Thread Brian Hulley
Jón Fairbairn wrote: Brian Hulley [EMAIL PROTECTED] writes: Cale Gibbard wrote: Anyway, the point of all this is that 0,1,2... are not really literals at all. They're nullary operators which give particular elements of any given instance of Num. Perhaps at some level in the compiler after

Re: [Haskell-cafe] Re: map (-2) [1..5]

2006-09-08 Thread Cale Gibbard
On 08/09/06, Brian Hulley [EMAIL PROTECTED] wrote: Jón Fairbairn wrote: Brian Hulley [EMAIL PROTECTED] writes: Cale Gibbard wrote: Anyway, the point of all this is that 0,1,2... are not really literals at all. They're nullary operators which give particular elements of any given instance of

[Haskell-cafe] Re: map (-2) [1..5]

2006-08-17 Thread Christian Maeder
map (\x - x - 2) [1..5] or map (flip (-) 2) [1..5] HTH Christian Tamas K Papp schrieb: The code in the subject generates an error. I understand why this is (- is treated as part of the number), but I don't know how to solve it, ie how to tell Haskell that - is a function/binary operator?

[Haskell-cafe] Re: map (-2) [1..5]

2006-08-17 Thread Stefan Monnier
I'd have thought it would have been simpler to just make the rule that -2 (no spaces between '-' and '2') would be a single lexeme, But then x-2 won't mean subtract 2 from x but call x with arg -2. Stefan ___ Haskell-Cafe mailing list

[Haskell-cafe] Re: map (-2) [1..5]

2006-08-17 Thread Jón Fairbairn
Stefan Monnier [EMAIL PROTECTED] writes: I'd have thought it would have been simpler to just make the rule that -2 (no spaces between '-' and '2') would be a single lexeme, But then x-2 won't mean subtract 2 from x but call x with arg -2. Well, since the normal typographical convention

Re: [Haskell-cafe] Re: map (-2) [1..5]

2006-08-17 Thread John Meacham
On Thu, Aug 17, 2006 at 11:18:59AM -0400, Stefan Monnier wrote: I'd have thought it would have been simpler to just make the rule that -2 (no spaces between '-' and '2') would be a single lexeme, But then x-2 won't mean subtract 2 from x but call x with arg -2. but now at least a