Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread Jonathan Cast
On Tue, 2008-06-17 at 18:45 +0200, Karoly Negyesi wrote: > Hi, > > The PHP community is discussing the adding of closures and lambdas to > the language, see the proposal at http://wiki.php.net/rfc/closures > > If someone with knowledge of both languages could take a quick look it > would be great

Re: [Haskell-cafe] monomorphism restriction

2008-06-14 Thread Jonathan Cast
On Sat, 2008-06-14 at 17:19 +1000, Rafal Kolanski wrote: > Ryan Ingram wrote: > > sumns 0 = 0 > > sumns x = sumns (x-1) + n > > > > Without the monomorphism restriction, computing n is a function call; > > it is evaluated each time it is asked for. > > I'm relatively new to Haskell, and since thi

Re: [Haskell-cafe] monomorphism restriction

2008-06-13 Thread Jonathan Cast
On Wed, 2008-06-11 at 20:24 -0700, Don Stewart wrote: > page: > > Definition of f: > >f = foldr (+) 0 > > Types: > >0 :: (Num t) => t > >foldr (+) 0 :: Num a => [a] -> a > >f :: [Integer] -> Integer > > > > Please remind me, again, of the advantages of f being something different

Re: [Haskell-cafe] automatically deriving Map and Filter on datatypes etc.

2008-06-05 Thread Jonathan Cast
On 5 Jun 2008, at 1:39 AM, Thomas Davie wrote: Even deriving an instance of Functor seems rather implausable, what should it do for data Wierd a b = Nil | A a (Wierd a b) | B b (Wierd a b) Should fmap's function argument operate on 'a's, 'b's, or both? class Functor (f :: * -> *) where ...

Re: [Haskell-cafe] Parsec, updateState, and failure

2008-05-31 Thread Jonathan Cast
On 31 May 2008, at 7:12 AM, Dimitry Golubovsky wrote: Hi, If a parser which updated user state fails, will such update be reverted? Suppose we have two parsers combined with <|> p = p1 <|> p2 p1 has the following: p1 = try $ do ... -- getting something from the input stream updateStat

Re: [Haskell-cafe] modelling C in Haskell ..

2008-05-30 Thread Jonathan Cast
On 30 May 2008, at 12:29 AM, Galchin, Vasili wrote: compactness in writing and also namespace pollution .. ;^) I know what the advantages of C's notation are. But getting the best notation out of Haskell generally doesn't happen by trying to make your code look like C. So the general an

Re: [Haskell-cafe] modelling C in Haskell ..

2008-05-30 Thread Jonathan Cast
On 29 May 2008, at 11:46 PM, Galchin, Vasili wrote: Hello, I don't want to write kludgy Haskell code! typedef struct blah { int val1; union { int val2; struct { int val3; int val4; } } }C_typ

Re: [Haskell-cafe] So how do people pronounce 'cabal' around here?

2008-05-29 Thread Jonathan Cast
On 29 May 2008, at 10:44 AM, Dan Piponi wrote: On Wed, May 28, 2008 at 6:38 PM, Richard A. O'Keefe <[EMAIL PROTECTED]> wrote: I've always pronounced it k'BAHL, but was surprised to find that the OED only countenances a short second syllable: The reason I originally asked is that American, Br

Re: [Haskell-cafe] bottomless Top?

2008-05-15 Thread Jonathan Cast
On 15 May 2008, at 4:29 AM, Conor McBride wrote: Replying slap-foreheadedly to own post... On 15 May 2008, at 11:56, Conor McBride wrote: Folks I'm also wondering whether it makes sense to have a "bottomless Top" type, with constructor _ and lazy pattern _ (with (undefined :: Top) equal to _

Re: [Haskell-cafe] Re: Endianess

2008-05-14 Thread Jonathan Cast
On 14 May 2008, at 2:13 PM, Claus Reinke wrote: It's not that simple with bits. They lack consistency just like the usual US date format and the way Germans read numbers. So you claim that you pronounce 14 tenty-four? In German pronunciation is completely uniform from 13 to 99. http://w

Re: [Haskell-cafe] I hate Haskell's typeclasses

2008-04-22 Thread Jonathan Cast
On 22 Apr 2008, at 9:53 AM, Ryan Ingram wrote: On Mon, Apr 21, 2008 at 10:58 PM, Jonathan Cast <[EMAIL PROTECTED]> wrote: I must have failed to communicate well. To me, the point of giving a class a name is that then you can write a program that is parametric over the elements o

Re: [Haskell-cafe] I hate Haskell's typeclasses

2008-04-22 Thread Jonathan Cast
On 22 Apr 2008, at 8:03 PM, Derek Elkins wrote: On Mon, 2008-04-21 at 22:58 -0700, Jonathan Cast wrote: class Forceable alpha where seq :: alpha -> beta -> beta Instances derived automatically by the compiler, when possible, for every type (like Typeable should be). We can omit fun

Re: [Haskell-cafe] I hate Haskell's typeclasses

2008-04-21 Thread Jonathan Cast
On 21 Apr 2008, at 12:50 AM, Ryan Ingram wrote: On Fri, Apr 18, 2008 at 10:01 PM, Jonathan Cast <[EMAIL PROTECTED]> wrote: {-# GHC_OPTIONS -foverlapping-instances -fundecidable-instances #-} :) What you want to work is precisely what this allows. Of course, I bring that point up

Re: [Haskell-cafe] I hate Haskell's typeclasses

2008-04-20 Thread Jonathan Cast
On 20 Apr 2008, at 3:05 AM, David MacIver wrote: On Sun, Apr 20, 2008 at 4:46 AM, Jonathan Cast <[EMAIL PROTECTED]> wrote: On 19 Apr 2008, at 5:02 AM, David MacIver wrote: Independently of the rant... On Sat, Apr 19, 2008 at 6:01 AM, Jonathan Cast <[EMAIL PROTECTED]> wrote:

Re: [Haskell-cafe] I hate Haskell's typeclasses

2008-04-19 Thread Jonathan Cast
On 19 Apr 2008, at 5:02 AM, David MacIver wrote: Independently of the rant... On Sat, Apr 19, 2008 at 6:01 AM, Jonathan Cast <[EMAIL PROTECTED]> wrote: But why do I need to jump through these hoops for a perfectly safe & commonly desired operation? It's called a proof oblig

Re: [Haskell-cafe] I hate Haskell's typeclasses

2008-04-18 Thread Jonathan Cast
On 18 Apr 2008, at 9:29 PM, Ryan Ingram wrote: WARNING: RANT AHEAD. WARNING: RESPONSE IN THE SPIRIT OF THE ORIGINAL AHEAD. Hopefully this fires off some productive discussion on how to fix these problems! {-# GHC_OPTIONS -foverlapping-instances -fundecidable-instances #-} :) What you wan

Re: [Haskell-cafe] deriving

2008-04-08 Thread Jonathan Cast
On 8 Apr 2008, at 7:06 PM, Dan Weston wrote: Richard A. O'Keefe wrote: On 8 Apr 2008, at 7:15 am, Dan Weston wrote: [1] Yes, I know that "conciseness" is the much more common and accepted word for this, but if we can say "precision", "decision", and "incision", then it seems foolish to not

Re: [Haskell-cafe] compilation succeeds -- execution fails

2008-03-30 Thread Jonathan Cast
On 29 Mar 2008, at 10:21 PM, Jason Dusek wrote: Stefan O'Rear <[EMAIL PROTECTED]> wrote: The only type that you are allowed to assume corresponds to a C int is CInt, in the Foreign.C.Types module. This probably isn't the problem, but it could make problems of its own on a 64-bit or other

Re: [Haskell-cafe] Parsec Expected Type

2008-03-28 Thread Jonathan Cast
On 28 Mar 2008, at 2:02 AM, Paul Keir wrote: Thanks, I'd thought it was something to do with incompatible types. I can now create a simpler problem: tester2 = reserved "parameter" <|> symbol ":" Certainly I could use reserved ":" instead of symbol, but where is my thinking with symbol here

Re: [Haskell-cafe] Re: (flawed?) benchmark : sort

2008-03-10 Thread Jonathan Cast
On 10 Mar 2008, at 4:00 AM, Adrian Hey wrote: Neil Mitchell wrote: 2) What does it do with duplicate elements in the list? I expect it deletes them. To avoid this, you'd need to use something like fromListWith, keeping track of how many duplicates there are, and expanding at the end. Th

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-10 Thread Jonathan Cast
On 10 Mar 2008, at 12:37 AM, Donn Cave wrote: On Mar 9, 2008, at 1:07 PM, Henning Thielemann wrote: Errors are programming errors and must be fixed as Denis explained. Thus there is no need for a complex system of handling these situations at run-time. The program error might be unexpect

Re: [Haskell-cafe] Database relations mapping

2008-02-23 Thread Jonathan Cast
On 23 Feb 2008, at 3:30 AM, Radosław Grzanka wrote: Hi, I'm developing toy application to learn HDBC. I have "problem" with doing relations mapping. Actually I don't know is it a problem or "feature". ;) Anyway, I have two tables with relation between them: (this example is simplified to the

Re: [Haskell-cafe] Re: Doubting Haskell

2008-02-17 Thread Jonathan Cast
On 17 Feb 2008, at 1:12 AM, Colin Paul Adams wrote: "apfelmus" == apfelmus <[EMAIL PROTECTED]> writes: apfelmus> Colin Paul Adams wrote: Left? Right? Hardly descriptive terms. Sounds like a sinister language to me. apfelmus> The mnemonics is that Right x is "right" in the sense o

Re: [Haskell-cafe] Arrows: definition of pure & arr

2008-02-17 Thread Jonathan Cast
On 16 Feb 2008, at 11:40 PM, Peter Verswyvelen wrote: After having played with some packages that use arrows, and after having read the very nice "programming with arrows" paper I wanted to build some of my own. Strangely my code did not work, even the simplest function got stuck in an in

Re: [Haskell-cafe] Doubting Haskell

2008-02-16 Thread Jonathan Cast
On 16 Feb 2008, at 11:46 PM, Anton van Straaten wrote: Colin Paul Adams wrote: "Cale" == Cale Gibbard <[EMAIL PROTECTED]> writes: Cale> So, the first version: Cale> import System.IO import Control.Exception (try) Cale> main = do mfh <- try (openFile "myFile" ReadMode) case mfh

Re: [Haskell-cafe] Doubting Haskell

2008-02-16 Thread Jonathan Cast
On 16 Feb 2008, at 5:04 PM, Donn Cave wrote: On Feb 16, 2008, at 3:46 PM, Philippa Cowderoy wrote: On Sat, 16 Feb 2008, Alan Carter wrote: I'm a Haskell newbie, and this post began as a scream for help. Extremely understandable - to be blunt, I don't really feel that Haskell is ready a

Re: [Haskell-cafe] GHC strange behavior

2008-02-16 Thread Jonathan Cast
On 16 Feb 2008, at 3:06 PM, Ruslan Evdokimov wrote: Hi, all! I have strange GHC behavior. Consider the code: import Control.Parallel main = print (o `par` (fromInteger e) / (fromInteger o)) where [e,o] = map sum $ map (`filter` numbers) [even, odd] numbers = [1..1000] When it comp

Re: [Haskell-cafe] Re: A question about "monad laws"

2008-02-11 Thread Jonathan Cast
On 11 Feb 2008, at 7:52 AM, Arnar Birgisson wrote: Hi all, On Feb 11, 2008 3:14 PM, apfelmus <[EMAIL PROTECTED]> wrote: I will be mean by asking the following counter question: x + (y + z) = (x + y) + z is a mathematical identity. If it is a mathematical identity, a programmer need not ca

Re: [Haskell-cafe] A question about "monad laws"

2008-02-11 Thread Jonathan Cast
On 11 Feb 2008, at 5:33 AM, Deokjae Lee wrote: Tutorials about monad mention the "monad axioms" or "monad laws". The tutorial "All About Monads" says that "It is up to the programmer to ensure that any Monad instance he creates satisfies the monad laws". The following is one of the laws. (x >>

Re: [Haskell-cafe] GHC + interactive input/output

2008-02-08 Thread Jonathan Cast
On 8 Feb 2008, at 6:50 PM, Jonathan Cast wrote: On 8 Feb 2008, at 6:34 PM, Ryan Ingram wrote: import System.IO myGetLine = hFlush stdout >> getLine That fixes this issue, certainly (although it's superfluous; my program really does contain only a single call to getLine)... N

Re: [Haskell-cafe] GHC + interactive input/output

2008-02-08 Thread Jonathan Cast
On 8 Feb 2008, at 6:34 PM, Ryan Ingram wrote: import System.IO myGetLine = hFlush stdout >> getLine That fixes this issue, certainly (although it's superfluous; my program really does contain only a single call to getLine)... Nevertheless, it would be nice to at least have it in the stand

Re: [Haskell-cafe] GHC + interactive input/output

2008-02-08 Thread Jonathan Cast
On 8 Feb 2008, at 5:29 PM, Philip Weaver wrote: GHC certain *could* do this, but it's arguably not the right thing to do. For performance, the operating system buffers writes until it is ready to write large chunks at a time. If you do not want this behavior, change the buffering mode fro

Re: [Haskell-cafe] GHC + interactive input/output

2008-02-08 Thread Jonathan Cast
On 8 Feb 2008, at 4:50 PM, Brandon S. Allbery KF8NH wrote: On Feb 8, 2008, at 19:41 , Philip Weaver wrote: Your "gsi> " is buffered because there's no newline at the end. To flush the buffer and force it to be printed immediately, use 'hFlush' from the System.IO library, or use 'hSetBuffe

[Haskell-cafe] GHC + interactive input/output

2008-02-08 Thread Jonathan Cast
$ cat > foo.c #include int main() { char s[1024]; printf("gsi> "); gets(s); printf("%s\n", s); return 0; } $ make foo cc gsi.c -o gsi $ ./foo warning: this program uses gets(), which is unsafe. gsi> hello hello $ cat > foo.hs main = do putStr "gsi> " s <- getLine putStrLn s

Re: [Haskell-cafe] :i and :t give different types

2008-02-07 Thread Jonathan Cast
On 7 Feb 2008, at 12:30 PM, Chad Scherrer wrote: On Feb 7, 2008 11:57 AM, Don Stewart <[EMAIL PROTECTED]> wrote: Ah, yes, missing parens! Well spotted. So a pretty printer wibble in GHC? -- Don Yeah, that was my first concern, but then I noticed the quantification was different, so I'm stil

Re: [Haskell-cafe] Signature for non-empty filter

2008-02-07 Thread Jonathan Cast
On 7 Feb 2008, at 12:07 AM, Henning Thielemann wrote: On Wed, 6 Feb 2008, Jonathan Cast wrote: On 6 Feb 2008, at 1:54 PM, Matthew Pocock wrote: On Wednesday 06 February 2008, Henning Thielemann wrote: If the type checker does not terminate because the checked function does not terminate

Re: [Haskell-cafe] background question about IO monad

2008-02-07 Thread Jonathan Cast
On 6 Feb 2008, at 11:32 PM, Uwe Hollerbach wrote: All right, after a bit of dinner and some time to mess about, here's another attempt to check my understanding: here is a simplified version of the lisp-time example: module Main where import System.Time pure_fn :: Integer -> String pure_fn n

Re: [Haskell-cafe] background question about IO monad

2008-02-06 Thread Jonathan Cast
On 6 Feb 2008, at 7:30 PM, Uwe Hollerbach wrote: Hi, all, thanks for the responses. I understand the distinction between pure functions and impure functions/procedures/IO actions, Um, I'm not sure of that, given what you go on to say. it just felt to me in the samples that I quoted that I wa

Re: [Haskell-cafe] Mutable arrays

2008-02-06 Thread Jonathan Cast
On 6 Feb 2008, at 5:17 PM, Jeff φ wrote: IO(U)Arrays are only one variant of mutable Array, there are also ST (U)Arrays, which are often preferred. I should have worded my question better. The MArray interface is implemented in both the ST and IO monad. A state monad seems like a logical

Re: [Haskell-cafe] Mutable arrays

2008-02-06 Thread Jonathan Cast
I and some others proposed) guarantee you a constant amount of memory consumed and is perfectly safe too, is the Clean solution really so much better ? Jonathan Cast : I'm confused --- does uToList_2D return the head of the list before or after it finishes reading the array? If before, then

Re: [Haskell-cafe] Signature for non-empty filter

2008-02-06 Thread Jonathan Cast
On 6 Feb 2008, at 1:54 PM, Matthew Pocock wrote: On Wednesday 06 February 2008, Henning Thielemann wrote: If the type checker does not terminate because the checked function does not terminate on the example input, then the function does not pass the type check and as a compromise this wou

Re: [Haskell-cafe] Mutable arrays

2008-02-05 Thread Jonathan Cast
On 5 Feb 2008, at 10:14 PM, Jeff φ wrote: On Feb 5, 2008 4:58 PM, Chaddaï Fouché <[EMAIL PROTECTED]> wrote: 2008/2/5, Jeff φ <[EMAIL PROTECTED]>: > This is interesting. I've been programming in Concurrent Clean for a while. > Instead of monads, Clean supports unique types for mutable

Re: [Haskell-cafe] fmap vs. liftM

2008-02-04 Thread Jonathan Cast
On 4 Feb 2008, at 6:22 AM, Felipe Lessa wrote: Hi there, Reading http://www.haskell.org/haskellwiki/Things_to_avoid I found an interesting saying: "By the way, in the case of IO monad the Functor class method fmap and the Monad based function liftM are the same." I always tought that prop ::

Re: [Haskell-cafe] newbie q about types

2008-02-01 Thread Jonathan Cast
On 1 Feb 2008, at 10:30 PM, Logesh Pillay wrote: I have a list. Each component is a list with 2 whole numbers. First off, why? In Haskell (unlike dynamically typed languages like Python or Perl), if you know you always have two elements, you want a pair (519432,525806), not a list [51943

Re: [Haskell-cafe] Simple network client

2008-01-31 Thread Jonathan Cast
On 31 Jan 2008, at 1:23 AM, Reinier Lamers wrote: Bayley, Alistair wrote: More than one person has posted previously about the flaws and traps of lazy IO. A common position seems to be "don't do lazy IO". Still, when I was browsing the Haskell' wiki a few days ago, I couldn't find any prop

Re: [Haskell-cafe] Poor libraries documentation

2008-01-30 Thread Jonathan Cast
On 30 Jan 2008, at 7:19 PM, Anton van Straaten wrote: Derek Elkins wrote: On Thu, 2008-01-31 at 02:18 +, Neil Mitchell wrote: ... It isn't something that would throw a C programmer off, but it is something that could confuse a pure Haskell programmer. And the only way I could be sure of r

Re: [Haskell-cafe] Stacking monads - beginner design question

2008-01-29 Thread Jonathan Cast
On 29 Jan 2008, at 9:44 PM, Adam Smyczek wrote: Hi, My application has to manage a data set. I assume the state monad is designed for this. The state changes in functions that: a. perform IO actions and b. return execution status and execution trace (right now I'm using WriteT for this).

Re: [Haskell-cafe] Haskell maximum stack depth

2008-01-29 Thread Jonathan Cast
On 29 Jan 2008, at 1:28 AM, Neil Mitchell wrote: Hi Adrian, The "bug" is in ghc stack management. Why is it so important that the stack size is arbitrarily limited? It's not, but it makes some things easier and faster. A better question is why is it important for the stack to grow dynamical

Re: [Haskell-cafe] Haskell maximum stack depth

2008-01-28 Thread Jonathan Cast
On 28 Jan 2008, at 11:00 PM, Henning Thielemann wrote: On Mon, 28 Jan 2008, Jonathan Cast wrote: Or, to put it another way, the bugs Java's stack overflow is designed to catch are considered good style in Haskell. I consider explicit recursion in Haskell as bad style. One should use h

Re: [Haskell-cafe] Haskell maximum stack depth

2008-01-28 Thread Jonathan Cast
On 28 Jan 2008, at 10:07 AM, Neil Mitchell wrote: Hi ghc uses a pretty conventional stack AFAIK, and it is arbitrarily limited, but you can change the limit with +RTS options. GHC uses a conventional stack (in that you put stuff at the top, and take it off from the top), but it is not a con

Re: [Haskell-cafe] How to organize code

2008-01-28 Thread Jonathan Cast
On 27 Jan 2008, at 11:18 PM, L.Guo wrote: Hi, How do you organize code ? Here is a sample. Acturally, I am thinking about using this plan. Any suggestions ? -- BasicalType.hs type Position = (Int,Int) data Box = Box { pos :: Position } data Chain = Chain { pos :: [Position] } -- Object.h

Re: [Haskell-cafe] Why functional programming matters

2008-01-24 Thread Jonathan Cast
On 24 Jan 2008, at 3:04 PM, Evan Laforge wrote: This takes an iterator over some collection of Foos and finds the one with the highest value of updateTime. 9 lines of code, or 12 with the closing curly brackets. In Haskell this is so short and obvious you probably wouldn't bother declaring

Re: [Haskell-cafe] Throwback of inferred types

2008-01-20 Thread Jonathan Cast
On 20 Jan 2008, at 1:02 PM, [EMAIL PROTECTED] wrote: On 2008.01.19 19:11:13 +0100, Peter Verswyvelen <[EMAIL PROTECTED]> scribbled 1.4K characters: The problem is that this only works when the complete source file compiles correctly no? Yes. As I said, it's a very hackish solution - think

Re: [Haskell-cafe] Re: 0/0 > 1 == False

2008-01-19 Thread Jonathan Cast
On 19 Jan 2008, at 2:52 AM, Kalman Noel wrote: Jonathan Cast wrote: On 12 Jan 2008, at 3:23 AM, Kalman Noel wrote: (2) lim a_n = ∞ [...] (2) means that the sequence does not converge, To a value in R. Again, inf is a perfectly well defined extended real number, and behaves like

Re: [Haskell-cafe] One-line haskell program with GHC

2008-01-18 Thread Jonathan Cast
On 18 Jan 2008, at 2:00 PM, Clifford Beshers wrote: 2008/1/18 Sukit Tretriluxana <[EMAIL PROTECTED]>: Hi, I don't know if it's been asked before. I just wonder if GHC supports some sort of one-liner program that can be specify right as the argument to either ghci or runghc program. In perl,

Re: [Haskell-cafe] STM in F#

2008-01-17 Thread Jonathan Cast
On 17 Jan 2008, at 7:02 PM, Don Stewart wrote: http://cs.hubfs.net/blogs/hell_is_other_languages/archive/ 2008/01/16/4565.aspx I imagine this can only ease the process of learning Haskell, and broaden the base of possible Haskellers, as more people on using .NET stuff become familiar with mode

Re: [Haskell-cafe] ErrorT and catchError question

2008-01-15 Thread Jonathan Cast
On 15 Jan 2008, at 7:54 PM, Adam Smyczek wrote: On Jan 15, 2008, at 7:34 PM, Brandon S. Allbery KF8NH wrote: On Jan 15, 2008, at 22:05 , Adam Smyczek wrote: Ups, resend, first response did not make into the list. On Jan 14, 2008, at 9:33 PM, Brandon S. Allbery KF8NH wrote: On Jan 15, 20

Re: [Haskell-cafe] Re: 0/0 > 1 == False

2008-01-14 Thread Jonathan Cast
On 14 Jan 2008, at 9:56 AM, David Roundy wrote: On Fri, Jan 11, 2008 at 07:10:20PM -0800, Jonathan Cast wrote: On 11 Jan 2008, at 10:12 AM, Achim Schneider wrote: David Roundy <[EMAIL PROTECTED]> wrote: Prelude> let x=1e-300/1e300 Prelude> x 0.0 Prelude> x/x NaN The "

Re: [Haskell-cafe] Re: All equations must have the same arity - why?

2008-01-13 Thread Jonathan Cast
On 13 Jan 2008, at 5:49 PM, Achim Schneider wrote: Jonathan Cast <[EMAIL PROTECTED]> wrote: On 13 Jan 2008, at 5:27 PM, Achim Schneider wrote: Answer #2: Because you can't write f x = case x of [] -> [1] -> sort.nub But why not? Because arities are

Re: [Haskell-cafe] All equations must have the same arity - why?

2008-01-13 Thread Jonathan Cast
On 13 Jan 2008, at 5:38 PM, [EMAIL PROTECTED] wrote: Neil Mitchell writes: I quite like the idea of permitting equations to have different arities. It removes restrictions, makes things more regular etc. More regular??? My goodness... Of course, it removes restrictions. But in the history

Re: [Haskell-cafe] Re: All equations must have the same arity - why?

2008-01-13 Thread Jonathan Cast
On 13 Jan 2008, at 5:27 PM, Achim Schneider wrote: "Neil Mitchell" <[EMAIL PROTECTED]> wrote: Hi, It's nice to write functions in point free style: f = sort . nub But sometimes I have to add an extra case, on a certain value: f [] = [1] f = sort . nub But now these equations have differen

[Haskell-cafe] Re: All equations must have the same arity - why?

2008-01-13 Thread Jonathan Cast
On 13 Jan 2008, at 4:56 PM, [EMAIL PROTECTED] wrote: Jonathan Cast writes: On 13 Jan 2008, at 4:15 PM, Achim Schneider wrote: ... never mind... I'm glad you are capable of ever so nobly assigning the purest imaginable motives to the designers of Haskell. You are an inspiration

Re: [Haskell-cafe] Re: All equations must have the same arity - why?

2008-01-13 Thread Jonathan Cast
On 13 Jan 2008, at 4:15 PM, Achim Schneider wrote: "Neil Mitchell" <[EMAIL PROTECTED]> wrote: i.e. lift the arities to the longest argument list. Is there a reason this isn't done? Most likely not, there are being made up right now. I'm glad you are capable of ever so nobly assigning the

Re: [Haskell-cafe] Re: 0/0 > 1 == False

2008-01-13 Thread Jonathan Cast
On 12 Jan 2008, at 4:06 AM, Achim Schneider wrote: Kalman Noel <[EMAIL PROTECTED]> wrote: Achim Schneider wrote: Actually, lim( 0 ) * lim( inf ) isn't anything but equals one, and the anything is defined to one (or, rather, is _one_ anything) to be able to use the abstraction. It's a bit like

Re: [Haskell-cafe] Re: 0/0 > 1 == False

2008-01-13 Thread Jonathan Cast
On 12 Jan 2008, at 3:33 AM, Cristian Baboi wrote: On Sat, 12 Jan 2008 13:23:41 +0200, Kalman Noel <[EMAIL PROTECTED]> wrote: Achim Schneider wrote: Actually, lim( 0 ) * lim( inf ) isn't anything but equals one, and the anything is defined to one (or, rather, is _one_ anything) to be able to

Re: [Haskell-cafe] Re: 0/0 > 1 == False

2008-01-13 Thread Jonathan Cast
On 12 Jan 2008, at 3:23 AM, Kalman Noel wrote: Achim Schneider wrote: Actually, lim( 0 ) * lim( inf ) isn't anything but equals one, and the anything is defined to one (or, rather, is _one_ anything) to be able to use the abstraction. It's a bit like the difference between eight pens and a box

Re: [Haskell-cafe] Re: 0/0 > 1 == False

2008-01-13 Thread Jonathan Cast
On 11 Jan 2008, at 11:25 PM, Achim Schneider wrote: Jonathan Cast <[EMAIL PROTECTED]> wrote: On 11 Jan 2008, at 10:12 AM, Achim Schneider wrote: David Roundy <[EMAIL PROTECTED]> wrote: Prelude> let x=1e-300/1e300 Prelude> x 0.0 Prelude> x/x NaN The "true"

Re: [Haskell-cafe] Comments and suggestions on code

2008-01-12 Thread Jonathan Cast
On 12 Jan 2008, at 4:42 PM, Andre Nathan wrote: On Sat, 2008-01-12 at 16:00 -0800, Jonathan Cast wrote: Wait, the last entry? If you're just printing out the values, then no --- those should have been garbage collected already. Won't they be garbage collected only after the las

Re: [Haskell-cafe] Comments and suggestions on code

2008-01-12 Thread Jonathan Cast
On 12 Jan 2008, at 10:26 AM, Andre Nathan wrote: On Sat, 2008-01-12 at 10:11 -0800, Jonathan Cast wrote: A nit: the list is almost certainly getting created lazily, or you'd get more than 300% more memory usage. But you still get the list's cons cells as your bookkeeping baggage

Re: [Haskell-cafe] [newbie question] Memoization automatic in Haskell?

2008-01-12 Thread Jonathan Cast
On 12 Jan 2008, at 3:30 PM, David Benbennick wrote: On 1/12/08, Henning Thielemann <[EMAIL PROTECTED]> wrote: Caching is not the default, but you can easily code this by yourself: Define an array and initialize it with all function values. Because of lazy evaluation the function values are

Re: [Haskell-cafe] Comments and suggestions on code

2008-01-12 Thread Jonathan Cast
On 12 Jan 2008, at 10:26 AM, Andre Nathan wrote: On Sat, 2008-01-12 at 10:11 -0800, Jonathan Cast wrote: A nit: the list is almost certainly getting created lazily, or you'd get more than 300% more memory usage. But you still get the list's cons cells as your bookkeeping baggage

Re: [Haskell-cafe] [newbie question] Memoization automatic in Haskell?

2008-01-12 Thread Jonathan Cast
On 12 Jan 2008, at 3:16 PM, Hugh Perkins wrote: On Jan 12, 2008 10:54 PM, Henning Thielemann <[EMAIL PROTECTED]> wrote: On Sat, 12 Jan 2008, Hugh Perkins wrote: I guess that Haskell's referential transparence means the answers to the isPerfectSquare will be cached, ie automatically memoized?

Re: [Haskell-cafe] Comments and suggestions on code

2008-01-12 Thread Jonathan Cast
On 12 Jan 2008, at 7:19 AM, Andre Nathan wrote: On Fri, 2008-01-11 at 19:14 -0800, Jonathan Cast wrote: These are all known and expected. As I said, you can expect lazy versions to normally be slower than explicit loops. The question is whether 50% more time and 300% more memory has a higher

Re: [Haskell-cafe] Re: 0/0 > 1 == False

2008-01-12 Thread Jonathan Cast
On 12 Jan 2008, at 1:45 AM, Achim Schneider wrote: Kalman Noel <[EMAIL PROTECTED]> wrote: Achim Schneider wrote: whereas lim( 0 ) * lim( inf ) is anything you want Indeed I suppose that »lim inf«, which is a notation I'm not familiar with, is not actually defined to mean anything? It's an

Re: [Haskell-cafe] Comments and suggestions on code

2008-01-11 Thread Jonathan Cast
On 11 Jan 2008, at 2:24 PM, Andre Nathan wrote: processEntry :: DirStream -> IO () processEntry ds = do entry <- readDirStream ds if entry =~ "^[0-9]+$" then do putStrLn entry processEntry ds else if entry == "" then return () else processEntry ds bar :: IO () bar

Re: [Haskell-cafe] Comments and suggestions on code

2008-01-11 Thread Jonathan Cast
On 11 Jan 2008, at 2:20 PM, Andre Nathan wrote: On Fri, 2008-01-11 at 13:27 -0200, Andre Nathan wrote: I was wondering if laziness would make it run as if it was a single O(n) operation (get one directory entry "on demand", pass it to filter and then to insertInTree), because only one entry i

Re: [Haskell-cafe] Comments and suggestions on code

2008-01-11 Thread Jonathan Cast
On 11 Jan 2008, at 7:27 AM, Andre Nathan wrote: On Thu, 2008-01-10 at 20:37 -0800, Jonathan Cast wrote: It might be faster; laziness usually has higher constants than direct implementations. But I doubt the difference is critical in this case, and I would definitely time a re-writing and

Re: [Haskell-cafe] Re: 0/0 > 1 == False

2008-01-11 Thread Jonathan Cast
On 11 Jan 2008, at 10:12 AM, Achim Schneider wrote: David Roundy <[EMAIL PROTECTED]> wrote: Prelude> let x=1e-300/1e300 Prelude> x 0.0 Prelude> x/x NaN The "true" answer here is that x/x == 1.0 (not 0 or +Infinity), but there's no way for the computer to know this, so it's NaN. Didn't catch

Re: [Haskell-cafe] Re: Why purely in haskell?

2008-01-11 Thread Jonathan Cast
On 11 Jan 2008, at 5:13 AM, Achim Schneider wrote: Jonathan Cast <[EMAIL PROTECTED]> wrote: What kind of mathematics? I don't know of any mathematics where algebraic simplifications are employed without proof of the underlying equations (in some denotational model). Mathematic

Re: [Haskell-cafe] Re: Why purely in haskell?

2008-01-10 Thread Jonathan Cast
On 10 Jan 2008, at 7:55 AM, Achim Schneider wrote: "Daniel Yokomizo" <[EMAIL PROTECTED]> wrote: On Jan 10, 2008 3:36 PM, Achim Schneider <[EMAIL PROTECTED]> wrote: [EMAIL PROTECTED] wrote: Niko Korhonen writes: ... Although it could be argued that laziness is the cause of some very obscur

Re: Re[2]: [Haskell-cafe] confusion about 'instance'....

2008-01-10 Thread Jonathan Cast
On 10 Jan 2008, at 6:04 AM, Nicholls, Mark wrote: -Original Message- From: Bulat Ziganshin [mailto:[EMAIL PROTECTED] Sent: 10 January 2008 13:36 To: Nicholls, Mark Cc: Luke Palmer; haskell-cafe@haskell.org Subject: Re[2]: [Haskell-cafe] confusion about 'instance' Hello Mark, Thur

Re: [Haskell-cafe] Comments and suggestions on code

2008-01-10 Thread Jonathan Cast
On 10 Jan 2008, at 10:21 AM, Andre Nathan wrote: Hi Jonathan On Wed, 2008-01-09 at 21:32 -0800, Jonathan Cast wrote: An actual coding question, abuse? We should be so lucky. :) Your comments are much appreciated. You're welcome. This function is fairly complicated, simply becau

Re: [Haskell-cafe] Comments and suggestions on code

2008-01-09 Thread Jonathan Cast
On 9 Jan 2008, at 7:57 PM, Andre Nathan wrote: Hello I've just found time to finish writing my first "real world" program, so I thought I'd post it here and ask for insight on general issues such as if there's anything that isn't done "the Haskell way", or if there's something that could b

Re: [Haskell-cafe] Re: Currying and Partial Evaluation

2008-01-08 Thread Jonathan Cast
On 8 Jan 2008, at 9:01 PM, Derek Elkins wrote: On Tue, 2008-01-08 at 21:44 -0800, Jonathan Cast wrote: On 8 Jan 2008, at 7:56 PM, Derek Elkins wrote: Can we stop using confusing, misleading or outright wrong definitions and analogies? What, and bring CS to a halt? CS wouldn't b

Re: [Haskell-cafe] Re: Currying and Partial Evaluation

2008-01-08 Thread Jonathan Cast
On 8 Jan 2008, at 7:56 PM, Derek Elkins wrote: Can we stop using confusing, misleading or outright wrong definitions and analogies? What, and bring CS to a halt? jcc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailm

Re: [Haskell-cafe] Re: Is there anyone out there who can translate C# generics into Haskell?

2008-01-08 Thread Jonathan Cast
On 8 Jan 2008, at 3:38 PM, Achim Schneider wrote: ---$<--- or, while I'm at it ---$<--- moveBall :: State' -> State' moveBall state = state {ballPos' = (bpx+bvx, bpy+bvy)} where (bpx, bpy) = ballPos' state (bvx, bvy) = ballVel' state idle'' :: StateRef -> IdleCallback idle'' st =

Re: [Haskell-cafe] Re: Wikipedia on first-class object

2008-01-06 Thread Jonathan Cast
On 6 Jan 2008, at 4:00 PM, Aaron Denney wrote: On 2008-01-06, Jonathan Cast <[EMAIL PROTECTED]> wrote: To wit, I do not believe the term `declarative' has any single referent, even in the sense that the term `functional' has any single referent. I find the only similarity bet

Re: [Haskell-cafe] Wikipedia on first-class object

2008-01-06 Thread Jonathan Cast
On 6 Jan 2008, at 12:13 PM, Derek Elkins wrote: On Sun, 2008-01-06 at 09:45 -0800, Jonathan Cast wrote: On 6 Jan 2008, at 3:02 AM, Derek Elkins wrote: On Fri, 2007-12-28 at 17:54 -0600, Jonathan Cast wrote: Programming languages are generally classified into three groups, imperative

Re: [Haskell-cafe] Wikipedia on first-class object

2008-01-06 Thread Jonathan Cast
On 6 Jan 2008, at 1:31 PM, [EMAIL PROTECTED] wrote: Derek Elkins writes: Jonathan Cast wrote: I find the term `declarative' to be almost completely meaningless. I was originally thinking of having the final sentence: "There are no clear, accepted meanings for any of these terms

Re: [Haskell-cafe] Re: Basic question concerning the category Hask (was: concerning data constructors)

2008-01-06 Thread Jonathan Cast
On 6 Jan 2008, at 12:27 PM, Dominic Steinitz wrote: Jonathan Cast fastmail.fm> writes: Extensionality is a key part of the definition of all of these constructions. The categorical rules are designed to require, in concrete categories, that the range of the two injections int

Re: [Haskell-cafe] Newbie question related to list evaluation

2008-01-06 Thread Jonathan Cast
On 6 Jan 2008, at 10:34 AM, Sai Hemanth K wrote: Hi, I am new to functional and lazy programming languages ( that's correct, my life has been pretty pathetic so far) and am not able to understand GHC's behaviour for a particular function. Can someone help me please? I am trying to write

Re: [Haskell-cafe] Basic question concerning the category Hask (was: concerning data constructors)

2008-01-06 Thread Jonathan Cast
On 6 Jan 2008, at 5:32 AM, Yitzchak Gale wrote: (sorry, I hit the send button) What is the lifted version you are referring to? Take the ordinary disjoint union, and then add a new _|_ element, distinct from both existing copies of _|_ (which are still distinct from each other). Now why i

Re: [Haskell-cafe] Basic question concerning the category Hask (was: concerning data constructors)

2008-01-06 Thread Jonathan Cast
On 6 Jan 2008, at 3:55 AM, Yitzchak Gale wrote: I wrote: What goes wrong with finite coproducts? The obvious thing to do would be to take the disjoint union of the sets representing the types, identifying the copies of _|_. Jonathan Cast wrote: This isn't a coproduct. If we have f

Re: [Haskell-cafe] Re: Is there anyone out there who can translate C# generics into Haskell?

2008-01-06 Thread Jonathan Cast
On 6 Jan 2008, at 2:13 AM, Achim Schneider wrote: Jonathan Cast <[EMAIL PROTECTED]> wrote: On 4 Jan 2008, at 2:00 AM, Nicholls, Mark wrote: You may be right...but learning is not an atomic thingwherever I start I will get strange things happening. The best place to start le

Re: [Haskell-cafe] Wikipedia on first-class object

2008-01-06 Thread Jonathan Cast
On 6 Jan 2008, at 3:02 AM, Derek Elkins wrote: On Fri, 2007-12-28 at 17:54 -0600, Jonathan Cast wrote: Programming languages are generally classified into three groups, imperative, functional, and logical. The difference is in the style of programming encouraged (or mandated, for older

Re: [Haskell-cafe] Basic question concerning the category Hask (was: concerning data constructors)

2008-01-05 Thread Jonathan Cast
On 5 Jan 2008, at 6:03 PM, Yitzchak Gale wrote: Jonathan Cast wrote: The normal view taken by Haskellers is that the denotations of Haskell types are CPPOs. So: (1) Must be monotone (2) Must be continuous (Needn't be strict, even though that messes up the resulting category substant

Re: Re[6]: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell?

2008-01-05 Thread Jonathan Cast
On 4 Jan 2008, at 2:00 AM, Nicholls, Mark wrote: You may be right...but learning is not an atomic thingwherever I start I will get strange things happening. The best place to start learning Haskell is with the simplest type features, not the most complicated. And it's the simplest featu

Re: [Haskell-cafe] Basic question concerning the category Hask (was: concerning data constructors)

2008-01-03 Thread Jonathan Cast
On 3 Jan 2008, at 3:40 AM, Jens Blanck wrote: > The normal view taken by Haskellers is that the denotations of > Haskell types are CPPOs. CPPO? > So: > > (1) Must be monotone > (2) Must be continuous Could you please define what you mean by those terms in this context? > (Needn't be strict,

Re: Re[4]: [Haskell-cafe] Is there anyone out there who can translate C# generics into Haskell?

2008-01-03 Thread Jonathan Cast
On 3 Jan 2008, at 7:40 AM, Nicholls, Mark wrote: I do not necessarily disagree But if I can identify the overlapthen I have leant the overlap...on the cheap. Not really. You still don't have the context which allows you to fit the Haskell features into a complete system. Meanin

Re: [Haskell-cafe] Re: The Worker/Wrapper Transformation

2008-01-03 Thread Jonathan Cast
On 3 Jan 2008, at 4:49 AM, Isaac Dupree wrote: Achim Schneider wrote: Achim Schneider <[EMAIL PROTECTED]> wrote: [...] I'm trying to grok that [] = id ++ = . in the context of Hughes lists. they are also known as "difference lists", and also used at type String in the Prelude as "ShowS",

<    1   2   3   4   5   6   >