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

2008-01-12 Thread Kalman Noel
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? Kalman -- Find out how you can get

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

2008-01-12 Thread Achim Schneider
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 ad-hoc expression of as the slices approach zero

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

2008-01-12 Thread Henning Thielemann
On Sat, 12 Jan 2008, 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

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

2008-01-12 Thread Achim Schneider
Achim Schneider [EMAIL PROTECTED] 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] Re: 0/0 1 == False

2008-01-12 Thread Kalman Noel
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 of pens. If someone knows how to properly

RE: [Haskell-cafe] type questions again....

2008-01-12 Thread Nicholls, Mark
Is my problem here, simply that the forall extension in GHC is misleading.that the forall in MkSwizzle :: (forall a. Ord a = [a] - [a]) - Swizzle is not the same beast as the forall in.. data Accum a = forall s. MkAccum s (a - s - s) (s - a) really data Accum a = exists s. MkAccum s

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

2008-01-12 Thread Cristian Baboi
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 use the abstraction. It's a bit like the difference

[Haskell-cafe] Typo in ByteString documentation

2008-01-12 Thread Johan Tibell
In Data.ByteString.Unsafe in the documentation of unsafePackAddress the documentation reads: Use unsafePackAddress if you know the length of the string statically. I assume that unsafePackAddressLen is the being function referred to here. If I was sitting in front of my laptop I would send you

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

2008-01-12 Thread Achim Schneider
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 the difference between eight pens and a box of

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

2008-01-12 Thread Hugh Perkins
On Jan 9, 2008 5:43 PM, Derek Elkins [EMAIL PROTECTED] wrote: A shorter and lighter and and also interesting and entertaining read is: http://research.microsoft.com/~simonpj/Papers/haskell-retrospective/index.htm While the reason Haskell was pure was to support laziness, at this point though

