Re: [Haskell-cafe] NumberTheory library

2005-05-12 Thread Bo Herlin
Hi I have put some comments and examples in the code now, and will continue to do so as soon as i get time for it. Please look at the code, and tell me if it is worth making into a part of an official library. Or, even better, if someone has already done this code, and in a better way. You

Re: [Haskell-cafe] NumberTheory library

2005-05-11 Thread Bo Herlin
Hi [EMAIL PROTECTED] wrote: G'day all. Quoting Bo Herlin [EMAIL PROTECTED]: Great! I like this a LOT. ... I don't know if I count as a guru or not, but by all means. Want to discuss this on-list or off-list? The code kinda big already, 700 lines + an util-file, so i'll put it on-line at http

Re: [Haskell-cafe] NumberTheory library

2005-05-10 Thread Bo Herlin
Well, part of what I was doing was experimenting with what a library like this should look like, even more than what it should do. For some reason, I kind of like writing this: *Math.Prime is Prime 42 False instead of this: *Math.Prime isPrime 42 False Great! I like

Re: [Haskell-cafe] NumberTheory library

2005-05-05 Thread Bo Herlin
You might want to check out the archives of the mailing list, too. These sorts of problems occasionally get solved. For the record, here are a few of my attempts: http://andrew.bromage.org/Fib.hs (Fairly fast Fibonacci numbers) http://andrew.bromage.org/WheelPrime.hs (Fast

Re: [Haskell-cafe] Ambiguous type signature in class declaration

2005-04-28 Thread Bo Herlin
Doh, i have another question: Lets say i do as you wrote: class CRank a b where rank :: a - b - Maybe Integer -- Nothing means b is out of range or badly constructed unrank :: a - Integer - Maybe b -- Nothing means rank is out of range class CCountable a where count :: a - Maybe

Re: [Haskell-cafe] Ambiguous type signature in class declaration

2005-04-28 Thread Bo Herlin
Hi again Next approach: module Cafe where class CRankable a where rank :: a b - b - Maybe Integer -- Nothing means b is out of range or badly constructed unrank :: a b - Integer - Maybe b -- Nothing means rank is out of range count :: a b - Maybe Integer -- Nothing means infinity

Re: [Haskell-cafe] Ambiguous type signature in class declaration

2005-04-28 Thread Bo Herlin
Benjamin Franksen wrote: (lots of information...) HTH, Ben Thank you, very generous indeed. This WILL certanly help, once i have learned more of the basics ;-) I have to try out this functional-dependencies-thing before i understand everything you have typed. Thanks! /Bo

[Haskell-cafe] Ambiguous type signature in class declaration

2005-04-27 Thread Bo Herlin
Hi I am trying to make a class like this: class CRank a b where rank :: a - b - Maybe Integer -- Nothing means b is out of range or badly constructed unrank :: a - Integer - Maybe b -- Nothing means rank is out of range count :: a - Maybe Integer -- Nothing means infinity with possible

Re: [Haskell-cafe] Ambiguous type signature in class declaration

2005-04-27 Thread Bo Herlin
Ok, i got it now, thanks for the help. /Bo ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] foldr1 min [(maxBound::Int)%1,1 % 2]

2005-04-13 Thread Bo Herlin
Hi How come foldr1 min [(maxBound::Int) % 1,1 % 2] 2147483647 % 1 but foldr1 min [2147483647 % 1,1 % 2] 1 % 2 Why??? /Bo Herlin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] foldr1 min [(maxBound::Int)%1,1 % 2]

2005-04-13 Thread Bo Herlin
Hmm, too simple :-P ...Thanks Henning Thielemann wrote: On Wed, 13 Apr 2005, Bo Herlin wrote: Hi How come foldr1 min [(maxBound::Int) % 1,1 % 2] 2147483647 % 1 I guess that foldr1 min == minimum but foldr1 min [2147483647 % 1,1 % 2] 1 % 2 Why??? The first one certainly causes an overflow

Re: [Haskell-cafe] foldr1 min [(maxBound::Int)%1,1 % 2]

2005-04-13 Thread Bo Herlin
(maxBound :: Int) * 2 1 * 1 == -2 1 which is again true! If you want well-behaved rationals, I suppose you have to use Ratio Integer. Hope this helps, - Cale On 4/13/05, Bo Herlin [EMAIL PROTECTED] wrote: Hi How come foldr1 min [(maxBound::Int) % 1,1 % 2] 2147483647 % 1 but foldr1 min

Re: [Haskell-cafe] List containing different types but all implementing the same class

2005-04-09 Thread Bo Herlin
Keean Schupke wrote: You can do this like: (code) This was a mouthful for me being a Haskell newbee, I have to chew on this one ;-) Thanks! /Bo Herlin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo

Re: [Haskell-cafe] List containing different types but all implementing the same class

2005-04-09 Thread Bo Herlin
Mark Carroll wrote: On Fri, 8 Apr 2005, Bo Herlin wrote: (snip) Is it possible to make this work? This is an extension beyond the 1998 standard, but http://haskell.org/hawiki/ExistentialTypes may be interesting to you. Yes, I think this is what I was aiming at. Thanks! /Bo Herlin

[Haskell-cafe] List containing different types but all implementing the same class

2005-04-08 Thread Bo Herlin
Is it possible to make this work? /Bo Herlin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe