Re: [Haskell-cafe] performance question
On Mon, Jan 17, 2005 at 08:54:38PM -0800, Ben Rudiak-Gould wrote: If performance is the main concern, I would flatten the data structure: data Interval = IlII Double Double | IlIE Double Double | IlEI Double Double | IlEE Double Double | NilII Double Double | NilIE Double Double | NilEI Double Double | NilEE Double Double I would go even further data IntervalType = IlII | IlIE | IlEI | IlEE | NilII | NilIE | NilEI | NilEE data Interval = Interval IntervalType {-# UNPACK #-} !Double {-# UNPACK #-} !Double now, the doubles can be stored in their native form and are not under a union data type (which always must be represented by a pointer) so accessing them can be very fast. John -- John Meacham - repetae.netjohn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] RE: Answers to Exercises in Craft of FP
Gour ([EMAIL PROTECTED]) wrote RE- : Do you know if there are solutions to exersises available somewhere? Have you gone through the whole book, i.e. all the exercises? Sincerely, Gour Hi Gour, Unfortuantely I don't know of anywhere that the exercise answers can be found, even after some google searching. I would definitely find them useful though as there are a couple I haven't been able to work out. I can't say I've gone through all the exercises yet but I'll get there one day! I've got as far as the abstract data types chapter. regards DaveO ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Math libraries for Haskell
Hello! Is there a math library for Haskell, using which one can calculate eigenvalues of matrices? Thanks in advance Dmitri Pissarenko -- Dmitri Pissarenko Software Engineer http://dapissarenko.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Math libraries for Haskell
On Tue, Jan 18, 2005 at 08:25:46PM +0100, Dmitri Pissarenko wrote: Hello! Is there a math library for Haskell, using which one can calculate eigenvalues of matrices? There is a binding to BLAS/LAPACK at http://www.isi.edu/~hdaume/HBlas/ but it might be too heavyweight for just calculating eigenvalues. however, it should be fast :) A standard matrix representation in the libraries would be nice. (not necessarily all matrix operations, but a representation/type so different peoples matrix libraries can play nice with each other) I was thinking something like a general matrix type, which a class for things that can be converted too it, and another class with a partial function for converting the general matricies to specific implementation versions. (so that one can write a library only for square matricies for instance and still use the general conversion routines) But I am sure others have given this more thought... John -- John Meacham - repetae.netjohn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Math libraries for Haskell
Are you interested in seeing Haskell implementation of these algorithms, or are you interested in using eignevalues in some Haskell program? I am interested in using eigenvalues in a Haskell program. This seems like a perfect candidate for using FFI if you're just looking for fast eigenvalue computations (though you'll need to write/find a C library to do it first). You mean that I have to write a program in C (or other language), which calculates the eigenvalues, and then let the C program co-operate with the Haskell program via FFI? TIA Dmitri Pissarenko -- Dmitri Pissarenko Software Engineer http://dapissarenko.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Math libraries for Haskell
On Tue, 18 Jan 2005 20:41:28 +0100, Dmitri Pissarenko [EMAIL PROTECTED] wrote: Are you interested in seeing Haskell implementation of these algorithms, or are you interested in using eignevalues in some Haskell program? I am interested in using eigenvalues in a Haskell program. This seems like a perfect candidate for using FFI if you're just looking for fast eigenvalue computations (though you'll need to write/find a C library to do it first). You mean that I have to write a program in C (or other language), which calculates the eigenvalues, and then let the C program co-operate with the Haskell program via FFI? No you don't have to (see the other replies), it just seems to me that these types of things is probably widely available already as C libraries, and by simply interfacing to one of those you'll likely get better speed (if that is indeed important to you) than just writing it in Haskell directly. -- Sebastian Sylvan +46(0)736-818655 UIN: 44640862 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] About instance
Hi. I have the next definitions: type Ocurrence = (String, Int) type Inside = [Ocurrence] data Pattern = Return Inside | Abort | Filter (Ocurrence - Bool) Pattern beyond :: Pattern - Pattern beyond (Filter pred Abort) = Abort -- more definitions of beyond optimous :: Pattern - Pattern optimous p = fixPoint beyond p where fixPoint f x = if(f x == x) then x else fixPoint f (f x) When I load the program an error is produced: ERROR - An instance of Eq (Event - Bool) is required to derive Eq Pattern I put: data Pattern = Return Inside | Abort | Filter (Ocurrence - Bool) Pattern deriving (Eq) and a new error was produced: ERROR - An instance of Eq (Ocurrence - Bool) is required to derive Eq Pattern Who can I do an instance of Eq (Ocurrence - Bool)? Is there another option to avoid the error? Regards Ulises _ Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] About instance
On 18 Jan 2005, at 21:45, Ulises Juarez Martinez wrote: Who can I do an instance of Eq (Ocurrence - Bool)? Is there another option to avoid the error? In general, you can't define one. To define equality on functions you want to check the value on every possible input, and since Ocurrence is an infinite type, that can't be done in a finite time. In this specific case, you are dealing with indicator functions, which are isomorphic to (possibly infinite) Sets of Ocurrences. If you happen to know that they will always be finite (or, perhaps, always cofinite) you might solve the problem by using that representation. Jules ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Why is getArgs in the IO monad?
In article [EMAIL PROTECTED], Keean Schupke [EMAIL PROTECTED] wrote: Surely both requirements can be satisfied if the programs arguments are made parameters of main: main :: [String] - IO () Keean. Better yet, it should be an implicit parameter so as not to break existing programs. main :: (?args :: [String]) = IO () You could do the same with standard input and output. -- Ashley Yakeley, Seattle WA ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Hugs vs GHC (again)was: Re: Somerandomnewbiequestions
On Tue, 2005-01-18 at 22:52 +, Glynn Clements wrote: Ben Rudiak-Gould wrote: Essentially, reading data from regular files is always deemed to occur soon, so the usual mechanisms for dealing with slow I/O (i.e. pipes, FIFOs, character devices, sockets) don't work. This applies equally to non-blocking I/O (O_NONBLOCK), asynchronous I/O (O_ASYNC), select(), poll() etc. Yes, there are very few systems that do genuine async IO. I believe that Solaris and the Win NT kernel are supposed to be able to do this, though the interfaces to these features are apparently rather hard to use. I've heard that Linux is going to gain proper async IO for ordinary buffered (as opposed to direct IO) files some time in the not too distant future. Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: [Haskell] Re: Why is getArgs in the IO monad?
Keean Schupke [EMAIL PROTECTED] writes: Surely both requirements can be satisfied if the programs arguments are made parameters of main: main :: [String] - IO () From info '(libc)Error Messages', about program_invocation_name and program_invocation_short_name: *Portability Note:* These two variables are GNU extensions. If you want your program to work with non-GNU libraries, you must save the value of `argv[0]' in `main', and then strip off the directory names yourself. We added these extensions to make it possible to write self-contained error-reporting subroutines that require no explicit cooperation from `main'. This suggests that making global parameters available only as arguments of main would be a bad idea. But they should be settable, to account for the rare case of wanting to substitute something else to a library which reads them itself. -- __( Marcin Kowalczyk \__/ [EMAIL PROTECTED] ^^ http://qrnik.knm.org.pl/~qrczak/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Books on Haskell
Haskell wiki pages for this stuff? I presume you would need the authors/publishers permission. I am 62 pages into Implementing Functional Languages: a tutorial and would be happy to put up the solutions I have so far (with appropriate permission of course). The advantage of the wiki is that you can present different solutions (contributed by different people) that correspond to different programming styles. Matt On 18/01/2005, at 6:39 AM, Gour wrote: David Owen ([EMAIL PROTECTED]) wrote: I recommend Thompson's book because it contains good explanations and lots of exercises, although the book is quite big and takes some time to work through. Do you know if there are solutions to exersises avaialable somewhere? Have you gone through the whole book, i.e. all the exercises? Sincerely, Gour -- Registered Linux User | #278493 GPG Public Key | 8C44EDCD ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] styles
Haskell seems to be a language that allows for lots of different programming styles. The most obvious being pointed v.s. point free. As a programmer born and raised on OO - I have found the pointed style to suit me better. However, there are other distinctions. I heavily use let in and where to break up each function into smaller parts while I see other programmers putting everything in one line. I have seen the evolution of a Haskell programmer joke and most of it goes over my head. My question is Is there standard terminology for the different programming styles in Haskell (besides pointed and point-free)? Matt ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: performance question (John Meacham)
thanks Ben and John, your ideas looked like they may speed up things indeed, so i went along with them and reimplemented the whole thing to my surprise, the program got considerably slower even ! here is the new code. data ILtype = II | IE | EI | EE | NII | NIE | NEI | NEE deriving (Eq, Ord) (... I found no increase in performance by using the UNPACK pragma as you suggested, so I just ommitted it in this version...) data Interval = Range ILtype !Double !Double deriving (Eq, Ord) instance Show Interval where show (Range iltype x y) = case iltype of II - if x == y then (show x) else [ ++ (show x) ++ .. ++ (show y) ++ ] IE - [ ++ (show x) ++ .. ++ (show y) ++ ) EI - ( ++ (show x) ++ .. ++ (show y) ++ ] EE - ( ++ (show x) ++ .. ++ (show y) ++ ) NII - Not ++ show (Range II x y) NIE - Not ++ show (Range IE x y) NEI - Not ++ show (Range EI x y) NEE - Not ++ show (Range EE x y) the flip of interval types: ilFlip :: ILtype - ILtype ilFlip ilt = case ilt of II - NII IE - NIE EI - NEI EE - NEE NII - II NIE - IE NEI - EI NEE - EE The complement of Intervals : intComplement :: Interval - Interval intComplement (Range iltype x y) = (Range (ilFlip iltype) x y) membership function for Intervals: isIn :: Double - Interval - Bool isIn r (Range iltype x y) = case iltype of II - r = x r = y IE - r = x r y EI - r x r = y EE - r x r y NII - r y || r x NIE - r y || r = x NEI - r = y || r x NEE - r = y || r = x As always, any further comments or insights greatly appreciated. stijn. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe