Re: [Haskell-cafe] Regular Expression Parsing via derivatives

2011-08-02 Thread Christian Maeder
Am 01.08.2011 17:51, schrieb Alex Clemmer: Hi Haskell people, I've been snooping through various mailing lists and the current Haskell implementation of regular expressions and I was wondering if there has been a discussion about implementing regex parsing with derivatives. If so, I haven't

[Haskell-cafe] difference between class context and deriving

2011-08-02 Thread Patrick Browne
What is the difference between using a class context and deriving in data type declaration? Are there certain situations in which one or the other is preferred? data Eq a = Set1 a = NilSet1 | ConsSet1 a (Set1 a) data Set2 a = NilSet2 | ConsSet2 a (Set2 a) deriving Eq (NilSet1) ==

Re: [Haskell-cafe] difference between class context and deriving

2011-08-02 Thread Nicolas Wu
Hi Patrick, On 2 August 2011 13:57, Patrick Browne patrick.bro...@dit.ie wrote: What is the difference between using a class context and deriving in data type declaration? A class context simply says something about the types involved in the construction. In your example, data Eq a = Set1 a

Re: [Haskell-cafe] difference between class context and deriving

2011-08-02 Thread Henning Thielemann
On Tue, 2 Aug 2011, Patrick Browne wrote: What is the difference between using a class context and deriving in data type declaration? Are there certain situations in which one or the other is preferred? data Eq a = Set1 a = NilSet1 | ConsSet1 a (Set1 a) Note that these contexts might get

Re: [Haskell-cafe] difference between class context and deriving

2011-08-02 Thread Ryan Ingram
On Tue, Aug 2, 2011 at 5:57 AM, Patrick Browne patrick.bro...@dit.iewrote: data Eq a = Set1 a = NilSet1 | ConsSet1 a (Set1 a) data Set2 a = NilSet2 | ConsSet2 a (Set2 a) deriving Eq The former declaration is a language wart, IMO. All it does is attach a restriction to the

Re: [Haskell-cafe] QuickCheck Questions

2011-08-02 Thread Øystein Kolsrud
Hi! I usually use the function 'sized' for this. The function would look something like this: myIntGen :: Gen Int myIntGen = sized $ \n - choose (0,f n) where 'f' is a function that uses the size value to generate an upper value for your random range. I usually use ^2 or sqrt or something like

[Haskell-cafe] weird type signature in Arrow Notation

2011-08-02 Thread bob zhang
hi, all testB :: (ArrowChoice t1, Num a1, Num a) = (a - a1 - t2) - t1 a t3 - t1 a1 t3 - t1 (a, a1) t testB f g h = proc (x,y) - do if (f x y)then g - x + 1 else h - y + 2 it's very strange that the type of _f_ is (a-a1-t2) which I thought should be a - a1 - Bool, btw, is there any way to get the

[Haskell-cafe] Fractional Part

2011-08-02 Thread Ata Jafari
Hi everyone, I'm totally new to Haskell and functional programming. I try to solve some problems from Proejct Euler with Haskell so that I can improve myself in functional programming. In the first step I want to write a little code that can give me only the decimal part of a float. For

Re: [Haskell-cafe] Fractional Part

2011-08-02 Thread Chris Smith
On Wed, 2011-08-03 at 02:06 +0300, Ata Jafari wrote: In the first step I want to write a little code that can give me only the decimal part of a float. For instance: properFraction from the RealFrac type class will divide into the real and fractional parts. Once you've got the fractional

Re: [Haskell-cafe] Fractional Part

2011-08-02 Thread Mark Spezzano
Hi Ata, You could write the following decimalPart :: Float - Integer decimalPart f = read (tail (tail (show (f :: Integer This basically says convert f into a String using the show function, and then get the tail of that String twice to get rid of the leading zero and the decimal point

Re: [Haskell-cafe] Fractional Part

2011-08-02 Thread Eric Rasmussen
Just a hint, but with Project Euler there's a chance you're headed in a difficult direction if you're working with the decimal parts directly. Usually (always?) you can approach the problem in a way that won't depend on something like decimal precision that can be different across