Re: [Haskell-cafe] Very Basic IO question

2007-03-03 Thread Lennart Augustsson
Well, C stdio has this nice thing that if you read from stdin then stdout is automagically flushed first (maybe only if both are ttys). I think Haskell should have that too. -- Lennart On Mar 3, 2007, at 07:10 , Bryan O'Sullivan wrote: Joe Olivas wrote: However, changing

Re: [Haskell-cafe] Implementation of Dynamic datatype

2007-03-03 Thread Lennart Augustsson
Why would there be an extra function? The type data Dynamic = forall a . Dynamic TypeRep a is simply a pair. And so is data Dynamic = forall a . (Typeable a) = Dynamic a I think the latter is the most natural representation for Dynamic. -- Lennart On Mar 2, 2007, at 23:55 , Stefan

Re: [Haskell-cafe] Implementation of Dynamic datatype

2007-03-03 Thread Lennart Augustsson
= unsafeCoerce# v | otherwise = def -- Lennart On Mar 3, 2007, at 09:29 , Stefan O'Rear wrote: On Sat, Mar 03, 2007 at 09:18:00AM +, Lennart Augustsson wrote: Why would there be an extra function? The type data Dynamic = forall a . Dynamic TypeRep a is simply a pair. And so

Re: [Haskell-cafe] is there already a function that does this?

2007-03-03 Thread Lennart Augustsson
Those both look roughly like what I would do. -- Lennart On Mar 3, 2007, at 21:35 , Jared Jennings wrote: -- Sort the [a]'s by the [b]'s. sortByKeys :: (Ord b) = [b] - [a] - [a] sortByKeys keys values = map snd $ sortBy compareFst (zip keys values) where compareFst x y = compare

Re: [Haskell-cafe] Non-exported type classes?

2007-03-03 Thread Lennart Augustsson
Yes, as far as I can tell, C would be limited to Z and S. Nice trick! -- Lennart On Mar 4, 2007, at 00:03 , Roberto Zunino wrote: What is the effect of declaring a class in a module and not exporting it? Would that prevent to add more instances to that class other than those already

Re: [Haskell-cafe] Re: Code and Perf. Data for Prime Finders (was: Genuine Eratosthenes sieve)

2007-02-25 Thread Lennart Augustsson
OK. Another weird thing is that much of the Haskell code seems to work with Integer whereas the C code uses int. That doesn't seem fair. -- Lennart On Feb 25, 2007, at 02:40 , Melissa O'Neill wrote: Someone asked if I'd include a classic C version of the Sieve in my comparisons.

Re: [Haskell-cafe] Re: Code and Perf. Data for Prime Finders (was: Genuine Eratosthenes sieve)

2007-02-25 Thread Lennart Augustsson
100 different, and one that gets worse for larger n. Lennart Augustsson wrote: Another weird thing is that much of the Haskell code seems to work with Integer whereas the C code uses int. Originally, I was comparing Haskell with Haskell, and for that purpose I wanted to have a level playing

Re: [Haskell-cafe] How to solve this problem?It's quite easy in PHP.

2007-02-14 Thread Lennart Augustsson
Using printf doesn't need Haskell'. I wrote to require only Haskell98. -- Lennart On Feb 14, 2007, at 11:36 , Neil Mitchell wrote: Hi Eeek, a solution that does monadic maps and require's rank 2 types! arr = [('a',1), ('b',2), ('c',3)] showAll = lines (map showItem arr) showItem

Re: [Haskell-cafe] Implementation of scaled integers

2007-02-13 Thread Lennart Augustsson
The tricky part to get efficient is multiply and divide. Say you pick Int32 as the underlying type, when multiplying you really want the 64 bit result and then scale that. AFAIK, there are no such primitives exposed to the user. What you can do is cast to 64 bit, multiply, shift, and cast back

Re: [Haskell-cafe] Re: Optimization fun

2007-02-12 Thread Lennart Augustsson
Many architectures gives both the quotient and remainder when you use the division instruction, so divMod (quotRem) shouldn't cost more than a div or mod. But if the code generator takes advantage of that is another matter. On Feb 12, 2007, at 02:32 , Matthew Brecknell wrote: I wrote:

Re: [Haskell-cafe] IO is not a monad

2007-02-12 Thread Lennart Augustsson
, with or without seq. I'm a fan of eta, it makes reasoning easier. It also means the compiler can do more transformations. -- Lennart On Feb 12, 2007, at 10:22 , Yitzchak Gale wrote: Lennart Augustsson wrote: I'm not sure what you're asking. The (untyped) lambda calculus is Turing

Re: [Haskell-cafe] Foldr tutorial, Inspired by Getting a Fix from a Fold

2007-02-12 Thread Lennart Augustsson
Sure, but we also have para f e xs = snd $ foldr (\ x ~(xs, y) - (x:xs, f x xs y)) ([], e) xs So I think using para is fine. -- Lennart On Feb 12, 2007, at 18:40 , Bernie Pope wrote: Nicolas Frisby wrote: Guess this is a tricky choice for a foldr intro, since it requires a

