Re: [Haskell-cafe] instance Enum Double considered not entirely great?

2011-09-26 Thread Lennart Augustsson
If you do [0.1, 0.2 .. 0.3] it should leave out 0.3. This is floating point numbers and if you don't understand them, then don't use them. The current behaviour of .. for floating point is totally broken, IMO. -- Lennart On Fri, Sep 23, 2011 at 6:06 AM, Chris Smith cdsm...@gmail.com wrote:

Re: [Haskell-cafe] instance Enum Double considered not entirely great?

2011-09-26 Thread Lennart Augustsson
I totally agree with you. Haskell is very broken when it comes to [x..y] for floating point. It's an attempt to make it more friendly for naive users, but there is no way FP can be made friendly. Any such attempts will fail, so make it usable for people who understand FP instead. -- Lennart

Re: [Haskell-cafe] mapM is supralinear?

2011-09-26 Thread Lennart Augustsson
You seem to ignore garbage collection. On Sat, Sep 24, 2011 at 6:40 AM, Arseniy Alekseyev arseniy.alekse...@gmail.com wrote: Apparently it doesn't, and it seems to be fixed now. Does anyone know what exactly the bug was? Because this seems like a serious bug to me. I've run into it myself

Re: [Haskell-cafe] Is SHE (the Strathclyde Haskell Enhancement) portable?

2011-01-23 Thread Lennart Augustsson
It probably is portable, but I'd think only GHC has all the necessary extensions. On Sun, Jan 23, 2011 at 12:27 PM, Maciej Piechotka uzytkown...@gmail.comwrote: It may be strange question but: - Is SHE portable (assuming that the compiler have the extensions)? - If yes why there is only

Re: [Haskell-cafe] Set monad

2011-01-09 Thread Lennart Augustsson
That looks like it looses the efficiency of the underlying representation. On Sun, Jan 9, 2011 at 6:45 AM, Sebastian Fischer fisc...@nii.ac.jp wrote: On Sun, Jan 9, 2011 at 6:53 AM, Lennart Augustsson lenn...@augustsson.net wrote: It so happens that you can make a set data type

Re: [Haskell-cafe] Set monad

2011-01-08 Thread Lennart Augustsson
It so happens that you can make a set data type that is a Monad, but it's not exactly the best possible sets. module SetMonad where newtype Set a = Set { unSet :: [a] } singleton :: a - Set a singleton x = Set [x] unions :: [Set a] - Set a unions ss = Set $ concatMap unSet ss member :: (Eq a)

Re: [Haskell-cafe] Incorrectly inferring type [t]

2010-12-29 Thread Lennart Augustsson
First, what type would such a function have? Certainly not [a]-[b], because that type say that it can take a list of any type and turn it into a list of any other type, e.g., [Int]-[Bool]. On Thu, Dec 30, 2010 at 4:05 AM, william murphy will.t.mur...@gmail.comwrote: Hi All, I've spent a lot

Re: [Haskell-cafe] how to write a loop in haskell way

2010-12-19 Thread Lennart Augustsson
Recursion replaces loops. If it needs to be monadic or not depends on what you want to do. On Sun, Dec 19, 2010 at 10:53 AM, ender crazyen...@gmail.com wrote: 2010/12/19 Henning Thielemann lemm...@henning-thielemann.de: On Sun, 19 Dec 2010, ender wrote: do alloca $ \value - do

Re: [Haskell-cafe] [URGENT] DNS problems at haskell.org?

2010-12-18 Thread Lennart Augustsson
I bet they did try to contact the owner. But when the contact email no longer works nobody will get the messages. On Sat, Dec 18, 2010 at 3:35 PM, Ketil Malde ke...@malde.org wrote: Karel Gardas karel.gar...@centrum.cz writes:

Re: [Haskell-cafe] [Haskell] Functor = Applicative = Monad

2010-12-16 Thread Lennart Augustsson
IO On Thu, Dec 16, 2010 at 6:03 PM, John Smith volderm...@hotmail.com wrote: On 15/12/2010 14:31, Lennart Augustsson wrote: Yes, I think there should be a MonadFail distinct from MonadPlus. Some types, like IO, are not in MonadPlus, but have a special implementation of the fail method

Re: [Haskell-cafe] [Haskell] Functor = Applicative = Monad

2010-12-15 Thread Lennart Augustsson
Any refutable pattern match in do would force MonadFail (or MonadPlus if you prefer). So 1. (MonadFail m) = a - m a, \ a - return a 2. (MonadFail m) = m a, mfail ... 3. (MonadFail m) = Maybe a - m a, \ a - case a of Nothing - mfail ...; Just x - return x 4. (Monad m) = a - b - m a, \

Re: [Haskell-cafe] [Haskell] Functor = Applicative = Monad

2010-12-15 Thread Lennart Augustsson
reasons (better error messages was the excuse). -- Lennart On Wed, Dec 15, 2010 at 11:51 AM, John Smith volderm...@hotmail.com wrote: On 15/12/2010 11:39, Lennart Augustsson wrote: Any refutable pattern match in do would force MonadFail (or MonadPlus if you prefer). So 1. (MonadFail m

Re: [Haskell-cafe] Re: Haskell is a scripting language inspired by Python.

2010-11-04 Thread Lennart Augustsson
KRC, Miranda, and LML all predate Haskell and have list comprehensions. On Thu, Nov 4, 2010 at 3:16 PM, Jonathan Geddes geddes.jonat...@gmail.com wrote: Regardless of which languages got which features for which other languages, Haskell is surely NOT a scripting language inspired by python...

Re: [Haskell-cafe] Re: Haskell is a scripting language inspired by Python.

2010-11-04 Thread Lennart Augustsson
It happened at various universities around the world. Look at the original Haskell committee and you'll get a good idea where. The smallest Haskell I know of is Gofer/Hugs; it originally ran on a 640k PCs. Before that languages like SASL and KRC ran on PDP-11 with 64k memory. None of these had a

Re: [Haskell-cafe] What is simplest extension language to implement?

2010-11-02 Thread Lennart Augustsson
I don't understand. Why don't you use Haskell as the scripting language? On Tue, Nov 2, 2010 at 7:04 AM, Permjacov Evgeniy permea...@gmail.com wrote: Let us think, that we need some scripting language for our pure haskell project and configure-compile-run is not a way. In such a case a

Re: [Haskell-cafe] Re: Mysterious fact

2010-11-02 Thread Lennart Augustsson
Jon, you beat me to it. I was going to mention Ponder. But Ponder did have a builtin type, it had the function type built in. :) -- Lennart On Tue, Nov 2, 2010 at 9:47 PM, Jon Fairbairn jon.fairba...@cl.cam.ac.uk wrote: Andrew Coppin andrewcop...@btinternet.com writes: The other day, I

Re: [Haskell-cafe] who's in charge?

2010-10-28 Thread Lennart Augustsson
It's working just fine. I've never wanted a mail client library. :) -- Lennart 2010/10/27 Günther Schmidt gue.schm...@web.de: Dear Malcolm, since there is no mail client library even after 10+ years I suggest to rethink the approach, because frankly, it's not working. Günther

Re: [Haskell-cafe] Re-order type

2010-10-10 Thread Lennart Augustsson
You can use Djinn to generate the glue. Note that in the example you give there are many possible ways to make the glue just looking at the types. Changing the output types of f so they can't be confused with the input types we get: Djinn ? compose :: (c1 - a1 - d) - (a- b - c - (b1,c1,a1)) - (a

Re: [Haskell-cafe] Static computation/inlining

2010-10-10 Thread Lennart Augustsson
I would not worry about doing that at runtime. The only reliable way to make sure it happens at compile time that I can think of would be some Template Haskell. (Or some really deep magic with dictionaries.) -- Lennart On Mon, Oct 11, 2010 at 3:51 AM, Alexander Solla a...@2piix.com wrote: Hi

Re: [Haskell-cafe] Desired behaviour of rounding etc.

2010-10-08 Thread Lennart Augustsson
That code is incorrect. You can't assume that the base for floating point numbers is 2, that's something you have to check. (POWER6 and z9 has hardware support for base 10 floating point.) -- Lennart On Fri, Oct 8, 2010 at 2:08 PM, Daniel Fischer daniel.is.fisc...@web.de wrote: The methods

Re: [Haskell-cafe] Re: A GHC error message puzzle

2010-08-13 Thread Lennart Augustsson
So it's a bug in the garbage collector. It's closing a handle that clearly is still reachable, otherwise this would not have happened. On Fri, Aug 13, 2010 at 10:53 AM, Simon Marlow marlo...@gmail.com wrote: On 12/08/2010 21:59, Yitzchak Gale wrote: Wei Hu wrote: nonTermination _ =

Re: [Haskell-cafe] Re: Haskell in Industry

2010-08-10 Thread Lennart Augustsson
Rather than high turnover it indicates (in my experience) that it's difficult to fill positions in finance. That's one reason they are advertised repeatedly. On Tue, Aug 10, 2010 at 12:27 PM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: Malcolm Wallace malcolm.wall...@me.com writes:

Re: [Haskell-cafe] Re: Haskell in Industry

2010-08-10 Thread Lennart Augustsson
The former. On Tue, Aug 10, 2010 at 2:59 PM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: Lennart Augustsson lenn...@augustsson.net writes: Rather than high turnover it indicates (in my experience) that it's difficult to fill positions in finance. That's one reason

Re: [Haskell-cafe] Re: Haskell in Industry

2010-08-09 Thread Lennart Augustsson
Out of 10 people trained only 2 should do programming anyway. :) On Fri, Aug 6, 2010 at 4:58 AM, Tom Hawkins tomahawk...@gmail.com wrote: Hi Eil, Have you had any trouble training people to use Haskell? Yes.  I find that out of 10 people I train, only about 2 pick it up and run with it.  I'm

Re: [Haskell-cafe] Re: Haskell in Industry

2010-08-09 Thread Lennart Augustsson
But do you think there would be more Haskell jobs offered (in absolute terms), if no investment firms offered jobs? Is there some kind of quota of job offers that gets used up? There seems to be more job applicants that job offers at the moment, so I'm not sure what the problem is. On Mon, Aug

Re: [Haskell-cafe] Why is toRational a method of Real?

2010-08-05 Thread Lennart Augustsson
Yes, for instance to be able to use functions as number. Or to be able to use constructive real numbers as numbers, since equality is not computable. -- Lennart On Thu, Aug 5, 2010 at 4:17 AM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: On 5 August 2010 10:15, Lennart Augustsson

Re: [Haskell-cafe] Why is toRational a method of Real?

2010-08-04 Thread Lennart Augustsson
You're right. It's bad to have toRational in Real. It's also bad to have Show and Eq as superclasses to Num. On Wed, Aug 4, 2010 at 8:30 PM, Omari Norman om...@smileystation.com wrote: Why is toRational a method of Real? I thought that real numbers need not be rational, such as the square

Re: [Haskell-cafe] Re: Instances for Set of Functor, Traversable?

2010-07-27 Thread Lennart Augustsson
, www.cs.kuleuven.be/~toms/Research/papers/constraint_families.pdf On Tue, Jul 27, 2010 at 10:17 AM, o...@okmij.org wrote: Lennart Augustsson wrote: Try to make Set an instance of Functor and you'll see why it isn't. It's very annoying. And yet the very simple, and old solution works.        http

Re: [Haskell-cafe] Instances for Set of Functor, Traversable?

2010-07-26 Thread Lennart Augustsson
Try to make Set an instance of Functor and you'll see why it isn't. It's very annoying. On Mon, Jul 26, 2010 at 11:55 PM, Gregory Crosswhite gcr...@phys.washington.edu wrote: Is there a specific reason why Set doesn't have instances for Functor and Traversable?  Or have they just not been

Re: [Haskell-cafe] Using the ContT monads for early exits of IO ?

2010-06-10 Thread Lennart Augustsson
I would not use the continuation monad just for early exit. Sounds like the error monad to me. 2010/6/10 Günther Schmidt gue.schm...@web.de: Hi everyone, I'm about to write a rather lengthy piece of IO code. Depending on the results of some of the IO actions I'd like the computation to stop

Re: [Haskell-cafe] currying combinators

2010-05-28 Thread Lennart Augustsson
just consider cut free proofs there's usually infinitely many.) On Fri, May 28, 2010 at 8:14 AM, wren ng thornton w...@freegeek.org wrote: Lennart Augustsson wrote: So what would you consider a proof that there are no total Haskell functions of that type? Or, using Curry-Howard, a proof

Re: [Haskell-cafe] currying combinators

2010-05-27 Thread Lennart Augustsson
So what would you consider a proof that there are no total Haskell functions of that type? Or, using Curry-Howard, a proof that the corresponding logical formula is unprovable in intuitionistic logic? As I understand, in general this can only be proven using meta theory rather than the logic

Re: [Haskell-cafe] currying combinators

2010-05-26 Thread Lennart Augustsson
There are no interesting (i.e. total) functions of that type. 2010/5/25 Yitzchak Gale g...@sefer.org: Günther Schmidt wrote: http://www.hpaste.org/fastcgi/hpaste.fcgi/view?id=25694 in which I attempt to develop a currying combinator library. I'm stuck at some point and would appreciate any

Re: [Haskell-cafe] Re: Proof question -- (==) over Bool

2010-05-24 Thread Lennart Augustsson
That's totally false. You don't evaluate 'undefined' before calling 'id'. (Or if you, it's because you've made a transformation that is valid because 'id' is strict.) On Mon, May 24, 2010 at 9:05 AM, Alexander Solla a...@2piix.com wrote: Yes, but only because it doesn't work at all.  Consider

Re: [Haskell-cafe] Re: Proof question -- (==) over Bool

2010-05-23 Thread Lennart Augustsson
For Bool, I'm not sure, but for, e.g., () it's certainly true. Take this definition of == () == _ = True Using case analysis of just the constructors, ignoring the value bottom, you can easily prove symmetry. But '() == undefined' terminates, whereas 'undefined == ()' does not. Ignore bottom

Re: [Haskell-cafe] Clean proof?

2010-05-23 Thread Lennart Augustsson
There is no clean proof of that statement because it is false. (Consider the argument 'undefined'.) 2010/5/23 R J rj248...@hotmail.com: Given the following definition of either, from the prelude:     either                      :: (a - c, b - c) - Either a b - c     either (f, g) (Left x)      

Re: [Haskell-cafe] Clean proof -- correction

2010-05-23 Thread Lennart Augustsson
Actually, I didn't notice the typo. It's still not a true statement. (h . either (f, g)) undefined /= (either (h . f, h . g)) undefined Also, it's not exactly the function either from the Prelude. -- Lennart 2010/5/23 R J rj248...@hotmail.com: Correction:  the theorem is     h . either

Re: [Haskell-cafe] ShowList magic

2010-05-17 Thread Lennart Augustsson
Your question is actually deeper than some of the people answering you seem to realize. How does ghci decide what to do when you say show [] ? The expression [] has type [a], which means it could be a list of any type 'a', including Char. Normally, when Haskell can't determine the type in this

Re: [Haskell-cafe] Integers v ints

2010-04-03 Thread Lennart Augustsson
The cost factor of Integer vs Int is far, far smaller than the factor between computable reals vs Double. On Thu, Apr 1, 2010 at 6:33 PM, Jens Blanck jens.bla...@gmail.com wrote: Yes, the cost for computable reals will be an order of magnitude or possibly two for well-behaved computations. For

Re: [Haskell-cafe] Re: ANN: data-category, restricted categories

2010-03-30 Thread Lennart Augustsson
Of course Haskell' should have an empty case. As soon as empty data declarations are allowed then empty case must be allowed just by using common sense. On Tue, Mar 30, 2010 at 11:03 PM, Ashley Yakeley ash...@semantic.org wrote: wagne...@seas.upenn.edu wrote: I believe I was claiming that, in

Re: [Haskell-cafe] Where are the haskell elders?

2010-03-29 Thread Lennart Augustsson
What Don said. 2010/3/29 Don Stewart d...@galois.com: gue.schmidt: Hi all, I notice that posts from the Haskell elders are pretty rare now. Only every now and then we hear from them. How come? Because there is too much noise on this list, Günther -- Don

Re: [Haskell-cafe] GHC vs GCC vs JHC

2010-03-28 Thread Lennart Augustsson
Does anything change if you swap the first two rhss? On Sun, Mar 28, 2010 at 1:28 AM, Roman Leshchinskiy r...@cse.unsw.edu.au wrote: On 28/03/2010, at 09:47, Lennart Augustsson wrote: It's important to switch from mod to rem.  This can be done by a simple abstract interpretation. Also

Re: [Haskell-cafe] GHC vs GCC vs JHC

2010-03-27 Thread Lennart Augustsson
It's important to switch from mod to rem. This can be done by a simple abstract interpretation. I'm nore sure if it's jhc or gcc that does this for jhc. -- Lennart On Sat, Mar 27, 2010 at 10:30 PM, Rafael Cunha de Almeida almeida...@gmail.com wrote: John Meacham wrote: Here are jhc's

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-22 Thread Lennart Augustsson
Turn on OverloadedStrings and you can pattern match on any type you like that is in the IsString class. Which means that Data.Text can use string literals just like regular strings (but you can't use Char literals in the match). On Mon, Mar 22, 2010 at 1:15 PM, Ivan Miljenovic

Re: [Haskell-cafe] Proper round-trip HughesPJ/Parsec for Doubles?

2010-02-23 Thread Lennart Augustsson
If you use read (reads) and show for the actual conversion it will round trip. It appears to be non-trivial since most languages and libraries get it wrong. :) -- Lennart On Tue, Feb 23, 2010 at 1:44 PM, Andy Gimblett hask...@gimbo.org.uk wrote: Hi all, Short version: How can I pretty print

Re: [Haskell-cafe] GHC RTS question

2010-02-21 Thread Lennart Augustsson
Supply a fix for the problem, and it will probably get included. There has probably been little demand for this feature so far. -- Lennart On Sun, Feb 21, 2010 at 10:21 PM, Ben Millwood hask...@benmachine.co.uk wrote: On Sun, Feb 21, 2010 at 7:10 PM, Max Bolingbroke

Re: [Haskell-cafe] haskell-src type inference algorithm?

2010-02-12 Thread Lennart Augustsson
Well, something like such a tool exists, but I can't give it away. On Fri, Feb 12, 2010 at 12:13 AM, Niklas Broberg niklas.brob...@gmail.com wrote: Anyone know of a type inference utility that can run right on haskell-src types? or one that could be easily adapted? This is very high on my

Re: [Haskell-cafe] haskell-src type inference algorithm?

2010-02-11 Thread Lennart Augustsson
To do anything interesting you also to process modules, something which I hope to contribute soon to haskell-src-exts. On Thu, Feb 11, 2010 at 6:35 PM, Job Vranish job.vran...@gmail.com wrote: Anyone know of a type inference utility that can run right on haskell-src types? or one that could be

Re: [Haskell-cafe] haskell-src type inference algorithm?

2010-02-11 Thread Lennart Augustsson
It does type inference, it's just not engineered to be part of a real compiler. On Thu, Feb 11, 2010 at 6:41 PM, Stephen Tetley stephen.tet...@gmail.com wrote: http://web.cecs.pdx.edu/~mpj/thih/ Looks like its a type _checker_ though... On 11 February 2010 17:39, Stephen Tetley

Re: [Haskell-cafe] Re: could we get a Data instance for Data.Text.Text?

2010-01-23 Thread Lennart Augustsson
The only safe rule is: if you don't control the class, C, or you don't control the type constructor, T, don't make instance C T. I agree in principle, but in the real world you can't live by this rule. Example, I want to use Uniplate to traverse the tree built by haskell-src-exts, Using

Re: [Haskell-cafe] Language simplicity

2010-01-16 Thread Lennart Augustsson
PL/I has keywords, they're just not reserved words. With as many keywords as PL/I has, there something to say for not making them reserved. :) On Wed, Jan 13, 2010 at 11:50 AM, Brandon S. Allbery KF8NH allb...@ece.cmu.edu wrote: On Jan 13, 2010, at 05:45 , Ketil Malde wrote: Brandon S. Allbery

Re: [Haskell-cafe] How to get a list of constructors for a type?

2009-12-30 Thread Lennart Augustsson
I've put some of Oleg's code on hackage, named polytypeable. import Data.PolyTypeable main = print [polyTypeOf Nothing, polyTypeOf Just] This prints [Maybe a1,a1 - Maybe a1] To get a list of the actual constructors you need to derive Data.Data.Data and use that. -- Lennart On Wed, Dec

Re: [Haskell-cafe] ANNOUNCE: repr-0.3.2

2009-12-24 Thread Lennart Augustsson
Did you consider using the traced package? 2009/12/24 Bas van Dijk v.dijk@gmail.com: On Thu, Dec 24, 2009 at 1:00 AM, Andrey Sisoyev andrejs.sisoj...@nextmail.ru wrote: Where do you make use of it? :) A few months ago I was working on 'levmar'[1] a Levenberg-Marquardt data fitting

Re: [Haskell-cafe] Zumkeller numbers

2009-12-08 Thread Lennart Augustsson
And if you use quotRem it's faster (unless you're running on some exotic hardware like NS32K). On Tue, Dec 8, 2009 at 10:19 PM, Richard O'Keefe o...@cs.otago.ac.nz wrote: On Dec 9, 2009, at 1:15 AM, Daniel Fischer wrote: Am Dienstag 08 Dezember 2009 08:44:52 schrieb Ketil Malde: Richard

Re: [Haskell-cafe] Optimization with Strings ?

2009-12-03 Thread Lennart Augustsson
Thank you Sir for giving me a good laugh! On Thu, Dec 3, 2009 at 5:25 PM, John D. Earle johndea...@cox.net wrote: Dear Emmanuel Chantréau, You may want to look into Objective CAML http://caml.inria.fr/ which is a French product as you can see from the Internet address. It is likely better

Re: [Haskell-cafe] Coercing numeric and string constants

2009-11-16 Thread Lennart Augustsson
Try with -XExtendedDefaulingRules. On Mon, Nov 16, 2009 at 6:33 AM, Mark Lentczner ma...@glyphic.com wrote: I'm looking for a good way to handle a library interface that accepts both strings and numbers in particular argument positions: Start with the following definitions. I've defined

Re: [Haskell-cafe] Little errors in number calculations

2009-11-15 Thread Lennart Augustsson
Hugs is wrong, as you can easily see by evaluating let x = 123.35503 * 10.0 in x == read (show x) With ghc it comes out as True and with Hugs as False. -- Lennart On Sat, Nov 14, 2009 at 9:00 PM, Abby Henríquez Tejera parad...@gmail.com wrote: Hi. I've seen that in GHC sometimes there

Re: [Haskell-cafe] What does the `forall` mean ?

2009-11-14 Thread Lennart Augustsson
Of the two declarations data Fizzle a = Fizzle (b - (a, b)) a data Fizzle a = forall b. Fizzle (b - (a, b)) a only the second one is allowed (with some suitable extension). Personally I think the first one should be allowed as well, with the same meaning as the second one. Some

Re: [Haskell-cafe] Opinion about JHC

2009-11-13 Thread Lennart Augustsson
Thanks Neil, That was indeed my point. Since a compiler is a substantial program I would have more confidence it a compiler that is self-hosting. Surely you must have tried? -- Lennart On Fri, Nov 13, 2009 at 8:08 PM, Neil Mitchell ndmitch...@gmail.com wrote: Hi John, Do you use jhc when

Re: [Haskell-cafe] Opinion about JHC

2009-11-11 Thread Lennart Augustsson
John, Do you use jhc when you develop jhc? I.e., does it compile itself. For me, this is the litmus test of when a compiler has become usable. I mean, if even the developers of a compiler don't use it themselves, why should anyone else? :) -- Lennart On Wed, Nov 11, 2009 at 3:37 AM, John

Re: [Haskell-cafe] Opinion about JHC

2009-11-11 Thread Lennart Augustsson
If by minority platform you mean platforms that are resource starved, like some embedded systems, then I would have to agree. -- Lennart On Wed, Nov 11, 2009 at 2:12 PM, Donn Cave d...@avvanta.com wrote: Quoth Lennart Augustsson lenn...@augustsson.net, Do you use jhc when you develop jhc

Re: [Haskell-cafe] pretty printing with comments

2009-10-20 Thread Lennart Augustsson
It's not an easy problem to pretty print (i.e. change indentation) and preserve the comments. And always get it right. On Tue, Oct 20, 2009 at 1:28 PM, Pasqualino Titto Assini tittoass...@gmail.com wrote: Thanks Niklas, in fact this produced a source with comments: import

Re: [Haskell-cafe] Exponential complexity of type checking (Was: Type-level naturals multiplication)

2009-10-13 Thread Lennart Augustsson
Yes, there are simple H-M examples that are exponential. x0 = undefined x1 = (x1,x1) x2 = (x2,x2) x3 = (x3,x3) ... xn will have a type with 2^n type variables so it has size 2^n. -- Lennart On Tue, Oct 13, 2009 at 6:04 PM, Brad Larsen brad.lar...@gmail.com wrote: On Tue, Oct 13, 2009 at 3:37

Re: [Haskell-cafe] type inference question

2009-10-08 Thread Lennart Augustsson
The reason a gets a single type is the monomorphism restriction (read the report). Using NoMonomorphismRestriction your example with a works fine. On Thu, Oct 8, 2009 at 12:29 PM, Cristiano Paris fr...@theshire.org wrote: On Thu, Oct 8, 2009 at 11:04 AM, minh thu not...@gmail.com wrote: Hi,

Re: Re[2]: [Haskell-cafe] type inference question

2009-10-08 Thread Lennart Augustsson
Indeed, the types foo :: forall a . (Num a) = a - (Int, Float) and foo :: (forall a . (Num a) = a) - (Int, Float) are quite different. The first one say, I (foo) can handle any kind of numeric 'a' you (the caller) can pick. You (the caller) get to choose exactly what type you give me. The

Re: [Haskell-cafe] Num instances for 2-dimensional types

2009-10-05 Thread Lennart Augustsson
And what is a number? Are complex numbers numbers? On Mon, Oct 5, 2009 at 3:12 PM, Miguel Mitrofanov miguelim...@yandex.ru wrote: Sönke Hahn wrote: I used to implement    fromInteger n = (r, r) where r = fromInteger n , but thinking about it,    fromInteger n = (fromInteger n, 0)

Re: [Haskell-cafe] Num instances for 2-dimensional types

2009-10-05 Thread Lennart Augustsson
But complex numbers are just pairs of numbers. So pairs of numbers can obviously be numbers then. On Mon, Oct 5, 2009 at 4:40 PM, Miguel Mitrofanov miguelim...@yandex.ru wrote: Lennart Augustsson wrote: And what is a number? Can't say. You know, it's kinda funny to ask a biologist what

Re: [Haskell-cafe] Num instances for 2-dimensional types

2009-10-05 Thread Lennart Augustsson
Everyone agrees that the Haskell numeric hierarchy is flawed, but I've yet to see a good replacement. On Mon, Oct 5, 2009 at 4:51 PM, Brad Larsen brad.lar...@gmail.com wrote: On Mon, Oct 5, 2009 at 10:36 AM, Miguel Mitrofanov miguelim...@yandex.ru wrote: [...] Of course, it's OK to call

Re: [Haskell-cafe] Num instances for 2-dimensional types

2009-10-05 Thread Lennart Augustsson
: a) admit that complex numbers and double numbers are the same - and most mathematicians would agree they aren't - or b) admit that the relation be the same is not transitive - which is simply bizarre. Lennart Augustsson wrote: But complex numbers are just pairs of numbers.  So pairs of numbers

Re: [Haskell-cafe] What is a number. (Was: Num instances for 2-dimensional types)

2009-10-05 Thread Lennart Augustsson
OK, just pairs have no arithmetic, but one way of defining arithmetic is to treat the pairs as complex numbers. Or as mantissa and exponent. Or as something else. So there's nothing wrong, IMO, to make pairs an instance of Num if you so desire. (Though I'd probably introduce a new type.) On

Re: [Haskell-cafe] Re: Is logBase right?

2009-08-27 Thread Lennart Augustsson
Prelude toRational 697.04157958259998 3065621287177675 % 4398046511104 Prelude toRational 697.0415795826 3065621287177675 % 4398046511104 As you can see, both numbers are represented by the same Double. Haskell prints a Double with the simplest number that converts back to the same bit pattern.

Re: [Haskell-cafe] Re: Is logBase right?

2009-08-25 Thread Lennart Augustsson
be a small penalty. -- Lennart On Tue, Aug 25, 2009 at 3:20 PM, Henning Thielemannlemm...@henning-thielemann.de wrote: On Sun, 23 Aug 2009, Lennart Augustsson wrote: You're absolutely right.  It would be easy to change logBase to have special cases for, say, base 2 and base 10, and call the C

Re: [Haskell-cafe] Re: Is logBase right?

2009-08-23 Thread Lennart Augustsson
You're absolutely right. It would be easy to change logBase to have special cases for, say, base 2 and base 10, and call the C library functions for those. In fact, I think it's a worth while change, since it's easy and get's better results for some cases. -- Lennart On Sun, Aug 23, 2009 at

Re: [Haskell-cafe] Unifcation and matching in Abelian groups

2009-08-22 Thread Lennart Augustsson
Even if you are only slightly irritated by offset syntax, why are you using it? {;} works fine. On Sat, Aug 22, 2009 at 3:51 AM, John D. Ramsdellramsde...@gmail.com wrote: Let me put all my cards on the table.  You see, I really am only slightly irrigated by offset syntax.  In contrast, I am a

Re: [Haskell-cafe] Re: Where do I put the seq?