[Haskell-Cafe] Linq (FP in C#)

2008-01-12 Thread Hugh Perkins
Linq went live in C# in November, as part of .Net 3.5. It adds lots of FP-things to C#. It's really fun to be able to use Haskell-ish things in C#. Manipulating lists and collections just got *much* easier. Things it does: - map, fold, filter are all there (they're called select, agregate,

Re: [Haskell-Cafe] Linq (FP in C#)

2008-01-12 Thread Peter Verswyvelen
Yes indeed. And you forget expression trees: code gets translated into an AST like tree, and then you can use that tree for anything you want (like compiling different other code, or code for another platform) Hugh Perkins wrote: Linq went live in C# in November, as part of .Net 3.5. It adds

Re: [Haskell-cafe] Gtk2HS and GHC 6.8.2

2008-01-12 Thread Ian Lynagh
On Fri, Jan 11, 2008 at 06:50:02PM +0100, Peter Verswyvelen wrote: It seems GHC 6.8.2 fixes a couple of bugs in GHC 6.8.1, so I'm using that one. Gtk2HS does not yet detect my GHC 6.8.2 installation, but I guess it is 100% compatible. No, it's not binary-compatible. You'll need a Gtk2HS

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

2008-01-12 Thread Pierre-Evariste Dagand
2008/1/12, Cristian Baboi [EMAIL PROTECTED]: Suppose lim a_n = a , lim b_n = b, c_2n = a_n, c_2n+1 = b_n. What is lim c_n ? This reminds me of these good old days in Classe prépa (something typically french) doing these silly things with sequences and Epsilons... So let's try to do it :

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

2008-01-12 Thread Andre Nathan
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 cost in your case than the extra

[Haskell-cafe] ANN: Haskell Cryptographic Library 4.1.0

2008-01-12 Thread Dominic Steinitz
I'd like to announce the release of a new version of the library following various contributions (contributors are bcc'd). Additions include: BubbleBabble, TEA, HMAC and more large word support. It no longer includes Base64. This is provided by

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-12 Thread Andre Nathan
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, and they take up space in exchange for greater

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

2008-01-12 Thread Cristian Baboi
On Sat, 12 Jan 2008 13:55:19 +0200, Kalman Noel [EMAIL PROTECTED] wrote: Cristian Baboi: Suppose lim a_n = a , lim b_n = b, c_2n = a_n, c_2n+1 = b_n. What is lim c_n ? If my intuition was of any importance here, it would claim that c_n diverges, because if I roughly approximate c_n by the

[Haskell-cafe] Solving a geometry problem with Haskell

2008-01-12 Thread Rafael Almeida
Hello, I have been browsing through the problems at projecteuler.net and I found one that seemed interesting. It's the problem 176, I'll state it here: The four rectangular triangles with sides (9,12,15), (12,16,20), (5,12,13) and (12,35,37) all have one of the shorter sides

Re: [Haskell-cafe] Solving a geometry problem with Haskell

2008-01-12 Thread Hugh Perkins
On Jan 12, 2008 10:19 PM, Rafael Almeida [EMAIL PROTECTED] wrote: After some profiling I found out that about 94% of the execution time is spent in the ``isPerfectSquare'' function. I guess that Haskell's referential transparence means the answers to the isPerfectSquare will be cached, ie

Re: [Haskell-cafe] Solving a geometry problem with Haskell

2008-01-12 Thread Luke Palmer
On Jan 12, 2008 9:19 PM, Rafael Almeida [EMAIL PROTECTED] wrote: After some profiling I found out that about 94% of the execution time is spent in the ``isPerfectSquare'' function. That function is quite inefficient for large numbers. You might try something like this: isPerfectSquare n =

Re: [Haskell-cafe] Solving a geometry problem with Haskell

2008-01-12 Thread Luke Palmer
You can do better than this, too, actually. It looks like you're using isPerfectSquare inside a filter, which is given a monotone sequence. That means we can do: -- finds the intersection of two monotone sequences intersectMonotone :: (Ord a) = [a] - [a] - [a] intersectMonotone (x:xs)

[Haskell-cafe] Re: Solving a geometry problem with Haskell

2008-01-12 Thread Achim Schneider
Rafael Almeida [EMAIL PROTECTED] wrote: perfectSquares :: [Integer] perfectSquares = zipWith (*) [1..] [1..] isPerfectSquare :: Integer - Bool isPerfectSquare x = (head $ dropWhile (x) perfectSquares) == x what about module Main where isPerfectSquare :: Integer - Bool isPerfectSquare n =

[Haskell-cafe] Re: Solving a geometry problem with Haskell

2008-01-12 Thread Achim Schneider
Achim Schneider [EMAIL PROTECTED] wrote: Rafael Almeida [EMAIL PROTECTED] wrote: perfectSquares :: [Integer] perfectSquares = zipWith (*) [1..] [1..] isPerfectSquare :: Integer - Bool isPerfectSquare x = (head $ dropWhile (x) perfectSquares) == x what about module Main where

Re: [Haskell-cafe] Re: Solving a geometry problem with Haskell

2008-01-12 Thread Andrei Formiga
On Jan 12, 2008 7:12 PM, Achim Schneider [EMAIL PROTECTED] wrote: what about module Main where isPerfectSquare :: Integer - Bool isPerfectSquare n = sqrrt == fromIntegral (truncate sqrrt) where sqrrt = sqrt $ fromIntegral n ? It's a hell alot faster, but I have no idea if some

Re: [Haskell-cafe] Solving a geometry problem with Haskell

2008-01-12 Thread Daniel Fischer
Am Samstag, 12. Januar 2008 22:48 schrieb Luke Palmer: On Jan 12, 2008 9:19 PM, Rafael Almeida [EMAIL PROTECTED] wrote: After some profiling I found out that about 94% of the execution time is spent in the ``isPerfectSquare'' function. That function is quite inefficient for large numbers.

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

2008-01-12 Thread Kalman Noel
Cristian Baboi wrote: Cristian Baboi: Suppose lim a_n = a , lim b_n = b, c_2n = a_n, c_2n+1 = b_n. What is lim c_n ? If my intuition was of any importance here, it would claim that c_n diverges, because if I roughly approximate c_n by the sequence c' = ⟨a,b,a,b,...⟩, then I note that c'

Re: [Haskell-cafe] Solving a geometry problem with Haskell

2008-01-12 Thread Henning Thielemann
On Sat, 12 Jan 2008, Hugh Perkins wrote: On Jan 12, 2008 10:19 PM, Rafael Almeida [EMAIL PROTECTED] wrote: After some profiling I found out that about 94% of the execution time is spent in the ``isPerfectSquare'' function. I guess that Haskell's referential transparence means the answers

[Haskell-cafe] Re: Solving a geometry problem with Haskell

2008-01-12 Thread Achim Schneider
Achim Schneider [EMAIL PROTECTED] wrote: Achim Schneider [EMAIL PROTECTED] wrote: Rafael Almeida [EMAIL PROTECTED] wrote: perfectSquares :: [Integer] perfectSquares = zipWith (*) [1..] [1..] isPerfectSquare :: Integer - Bool isPerfectSquare x = (head $ dropWhile (x)

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, and they

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

2008-01-12 Thread Thomas Davie
On 12 Jan 2008, at 23:16, 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] [newbie question] Memoization automatic in Haskell?

2008-01-12 Thread Felipe Lessa
(While writing this message GMail told me I was too late to answer the question. Oh well, as I already typed it, let's send =) On Jan 12, 2008 9:16 PM, Hugh Perkins [EMAIL PROTECTED] wrote: Interesting... but I dont understand... I thought that referential transparence meant that once the

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

2008-01-12 Thread Henning Thielemann
On Sun, 13 Jan 2008, 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

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

2008-01-12 Thread Brandon S. Allbery KF8NH
On Jan 12, 2008, at 18:16 , 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] [newbie question] Memoization automatic in Haskell?

2008-01-12 Thread Hugh Perkins
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? (not sure if is correct term?)

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

2008-01-12 Thread David Benbennick
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 computed only when they are requested and then they

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

[Haskell-cafe] Re: Solving a geometry problem with Haskell

2008-01-12 Thread Achim Schneider
Rafael Almeida [EMAIL PROTECTED] wrote: [perfect square problem] most of this is shamelessly stolen from http://www.haskell.org/haskellwiki/Generic_number_type#squareRoot (^!) :: Num a = a - Int - a (^!) x n = x^n isSquare :: Integer - Bool isSquare n = let newtonStep x = div (x + div n

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

2008-01-12 Thread Henning Thielemann
On Sat, 12 Jan 2008, 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

[Haskell-cafe] Re: Solving a geometry problem with Haskell

2008-01-12 Thread Achim Schneider
Achim Schneider [EMAIL PROTECTED] wrote: the last one take a bit less than 20 secs on my pc. And 2^2^16 is a number that takes at least an hour to pronounce. Which means that I'm an absolute genius when it comes to fucking up perfectly good algorithms. -- (c) this sig last receiving data

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

2008-01-12 Thread Luke Palmer
On Jan 12, 2008 11:30 PM, David Benbennick [EMAIL PROTECTED] 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

[Haskell-cafe] fast fractional part of floating point number - modf?

2008-01-12 Thread Henning Thielemann
Is there a fast and reliable way to compute the fraction of a floating point number? I can implement fraction x = snd (properFraction x :: (Int, Double)) or fraction x = x - fromIntegral (truncate x :: Int) (actually I need 'floor' not 'truncate' but this is another issue) but these

Re: [Haskell-cafe] Re: Solving a geometry problem with Haskell

2008-01-12 Thread ajb
G'day all. Quoting Henning Thielemann [EMAIL PROTECTED]: The rare cases occur for big numbers. http://www.haskell.org/haskellwiki/Generic_number_type#isSquare How big, you might ask? Prelude let dd = undefined :: Double in floatRadix dd ^ floatDigits dd 9007199254740992 Pretty big, and

[Haskell-cafe] the trivial monad- thoughts and a question

2008-01-12 Thread Brian Hurt
So, I've been playing around with what I call the trivial monad: module TrivialMonad where data TrivialMonad a = M a recover :: TrivialMonad a - a recover (M x) = x instance Monad TrivialMonad where (M x) = f = f x (M x) f = f return x = M x fail s =

Re: [Haskell-cafe] the trivial monad- thoughts and a question

2008-01-12 Thread Isaac Dupree
Brian Hurt wrote: The second question I have is: is there any hope of getting something like this into the standard library? the newtype Identity in module Control.Monad.Identity in package `mtl` is what you describe:

Re: [Haskell-cafe] the trivial monad- thoughts and a question

2008-01-12 Thread Daniel Fischer
Am Sonntag, 13. Januar 2008 01:47 schrieb Brian Hurt: So, I've been playing around with what I call the trivial monad: module TrivialMonad where data TrivialMonad a = M a recover :: TrivialMonad a - a recover (M x) = x instance Monad TrivialMonad where (M x) = f = f x (M

Re: [Haskell-cafe] the trivial monad- thoughts and a question

2008-01-12 Thread Luke Palmer
On Jan 13, 2008 12:47 AM, Brian Hurt [EMAIL PROTECTED] wrote: So, I've been playing around with what I call the trivial monad: module TrivialMonad where data TrivialMonad a = M a Better to use newtype here; then it really is operationally equivalent to using just a, except that it's possible

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

2008-01-12 Thread Andre Nathan
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 last entry is used, though? Since getDirectoryEntries returns a

Re: [Haskell-cafe] the trivial monad- thoughts and a question

2008-01-12 Thread Miguel Mitrofanov
The first question I have is it is possible to implement this guy without wrapping the value in a constructor? No. The second question I have is: is there any hope of getting something like this into the standard library? It's there already. It's called Identity monad.

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

2008-01-12 Thread Luke Palmer
On Jan 13, 2008 12:42 AM, Andre Nathan [EMAIL PROTECTED] 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

[Haskell-cafe] ANNOUNCE: pcre-light, a light, portable regular expression library for Haskell

2008-01-12 Thread Don Stewart
pcre-light A light regular expression library, using Perl 5 compatible regexes I'm pleased to announce the first release of pcre-light. This library provides a simple, efficient interface to PCRE regular expressions, via either strict ByteStrings or classical

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 last entry is