Re: [Haskell-cafe] Re: Foldr tutorial, Inspired by Getting a Fix from a Fold

2007-02-12 Thread Lennart Augustsson
I thought solution one was missing the ~ ? On Feb 12, 2007, at 22:07 , [EMAIL PROTECTED] wrote: Bernie Pope wrote: Lennart Augustsson wrote: Sure, but we also have para f e xs = snd $ foldr (\ x ~(xs, y) - (x:xs, f x xs y)) ([], e) xs Nice one. Nice one is an euphemism, it's exactly

Re: [Haskell-cafe] IO is not a monad

2007-02-12 Thread Lennart Augustsson
No, I can't say off hand if seq-hnf would keep eta valid, either. Neither do I know how to implement seq-hnf efficiently. :) As far as eta for other types, yes, I'll take it if I can get it's easily. But I'm also pretty happy with encoding all the other data types within the lambda calculus

Re: [Haskell-cafe] Re: Optimization fun

2007-02-11 Thread Lennart Augustsson
Yes, and that's pretty much what my version does (and what the original tried to do?). On Feb 11, 2007, at 20:14 , DavidA wrote: If you want it fast, don't use a sieve method at all (or a wheel method) - use trial division: primes = 2 : [p | p - [3,5..], trialDivision primes p]

Re: [Haskell-cafe] IO is not a monad

2007-02-10 Thread Lennart Augustsson
I'm not sure what you're asking. The (untyped) lambda calculus is Turing complete. How could seq improve that? On Feb 8, 2007, at 11:18 , Yitzchak Gale wrote: Lennart Augustsson wrote: I think seq is funny because it is not lambda definable. Does the set of computable functions

Re: [Haskell-cafe] Very fast loops. Now!

2007-02-10 Thread Lennart Augustsson
GCC 4.x gets a pass on this test. :) You can do (much) better than that, of course. But it's what I'd expect without going over board. -- Lennart On Feb 10, 2007, at 16:45 , Donald Bruce Stewart wrote: dons: The following C program was described on #haskell #include stdio.h

Re: [Haskell-cafe] Very fast loops. Now!

2007-02-10 Thread Lennart Augustsson
Yes! That's the code I like. On Feb 10, 2007, at 17:46 , Felipe Almeida Lessa wrote: On 2/10/07, Rafael Almeida [EMAIL PROTECTED] wrote: While the haskell program took so long, the C program went really faster than the haskell version: $ gcc -O3 -ffast-math -mfpmath=sse -msse2 -std=c99

Re: [Haskell-cafe] Optimization fun

2007-02-10 Thread Lennart Augustsson
There are many things that makes your code slow. * The default for Haskell is to compute with Integer, not Int. So that makes from Integral and floor very slow. * foldl' is a bad choice, because it is too strict, you want to abort the loop as soon as possible. * your take is really wrong.

Re: [Haskell-cafe] Haskell soltion ofr I/O: is it monads or uniqueness types, after all?

2007-02-10 Thread Lennart Augustsson
Hbc implements the IO type by request/response IO. I.e., the original Haskell I/O system. People who assume IO involves some RealWorld being passed around are just making unwarranted assumptions. The Haskell definition leaves the IO type abstract. -- Lennart On Feb 10, 2007, at 19:16

Re: [Haskell-cafe] Optimization fun

2007-02-10 Thread Lennart Augustsson
Yeah, the 1 first primes takes about 0.1 seconds in Haskell too using the code I posted. On Feb 10, 2007, at 21:49 , Creighton Hogg wrote: On 2/10/07, Peter Berry [EMAIL PROTECTED] wrote: Gah! Gmail has really broken defaults for posting to lists. On 10/02/07, Creighton Hogg [EMAIL

Re: [Haskell-cafe] Re: Optimization fun

2007-02-10 Thread Lennart Augustsson
This is actually a pretty good algorithm. And also a rather subtle one when it comes to termination. :) -- Lennart On Feb 10, 2007, at 22:00 , [EMAIL PROTECTED] wrote: Creighton Hogg wrote: Hello Haskell-ers, So a friend and I were thinking about making code faster in Haskell,

Re: [Haskell-cafe] IO is not a monad

2007-02-07 Thread Lennart Augustsson
I think seq is funny because it is not lambda definable. All other constructs in H98 are (except for ! on data types which is defined in terms of seq). -- Lennart On Feb 8, 2007, at 01:12 , Yitzchak Gale wrote: Haskell is a non-strict language, so non-strict values are legitimate,

Re: [Haskell-cafe] Newbie: generating a truth table

2007-02-06 Thread Lennart Augustsson
It would be better to produce a triple (as was suggested) loop = [(x, y, xy) | x - [True, False], y - [True, False]] The you can map a function that prints over that. Or even better map a function that generates the strings, and the use one big putStr at the end. Always try to separate IO

Re: [Haskell-cafe] List operation question

2007-02-04 Thread Lennart Augustsson
Not much better. You could define shiftl such that is does a single traversal and returns both the last element and all but the last. That will save you one traversal. On Feb 4, 2007, at 18:44 , Eric Olander wrote: Hi, I'm still somewhat new to Haskell, so I'm wondering if there are

Re: [Haskell-cafe] List operation question

2007-02-04 Thread Lennart Augustsson
I agree. If performance is important enough to worry about is shiftl traverses the list once or twice then it's time to switch to a better data type. On Feb 4, 2007, at 19:27 , Yitzchak Gale wrote: Nicolas Frisby wrote: I've always thought that when certain operations are of particular

Re: [Haskell-cafe] How did you stumble on Haskell?

2007-02-03 Thread Lennart Augustsson
On Jan 29, 2007, at 03:01 , Alexy Khrabrov wrote: How do people stumble on Haskell? Well, I didn't really stumble on it. I was at the 1987 meeting when we decided to define Haskell. But I stumbled on functional programming in the first place. I had to learn it because it was part of a

Re: [Haskell-cafe] How did you stumble on Haskell?

2007-02-03 Thread Lennart Augustsson
is this? Is it available for download anywhere? Mike Lennart Augustsson wrote: On Jan 29, 2007, at 03:01 , Alexy Khrabrov wrote: How do people stumble on Haskell? Well, I didn't really stumble on it. I was at the 1987 meeting when we decided to define Haskell. But I stumbled on functional

Re: [Haskell-cafe] Is Excel the most used -- and fucntional -- programming lanuage on Earth?

2007-01-31 Thread Lennart Augustsson
: On 1/30/07, Lennart Augustsson [EMAIL PROTECTED] wrote: Excel is what I like to call a 0:th order functional language, i.e., you can't even define functions, just values. :) Every cell with an expression in Excel is a function. The problem is that the domains and codomains of these functions don't

Re: [Haskell-cafe] Is Excel the most used -- and fucntional -- programming lanuage on Earth?

2007-01-30 Thread Lennart Augustsson
Excel is what I like to call a 0:th order functional language, i.e., you can't even define functions, just values. :) -- Lennart On Jan 30, 2007, at 21:58 , Neil Mitchell wrote: Hi Alexy, Heard that statement recently -- that Excel is a functional programming language, and the most

Re: [Haskell-cafe] State of OOP in Haskell

2007-01-28 Thread Lennart Augustsson
OOHaskell is ingenious, but it's a terrible way to use Haskell. It's very unidiomatic Haskell, and it makes you do things in the same old OO way. Presumably people are using Haskell to do things differently? But as I said, I consider OOHaskell itself a work of genius. :) -- Lennart On

Re: seq does not preclude parametricity (Re: [Haskell-cafe] IO is not a monad)

2007-01-24 Thread Lennart Augustsson
it completely, just enough to ruin the properties used by, e.g., foldr/build. The problem with the current seq can also be seen by the fact that it doesn't work properly with the IO type. -- Lennart On Jan 24, 2007, at 04:11 , Janis Voigtlaender wrote: Lennart Augustsson wrote: I don't think

Re: [Haskell-cafe] basic field questions

2007-01-24 Thread Lennart Augustsson
There is no good solution to your problem. But one way to have both the type A and the type B as you define them is to put them in separate modules and then use qualified names for the `test' function. -- Lennart On Jan 24, 2007, at 06:12 , jamin1001 wrote: Hi, I am new at Haskell

Re: seq does not preclude parametricity (Re: [Haskell-cafe] IO is not a monad)

2007-01-24 Thread Lennart Augustsson
Limiting the value recursion is not enough, of course. You'd have to limit the type recursion as well. -- Lennart On Jan 24, 2007, at 10:41 , Robert Dockins wrote: On Jan 24, 2007, at 8:27 AM, Lennart Augustsson wrote: Well, I think fix destroys parametricity too, and it would

Re: [Haskell-cafe] IO is not a monad

2007-01-23 Thread Lennart Augustsson
Could you explain why would a class Seq not be sufficient? If there were a class Seq, I'd not want functions to be in that class. -- Lennart On Jan 23, 2007, at 08:57 , Yitzchak Gale wrote: I wrote: Prelude let f .! g = ((.) $! f) $! g Prelude let f = undefined :: Int - IO Int

Re: [Haskell-cafe] IO is not a monad

2007-01-23 Thread Lennart Augustsson
there. :) -- Lennart On Jan 23, 2007, at 11:06 , Yitzchak Gale wrote: Hi, Lennart Augustsson wrote: Could you explain why would a class Seq not be sufficient? If there were a class Seq, I'd not want functions to be in that class. Oh, I see. Well that is pretty much the same as ignoring seq

Re: [GHC] #1112: The testsuite setup is broken

2007-01-22 Thread Lennart Augustsson
No, it was not 6.6, it was HEAD. So at a minimum, I think that the summary of a log from the nightly run should be checked in together with the source of the tests. The fact that there are 0 failures for a release is of very little interest. If you are going to do any GHC development you are

Re: [Haskell-cafe] Fractional sqrt

2007-01-19 Thread Lennart Augustsson
If it's arbitrary precision floating point that you want then sqrt should where it already is, as a member of Floating. (I find arbitrary precision real to be an oxymoron, the real numbers are the real numbers, they already have arbitrary precision.) For a real number module, you can use,

Re: [Haskell-cafe] Re: Article review: Category Theory

2007-01-19 Thread Lennart Augustsson
And this is why some of us think that adding polymorphic seq to Haskell was a mistake. :( -- Lennart On Jan 19, 2007, at 08:05 , [EMAIL PROTECTED] wrote: Ulf Norell wrote: In the section on the category laws you say that the identity morphism should satisfy f . idA = idB . f

Re: [Haskell-cafe] Re: Article review: Category Theory

2007-01-19 Thread Lennart Augustsson
a context on anything that uses seq and you can tell that there is some funny business going on. -- Lennart On Jan 19, 2007, at 13:07 , Brian Hulley wrote: Lennart Augustsson wrote: On Jan 19, 2007, at 08:05 , [EMAIL PROTECTED] wrote: Thus, Hask is not a category, at least not as defined

Re: [Haskell-cafe] seq (was: Article review: Category Theory)

2007-01-19 Thread Lennart Augustsson
This solution was used in the first place. But then some people were too lazy to actually use the Eval (as Seq was called) class, so they wanted a polymorphic seq. And so we're in this mess. And it is a mess, e.g., the foldr/build transformation ghc uses to fuse list processing isn't really

Re: [Haskell-cafe] Fractional sqrt

2007-01-18 Thread Lennart Augustsson
I don't see a much better way than using something like Newton- Raphson and testing for some kind of convergence. The Fractional class can contain many things; for instance it contains rational numbers. So your mysqrt function would have to be able to cope with returning arbitrary

Re: [Haskell-cafe] GADTs are expressive

2007-01-08 Thread Lennart Augustsson
So Terminating contains all the terminating terms in the untyped lambda calculus and none of the non-terminating ones. And the type checker checks this. So it sounds to me like the (terminating) type checker solves the halting problem. Can you please explain which part of this I have

Re: [Haskell-cafe] GADTs are expressive

2007-01-08 Thread Lennart Augustsson
at 08:02:36AM -0500, Lennart Augustsson wrote: So it sounds to me like the (terminating) type checker solves the halting problem. Can you please explain which part of this I have misunderstood? Perhaps you, the user, have to encode the proof of halting in the way you construct the term

Re: Re[6]: [Haskell-cafe] Strange type behavior in GHCi 6.4.2

2006-12-31 Thread Lennart Augustsson
Oh, I have other arguments against pragmas. :) But I think the best one is that optimization applied in the wrong place is just poor software engineering. As Michael A. Jackson said: The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts

Re: Re[8]: [Haskell-cafe] Strange type behavior in GHCi 6.4.2

2006-12-31 Thread Lennart Augustsson
What Kirsten said. I think you can be much more productive in optimizing your code if you actually understand what's going on. I usually don't go as far as looking at compiler intermediate code; I usually stick with profiling (or look at assembly code if it's a really performance critical inner

Re: Re[4]: [Haskell-cafe] Strange type behavior in GHCi 6.4.2

2006-12-30 Thread Lennart Augustsson
Maybe it's simpler to add a lot of INLINE, but that can make a program slower as well as faster. It's much better to profile and add them where they are needed. -- Lennart On Dec 30, 2006, at 08:42 , Bulat Ziganshin wrote: Hello Kirsten, Friday, December 29, 2006, 6:30:22 PM, you

Re: [Haskell-cafe] Mo' comprehensions

2006-12-30 Thread Lennart Augustsson
What would the Comprehensible class have? And how would it be different from Monad(Zero)? -- Lennart On Dec 30, 2006, at 10:05 , Diego Navarro wrote: I was solving some programming puzzles today[1], and found myself pining for Map comprehensions. Maybe there should be a

Re: Re[2]: [Haskell-cafe] Strange type behavior in GHCi 6.4.2

2006-12-29 Thread Lennart Augustsson
Before you start adding pragmas, try compiling with -O, it does a lot of the specialization automatically. -- Lennart On Dec 29, 2006, at 15:00 , Grady Lemoine wrote: I've performed some experiments in GHCi, and it looks like even for a simple function (+) (which should be the worst

Re: Stronger static types, was Re: [Haskell-cafe] Re: Versioning

2006-12-22 Thread Lennart Augustsson
Yes, Bluespec has efficient type level naturals. But it only has arithmetic and some trivial decision procedures. The slogan is the type checker knows arithmetic, not algebra. It worked pretty well. But you soon get into situations where you need polymorphic recursion of functions with

Re: [Haskell-cafe] partial functions / failure, Maybe and MonadError and good style

2006-12-22 Thread Lennart Augustsson
I would not advocate using the fail operation in a monad. It doesn't belong there, and hopefully it will go away some day. :) -- Lennart On Dec 23, 2006, at 02:21 , Stefan O'Rear wrote: On Fri, Dec 22, 2006 at 08:05:08PM -0500, Steve Downey wrote: Although terse, the subject

Re: [Haskell-cafe] Re: Versioning

2006-12-21 Thread Lennart Augustsson
On Dec 21, 2006, at 15:53 , Neil Mitchell wrote: Hi there are really no choices for real development. many libraries, language extensions and techniques are for ghc only I develop everything in Hugs, including the Yhc compiler itself. Hugs is great. There are lots of extensions in GHC,

Re: Stronger static types, was Re: [Haskell-cafe] Re: Versioning

2006-12-21 Thread Lennart Augustsson
It's possible to augment Haskell type system to be the one in Epigram. But it would no longer be Haskell. :) And to meet the goals of Epigram you'd also have to remove (unrestricted) recursion from Haskell. -- Lennart On Dec 21, 2006, at 23:46 , Brian Hulley wrote: Jacques

Re: [Haskell-cafe] Re: A suggestion for the next high profile Haskell project

2006-12-18 Thread Lennart Augustsson
I'm allergic to hex constants. Surely, they are not necessary. -- Lennart On Dec 18, 2006, at 18:14 , Chris Kuklewicz wrote: Hi all (and Don!), I have some rewritten versions of readInt below... Bulat Ziganshin wrote: Hello Donald, Monday, December 18, 2006, 3:51:48 AM, you

Re: [Haskell] GHC Error question

2006-12-13 Thread Lennart Augustsson
If the type checker really deduces the type 'forall a b . C a b = a - a' then an inference algorithm that works seems easy. Do type inference for f, then check that the signature the user has given is alpha-convertible with the deduced type (well, in general it's more complicated than

Re: [Haskell] GHC Error question

2006-12-13 Thread Lennart Augustsson
would still not be able to use the signature inferred by GHCi, but it would now be clear why that is the case (and why the signature above does not work). Claus - Original Message - From: Simon Peyton-Jones [EMAIL PROTECTED] To: Lennart Augustsson [EMAIL PROTECTED] Cc: GHC users glasgow

Re: [Haskell] GHC Error question

2006-12-13 Thread Lennart Augustsson
, but (b) it affects only very few programs and ones that are almost certainly ambiguous anyway, and (c) I can't see an easy way to fix it. So my current plan is: let it lie. I'll open a low-priority bug report for it though. Simon | -Original Message- | From: Lennart Augustsson [mailto

Re: [Haskell] Num is such a fat and greedy class

2006-12-11 Thread Lennart Augustsson
On Dec 11, 2006, at 03:50 , Johannes Waldmann wrote: let data Bar = ... in ... If you allow this you need to be very careful about type equality. When is Bar equal to Bar? If it's inside a recursive function, does each invocation get its own Bar? (In SML the answer is yes.) If you

Re: [Haskell] GHC Error question

2006-12-09 Thread Lennart Augustsson
Your two examples are different, the second one is rejected by the type checker, with or without a signature. The first one isn't. Tell me how this make sense: 1. I enter the definition for f. 2. I ask ghc for the type of f and get an answer. 3. I take the answer and tell ghc this is

Re: [Haskell] Num is such a fat and greedy class

2006-12-08 Thread Lennart Augustsson
Oh, come on. It's not that bad. Just start every module with import Prelude() import MyPrelude that's what I do. There's nothing sacred about the Prelude (except a few things used for special syntax). It just happens to be in scope. -- Lennart On Dec 8, 2006, at 15:04 , Dan

Re: [Haskell] GHC Error question

2006-12-07 Thread Lennart Augustsson
And why isn't C a b equivalent to C a b1? forall a b . C a b = a - a and forall a b1 . C a b1 = a - a look alpha convertible to me. Or is the inferred type forall a . C a b1 = a - a Btw, this reminds me again that I'd like to be able to use _ in type signatures. With the meaning of _

Re: Type wildcards, was: Re: [Haskell] GHC Error question

2006-12-07 Thread Lennart Augustsson
altogether (but only a few people advocate this (hello John!)). -- Lennart On Dec 7, 2006, at 07:20 , Johannes Waldmann wrote: Lennart Augustsson wrote: Btw, this reminds me again that I'd like to be able to use _ in type signatures. With the meaning of _ being, there's a type here, but I

Re: Type wildcards, was: Re: [Haskell] GHC Error question

2006-12-07 Thread Lennart Augustsson
I should have said that the situation in H98 is quite bad. There you can't make default instances. On Dec 7, 2006, at 07:49 , Johannes Waldmann wrote: Lennart Augustsson wrote: Speaking of wishlist, I'd also like to see context synonyms, e.g., context C a = (Ord a, Num a) The current

Re: Type wildcards, was: Re: [Haskell] GHC Error question

2006-12-07 Thread Lennart Augustsson
My (off-the-top-of-my-head) suggestion was much more modest. A context synonym would only allow you to shorten contexts, it would not be a new class. On Dec 7, 2006, at 10:53 , J. Garrett Morris wrote: On 12/7/06, Lennart Augustsson [EMAIL PROTECTED] wrote: Speaking of wishlist, I'd also

Re: [Haskell] ANNOUNCE: Visual Haskell prerelease 0.2

2006-11-29 Thread Lennart Augustsson
That's great! Thanks for the hard work, Krasimir. One question, where can I find the source? I didn't see anything about that on the download page. -- Lennart On Nov 28, 2006, at 02:30 , Krasimir Angelov wrote: Hello Haskellers, I am happy to announce that there is a prerelease

Re: Common subexpression elemination (CSE)

2006-11-28 Thread Lennart Augustsson
. -- Lennart On Nov 28, 2006, at 09:50 , Bertram Felgenhauer wrote: Dinko Tenev wrote: On 11/27/06, Lennart Augustsson [EMAIL PROTECTED] wrote: GHC doesn't normally do CSE. CSE can cause space leaks, so you can't do it willy-nilly. I'm sure there are some strict contexts where it could

Re: Common subexpression elemination (CSE)

2006-11-27 Thread Lennart Augustsson
GHC doesn't normally do CSE. CSE can cause space leaks, so you can't do it willy-nilly. I'm sure there are some strict contexts where it could be done safely, but I don't think ghc uses that information (yet). -- Lennart On Nov 27, 2006, at 08:34 , Christian Maeder wrote: the

Re: [Haskell-cafe] strange type mismatch when trying to use takusen

2006-11-24 Thread Lennart Augustsson
It's not a bug. It's what the type of ($) forces. On Nov 24, 2006, at 12:37 , Seth Gordon wrote: Taral wrote: Ah, the dreaded $ with existential types problem. $ is not quite equivalent to application -- the type checker does something funny with forall types. Just take out the $ and you'll

Re: [Haskell-cafe] Re: Debugging partial functions by the rules

2006-11-17 Thread Lennart Augustsson
Exactly! On Nov 17, 2006, at 07:30 , Henning Thielemann wrote: It seems to me like the discussion about static typesafety vs. no or weak typesafety. (Which still exists with respect to several Haskell libraries.) Of course, all type errors can be catched also by a debugger. So was the

Re: [Haskell-cafe] Re: Debugging partial functions by the rules

2006-11-15 Thread Lennart Augustsson
Should Haskell also provide unrestricted side effects, setjmp/ longjmp, missile launching functions, etc? After all, people who don't want to use them can just avoid them. :) On Nov 15, 2006, at 05:07 , Neil Mitchell wrote: Hi Yes, these techniques are fairly well known now, and

Re: String literals

2006-11-13 Thread Lennart Augustsson
To follow up on my own post. I implemented the overloaded strings last night and it seems to work pretty well. I've not done anything about defaulting yet. I don't know how much of a problem this will be in practice. On Nov 10, 2006, at 22:49 , Lennart Augustsson wrote: I think it's

Re: String literals

2006-11-13 Thread Lennart Augustsson
| -Original Message- | From: [EMAIL PROTECTED] [mailto:haskell-prime- [EMAIL PROTECTED] On Behalf Of | Lennart Augustsson | Sent: 11 November 2006 03:49 | To: Haskell Prime | Subject: String literals | | I think it's time that string literals got overloaded just like | numeric literals

[Haskell-cafe] Simple implementations of the lambda calculus

2006-11-12 Thread Lennart Augustsson
Some time ago I made a little experiment and implemented an interpreter for the lambda-calculus in Haskell. The only reason was that I wanted to try different ways of doing it. So I did it using simple substitution (i.e., as the textbooks describe it), unique identifiers, deBruijn

String literals

2006-11-10 Thread Lennart Augustsson
I think it's time that string literals got overloaded just like numeric literals. There are several reasons for this. One reason is the new fast string libraries. They are great, but string literals don't work; you need to pack them first. Another reason is the increasing use of

Re: String literals

2006-11-10 Thread Lennart Augustsson
at 10:49:15PM -0500, Lennart Augustsson wrote: Any thoughts? what about pattern matching? Yes, pattern matching is the issue that occurs to me too. While string literals :: ByteString would be nice (and other magic encoded in string literals, I guess), what is the story for pattern matching

Re: Re[2]: [Haskell-cafe] Fractional/negative fixity?

2006-11-07 Thread Lennart Augustsson
But DEC's language FOCAL had fractional line numbers. :) On Nov 7, 2006, at 06:00 , Henning Thielemann wrote: On Mon, 6 Nov 2006, Bulat Ziganshin wrote: Hello Henning, Monday, November 6, 2006, 1:27:54 PM, you wrote: print msg `on` mode==debug but failed because my code frequently

Re: Fractional/negative fixity?

2006-11-07 Thread Lennart Augustsson
On Nov 7, 2006, at 11:47 , [EMAIL PROTECTED] wrote: Henning Thielemann wrote: On Tue, 7 Nov 2006, Simon Marlow wrote: I'd support fractional and negative fixity. It's a simple change to make, but we also have to adopt http://hackage.haskell.org/cgi-bin/haskell-prime/trac.cgi/wiki/

Re: Re[2]: [Haskell-cafe] Fractional/negative fixity?

2006-11-07 Thread Lennart Augustsson
But DEC's language FOCAL had fractional line numbers. :) On Nov 7, 2006, at 06:00 , Henning Thielemann wrote: On Mon, 6 Nov 2006, Bulat Ziganshin wrote: Hello Henning, Monday, November 6, 2006, 1:27:54 PM, you wrote: print msg `on` mode==debug but failed because my code frequently

[Haskell-cafe] Re: Fractional/negative fixity?

2006-11-07 Thread Lennart Augustsson
On Nov 7, 2006, at 11:47 , [EMAIL PROTECTED] wrote: Henning Thielemann wrote: On Tue, 7 Nov 2006, Simon Marlow wrote: I'd support fractional and negative fixity. It's a simple change to make, but we also have to adopt http://hackage.haskell.org/cgi-bin/haskell-prime/trac.cgi/wiki/

Re: [Haskell-cafe] How to improve speed? (MersenneTwister is several times slower than C version)

2006-11-02 Thread Lennart Augustsson
kello 22:04 -0500, Lennart Augustsson kirjoitti: The whole point of writing the Mersenne Twister was that I wanted to show how a stateful computation could be encapsulated in the ST monad and none of it showing up outside. This aspect of the code is totally gone now when everything is in the IO

Re: [Haskell-cafe] How to improve speed? (MersenneTwister is several times slower than C version)

2006-11-01 Thread Lennart Augustsson
: Hi all, On HaWiki was an announcement of MersenneTwister made by Lennart Augustsson. On a typical run to find out 1000th rnd num the output is (code shown below): $ time ./testMTla Testing Mersenne Twister. Result is [3063349438] real0m4.925s user0m4.856s I was exercising

Re: [Haskell-cafe] How to improve speed? (MersenneTwister is several times slower than C version)

2006-11-01 Thread Lennart Augustsson
it in the IO monad? -- Lennart On Nov 1, 2006, at 20:51 , Lemmih wrote: On 11/1/06, isto [EMAIL PROTECTED] wrote: Hi all, On HaWiki was an announcement of MersenneTwister made by Lennart Augustsson. On a typical run to find out 1000th rnd num the output is (code shown below

Re: Re[2]: [Hugs-users] Record puns, time for removal?

2006-10-31 Thread Lennart Augustsson
If we allow C{..} in patterns we should absolutely have it in expressions too. Both for symmetry and usefulness. -- Lennart On Oct 31, 2006, at 14:06 , Iavor Diatchki wrote: Hello, I think the it may be confusing to novices argument tends to be over-used and we should be careful

Re: Re[2]: [Hugs-users] Record puns, time for removal?

2006-10-30 Thread Lennart Augustsson
Funny that you should mention this idea. I spent last night and this morning implementing it in ghc. But I use '..' instead of '*'. The punning is available both for expressions and patterns. I am of two minds about this extension. It introduces bound variables without mentioning the

Re: [Haskell-cafe] Exact Real Arithmetic

2006-10-22 Thread Lennart Augustsson
Look in http://darcs.augustsson.net/Darcs/, it's in the CReal repository. -- Lennart On Oct 20, 2006, at 06:19 , Henning Thielemann wrote: On http://www.haskell.org/hawiki/ExactRealArithmetic there is a module by David Lester mentioned, with a link to

Re: Two things that i still can't understand in Haskell standard

2006-10-14 Thread Lennart Augustsson
You don't mean checking kind, but checking type. The same argument that can be made for the monomorphism restriction at base type can be used for function types too. There is nothing impossible about prefixpostfix operator. Haskell just happens not to have them. They could be added.

Re: [Haskell] GADT: call for proper terminology

2006-10-11 Thread Lennart Augustsson
On Oct 11, 2006, at 03:58 , Bulat Ziganshin wrote: Hello oleg, Wednesday, October 11, 2006, 6:12:23 AM, you wrote: Annotate the data type using a GADT: data MyData a where MyCon :: MyData a It helps to reduce confusion about the merits of various features and additions to Haskell if we

Re: [Haskell] GADT: call for proper terminology

2006-10-11 Thread Lennart Augustsson
Well, Kent Petersson and I proposed them as an addition to Haskell in 1994, so they are not that new. :) -- Lennart http://web.cecs.pdx.edu/~sheard/papers/silly.pdf On Oct 11, 2006, at 09:47 , Paul Hudak wrote: Lennart Augustsson wrote: Well, I think the GADT type definition

Re: [Haskell-cafe] beginner's problem about lists

2006-10-10 Thread Lennart Augustsson
On Oct 10, 2006, at 08:49 , Matthias Fischmann wrote: On Tue, Oct 10, 2006 at 08:10:44PM +0800, [EMAIL PROTECTED] wrote: To: haskell-cafe@haskell.org From: [EMAIL PROTECTED] Date: Tue, 10 Oct 2006 20:10:44 +0800 Subject: [Haskell-cafe] beginner's problem about lists Hi all, I'm trying to

Re: [Haskell-cafe] Re: Haskell performance (again)!

2006-10-10 Thread Lennart Augustsson
On Oct 10, 2006, at 14:58 , Jón Fairbairn wrote: Bulat Ziganshin [EMAIL PROTECTED] writes: Hello Jon, Tuesday, October 10, 2006, 1:18:52 PM, you wrote: Surely all but one of the comparisons is unnecessary? If you use `compare` instead of (==) and friends, won't one do (I'm assuming that

Re: [Haskell-cafe] Haskell performance (again)!

2006-10-09 Thread Lennart Augustsson
I think your first try looks good. The only thing to worry about would be the + being too lazy. But that's easy to fix at the same time as improving your code in another respect. It's usually good to use real types instead of synonyms, so let's do that. data Nom = Nom Int Int type

Re: [Haskell-cafe] Either as a Monad instance

2006-10-03 Thread Lennart Augustsson
On Oct 3, 2006, at 03:49 , Ross Paterson wrote: On Tue, Oct 03, 2006 at 10:44:49AM +1000, Thomas Conway wrote: I've been [trying to] grapple with the various monads and transformers, and it occurs to me that the standard instance for Either as a monadic type is unnecessarily restrictive. Is

Re: [Haskell-cafe] Either as a Monad instance

2006-10-03 Thread Lennart Augustsson
wrote: On Tue, Oct 03, 2006 at 07:52:54AM -0400, Lennart Augustsson wrote: Yes, having fail in the Monad is a horrible wart. And like some other warts in Haskell it was added to cure the symptom rather than the disease. :( Switching metaphors, what do you see as the disease in this case

Re: [Haskell-cafe] smallest double eps

2006-09-30 Thread Lennart Augustsson
Hang on, hang on, now I'm getting confused. First you asked for the smallest (positive) x such that 1+x /= x which is around x=4.5e15. Then Joachim wondered if you wanted 1+x /= 1 which is around x=2.2e-16. But not you claim to be looking for the smallest positive number that a Double

Re: [Haskell-cafe] smallest double eps

2006-09-29 Thread Lennart Augustsson
Haskell doesn't provide such a value, but you could easily compute it from from the values given in the RealFloat class. It tells you the base, number of digits in mantissa, etc. As for using such an eps in a convergence test I'd be very careful. How do you know that your iteration

Re: [GHC] #801: random list from randomseed ... amd64 differs

2006-09-28 Thread Lennart Augustsson
The library works when Int has at least 32 bits. So 64 should be fine. I guess it should be rewritten with Int32. -- Lennart On Sep 28, 2006, at 08:05 , GHC wrote: #801: random list from randomseed ... amd64 differs ---

Re: [Haskell-cafe] Haskell DLL crashes Excel

2006-09-25 Thread Lennart Augustsson
I don't think GHC is to blame in this case. If you follow all the API (ABI) guidelines for building XLLs things work fine. But there's a lot of things to get right. -- Lennart On Sep 25, 2006, at 05:16 , Simon Peyton-Jones wrote: Andreas, Nikunj, and others I don't have any

Re: Change Data.Bits.rotate to rotate Integer (unbounded) types

2006-09-19 Thread Lennart Augustsson
And what would rotating an Integer mean? The only sensible interpretation I can think of is to make it behave like shift. On Sep 18, 2006, at 23:46 , Peter Tanski wrote: Welcome back! Since Data.Bits is not defined in the Haskell 1998 standard, are we free to change the implementation of

Re: [Haskell-cafe] Re: Problems interpreting

2006-09-18 Thread Lennart Augustsson
Or even shorter: subst e l = concatMap $ \x-if x==e then l else [x] I kinda like the list comprehension version too subst e l1 l2 = [ r | x - l2, r - if x==e then l1 else [x] ] On Sep 18, 2006, at 10:54 , Jón Fairbairn wrote: Andrea Rossato [EMAIL PROTECTED] writes: On Mon, Sep 18, 2006

Re: [Haskell] How to define Y combinator in Haskell

2006-09-15 Thread Lennart Augustsson
Well, you can do it with the existing recursion in Haskell let yc f = f (yc f) Or you can encode it with type level recursion and no value recursion by using a recursive data type. -- Lennart On Sep 15, 2006, at 08:11 , Haihua Lin wrote: Hi, Writing yc = \f - (\x - f(x

<    1   2   3   4   5   6   7   8   9   10   >