2009-08-21 Thread Lennart Augustsson
Internally GHC does have to enforce the ordering on IO operations somehow. If there actually was a RealWorld value being passed around you could use some version of seq the guarantees sequential evaluation. But GHC doesn't even pass a RealWorld around, the sequencing is enforced by different

Re: Re[2]: [Haskell-cafe] Re: Where do I put the seq?

2009-08-21 Thread Lennart Augustsson
You need a lot of magic to make the IO monad efficient. You don't really want to pass around (and pattern match on) a RealWorld token, that would be inefficient. On Fri, Aug 21, 2009 at 11:04 AM, Peter Verswyvelenbugf...@gmail.com wrote: IO also seems to use unboxed (hence strict?) tuples

Re: Re[2]: [Haskell-cafe] Re: Where do I put the seq?

2009-08-21 Thread Lennart Augustsson
The IO in hbc was (is) the old request-response model, on top of which there was also a continuation layer, as well as the monadic IO (once that was invented). It involved a lot more C code handling the requests than I really liked. BTW, unsafePerformIO is pretty ugly to implement in the

Re: [Haskell-cafe] Re: Where do I put the seq?

2009-08-20 Thread Lennart Augustsson
Using seq to control a program's semantics (as in, input-output behaviour) is a horrible hack. The seq operation there to control space and time aspects of your program. (The specification of seq doesn't even say that the first argument is evaluated before the second one.) You should use data

Re: [Haskell-cafe] unsafeDestructiveAssign?

2009-08-11 Thread Lennart Augustsson
No, there's no way you can change the value of 'a' after the fact. Since 'a' is a constant the compiler has most likely inlined it wherever it has been used, the done constant folding etc. If you need an updateable variable, you need to tell the compiler, otherwise it will assume your code is

Re: [Haskell-cafe] generalize RecordPuns and RecordWildCards to work with qualified names?

2009-08-09 Thread Lennart Augustsson
At a minimum I think the error message should be better. I also think it would be natural to use the DisambiguateRecordFields for the places where RecordWildcards are used. I mean, if I change from unqualified import to a qualified one, and then change all visible names to be qualified I would

Re: [Haskell-cafe] Complex numbers and (**)

2009-08-08 Thread Lennart Augustsson
A2: Yes, this seem unfortunate, so perhaps a different definition for Complex is warranted. Or maybe the default implementation for (**) should be changed so that 0**x is 0, except if x is 0 (in which case I think it should be undefined). -- Lennart On Sat, Aug 8, 2009 at 2:55 PM, Paul

Re: [Haskell-cafe] Re: Simple quirk in behavior of `mod`

2009-08-04 Thread Lennart Augustsson
That how I was taught to round in school, so it doesn't seem at all unusual to me. 2009/7/23 Matthias Görgens matthias.goerg...@googlemail.com: Round-to-even means x.5 gets rounded to x if x is even and x+1 if x is odd. This is sometimes known as banker's rounding. OK.  That's slightly

Re: [Haskell-cafe] Re: Adding a field to a data record

2009-07-29 Thread Lennart Augustsson
With the RecordWildCard extension you should be able to write newFoo Old.Foo{..} = New.Foo { .., z=1 } On Tue, Jul 28, 2009 at 3:47 PM, Henry Laxennadine.and.he...@pobox.com wrote: Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk writes: and perhaps use emacs to query-replace all the

Re: [Haskell-cafe] Slightly off-topic: Lambda calculus

2009-06-21 Thread Lennart Augustsson
As others have pointed out, it is not enough to rename before reduction. It should be pretty obvious since when you do substitution and copy a lambda expression into more than once place you will introduce variables with the same name. You can keep unique variables by cloning during substitution,

Re: [Haskell-cafe] Slightly off-topic: Lambda calculus

2009-06-21 Thread Lennart Augustsson
Actually, keeping all names distinct is not de Bruijn numbering, it's called the Barendregt convention. On Sun, Jun 21, 2009 at 7:05 PM, Deniz Dogandeniz.a.m.do...@gmail.com wrote: 2009/6/21 Andrew Coppin andrewcop...@btinternet.com: OK, so I'm guessing there might be one or two (!) people

Re: [Haskell-cafe] unique identity and name shadowing during type inference

2009-06-20 Thread Lennart Augustsson
Use 1. You'll probably need a monad in the type checker soon or later anyway, e.g., for handling errors. On Sat, Jun 20, 2009 at 7:57 PM, Geoffrey Irvingirv...@naml.us wrote: Hello, I am designing a type inference algorithm for a language with arbitrary function overloading.  For various

Re: [Haskell-cafe] Obscure weirdness

2009-06-20 Thread Lennart Augustsson
Did you try running it in some debugger, like windbg or VS? 2009/6/20 Andrew Coppin andrewcop...@btinternet.com: Marcin Kosiba wrote: On Saturday 20 June 2009, Andrew Coppin wrote: OK, so here's an interesting problem... I've been coding away all day, but now my program is doing something

Re: [Haskell-cafe] curious about sum

2009-06-17 Thread Lennart Augustsson
What do you mean by literals are strict? Strictness is a semantic property of functions, and while literals can be overloaded to be functions I don't know what you mean. On Wed, Jun 17, 2009 at 9:50 PM, Keith Sheppardkeiths...@gmail.com wrote: Haskell's numeric literals are strict. You wouldn't

