Re: [Haskell-cafe] What puts False before True?

2007-05-30 Thread kahl
What is the basic philosophy for Bool being a member of Ord? What justifies False True? The implication ordering, which on this smallest non-trivial Boolean algebra happens to be a linear order, is therefore the natural candidate for Ord, the type class of ``default linear orders''.

Re: [Haskell-cafe] The C Equiv of != in Haskell miscommunication thread

2007-05-29 Thread kahl
P.S. Have some cute code: Control.Monad.Fix.fix ((1:) . scanl (+) 1) Cute! But what an un-cute qualified name: :t Control.Monad.Fix.fix Control.Monad.Fix.fix :: (a - a) - a Has nothing to do with monads, and would perhaps be considered as ``out of Control'' in any case... ;-)

Re: [Haskell-cafe] Displaying infered type signature of 'offside' functions

2007-05-02 Thread kahl
Jules Bean [EMAIL PROTECTED] wrote, concerning the problem of getting at the types of local definitions: Simon Peyton-Jones wrote: The principal difficulties here are to do with what do we want rather the implementation challenges. 1. Should the compiler print the type of every

Re: [Haskell-cafe] Displaying infered type signature of 'offside' functions

2007-05-02 Thread kahl
* It would be nice if this worked inside the do-notation, too: do x :: Ordering x - m (This is curently a syntax error.) I think the following works with -fglasgow-exts: do (x :: Ordering) - m I know, but it is not as nice! ;-) Wolfram

Re: [Haskell-cafe] Recursion in Haskell

2007-02-19 Thread kahl
For absorbing the functional style of programming (which is what you really should be working on at this point), For functional style and the reasoning attitude associated with lazy functional programming, the following book is a good introduction: @Book{Bird-2000, author = {Richard

Re: [Haskell-cafe] factorising to prime numbers

2007-02-09 Thread kahl
If you look at the definition of 'powers' you'll note it's infinite. So there's no easy way to take the product of this list, if I don't know how many items to take from it. So you need finite lists. -- how many of the prime p are in the unique factorisation -- of the integer n?

Re: [Haskell-cafe] Space Leak Help

2007-02-04 Thread kahl
\begin{code} catWithLen :: [a] - (Int - [a]) - [a] catWithLen xs f = h 0 xs where h k [] = f k h k (x : xs) = case succ k of-- forcing evaluation k' - x : h k' xs \end{code} Thanks but this gives a different problem:

Re: [Haskell-cafe] Space Leak Help

2007-02-03 Thread kahl
I have re-written SHA1 so that is more idiomatically haskell and it is easy to see how it implements the specification. The only problem is I now have a space leak. I can see where the leak is but I'm less sure what to do about getting rid of it. Here's the offending

Re: [Haskell-cafe] GADTs: the plot thickens?

2007-01-31 Thread kahl
Hi Connor, A puzzle for you (and for me too). I just tried to translate an old Epigram favourite (which predates Epigram by some time) into GADT-speak. It went wrong. I had a feeling it might. I wonder how to fix it: I imagine it's possible to fix it, but that some cunning may be

Re: [Fwd: Re: [Haskell-cafe] Typeclasses and GADT [Was: Regular Expressions without GADTs]]

2005-10-26 Thread kahl
Tomasz Zielonka [EMAIL PROTECTED] wrote Wed, 26 Oct 2005 13:37:29 +0200: Speaking about casts, I was playing with using GADTs to create a non-extensible version of Data.Typeable and Data.Dynamic. I wonder if it's possible to write such a thing without GADTs (and unsafeCoerce, which is

Re: [Fwd: Re: [Haskell-cafe] Typeclasses and GADT [Was: Regular Expressions without GADTs]]

2005-10-26 Thread kahl
On 26 Oct 2005 10:11:25 -0400, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Tomasz Zielonka [EMAIL PROTECTED] wrote Wed, 26 Oct 2005 13:37:29 +0200: Speaking about casts, I was playing with using GADTs to create a non-extensible version of Data.Typeable and Data.Dynamic.