Re: [Haskell-cafe] curious about sum

2009-06-17 Thread Lennart Augustsson
The creators of Haskell didn't pick any particular representation for numbers. (Well, literals are kind of Integers.) You can pick what types you make instances of Num. Some of them are lazy, some of them are strict. On Wed, Jun 17, 2009 at 11:05 PM, Keith Sheppardkeiths...@gmail.com wrote: In

Re: [Haskell-cafe] Performance of functional priority queues

2009-06-15 Thread Lennart Augustsson
A priority queue can't have all operations being O(1), because then you would be able to sort in O(n) time. So O(log n) deleteMin and O(1) for the rest is as good as it gets. On Mon, Jun 15, 2009 at 10:40 AM, Sebastian Sylvansebastian.syl...@gmail.com wrote: On Mon, Jun 15, 2009 at 4:18 AM,

Re: [Haskell-cafe] Performance of functional priority queues

2009-06-15 Thread Lennart Augustsson
I wasn't contradicting you, just clarifying that this is indeed the optimal asymtotic complexity. On Mon, Jun 15, 2009 at 3:43 PM, Sebastian Sylvansebastian.syl...@gmail.com wrote: Is that not what I said? On Mon, Jun 15, 2009 at 2:12 PM, Lennart Augustsson lenn...@augustsson.net wrote

Re: [Haskell-cafe] Bool as type class to serve EDSLs.

2009-05-28 Thread Lennart Augustsson
Here's what I usually use. As Simon points out, ambiguity is lurking as soon as you use conditional. You can avoid it a fundep, but that's not necessarily what you want either. -- | Generalization of the 'Bool' type. Used by the generalized 'Eq' and 'Ord'. class Boolean bool where () ::

Re: [Haskell-cafe] Haskell type system and the lambda cube

2009-05-25 Thread Lennart Augustsson
Type checking is decidable for all of the lambda cube, but not type inference. Haskell 98 is a subset of Fw, Haskell with extensions is an superset of Fw. -- Lennart On Mon, May 25, 2009 at 12:59 PM, Brent Yorgey byor...@seas.upenn.edu wrote: On Sun, May 24, 2009 at 10:39:50AM +0200, Petr

Re: [Haskell-cafe] conflicting variable definitions in pattern

2009-05-15 Thread Lennart Augustsson
In the original language design the Haskell committee considered allowing multiple occurrences of the same variable in a pattern (with the suggested equality tests), but it was rejected in favour of simplicity. -- Lennart On Fri, May 15, 2009 at 11:30 AM, Sittampalam, Ganesh

Re: [Haskell-cafe] conflicting variable definitions in pattern

2009-05-15 Thread Lennart Augustsson
, 2009 at 1:19 PM, Conor McBride co...@strictlypositive.org wrote: On 15 May 2009, at 12:07, Lennart Augustsson wrote: In the original language design the Haskell committee considered allowing multiple occurrences of the same variable in a pattern (with the suggested equality tests

Re: [Haskell-cafe] is value evaluated?

2009-05-09 Thread Lennart Augustsson
But testing for something being evaluated has to be in the IO monad, or else you're going to break the semantics. On Fri, May 8, 2009 at 4:14 PM, Don Stewart d...@galois.com wrote: Andy Gill has been advocating programmatic access to the 'is evaluated' status bit for years now. 'seq' becomes

Re: [Haskell-cafe] A brief note on n_k patterns and Hackage

2009-05-04 Thread Lennart Augustsson
I presume that is a joke, but it's not very funny. On Mon, May 4, 2009 at 6:48 PM, Richard O'Keefe o...@cs.otago.ac.nz wrote: [about n+k in Hackage] On 5 May 2009, at 12:23 pm, John Van Enk wrote: Which package? There are at least two occurrences of n+1 as a pattern. If anyone wants to get

Re: [Haskell-cafe] Question about implementing an off-side rule in Parsec 2

2009-04-28 Thread Lennart Augustsson
Implementing exactly Haskell's rule for indentation is incredibly hard. In fact, no known Haskell compiler gets it right. But if you make a slightly simpler one, it's easy. The simple one is the one based only on indentation. There are different ways you can do this. For instance, you can

Re: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release

2009-04-23 Thread Lennart Augustsson
, Colin Paul Adams co...@colina.demon.co.uk wrote: Lennart == Lennart Augustsson lenn...@augustsson.net writes:    Lennart Of course, n+k will be missed by Haskell obfuscators.  I    Lennart mean, what will we do without (+) + 1 + 1 = (+) ? I think what would be missed would you be having

Re: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release

2009-04-23 Thread Lennart Augustsson
On Thu, Apr 23, 2009 at 6:30 AM, Richard O'Keefe o...@cs.otago.ac.nz wrote:  - a somewhat bogus claim about how much of the library you need to   know how to use it (of COURSE you need to know about integers in   order to use an integer operation, what's so bad about that?)  - the claim that +

  1   2   3   4   5   6   >