Re: [Haskell-cafe] More STUArray questions
On Mon, Mar 13, 2006 at 10:47:58PM +0100, Roberto Zunino wrote: Martin Percossi wrote: matrix.hs:138:27: Couldn't match the rigid variable `.' against `ST' `.' is bound by the type signature for `runSTMatrix' Expected type: ST s Inferred type: . (forall s1) Try compiling with -fglasgow-exts . Great! -- it works now. Thanks to everyone on this thread for their help and advice! Martin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: request for code review
On Tuesday 14 March 2006 20:58, you wrote: On 3/14/06, Benjamin Franksen [EMAIL PROTECTED] wrote: On Tuesday 14 March 2006 14:46, Pete Chown wrote: Shannon -jj Behrens wrote: Arrows looks like a replacement for monads. Are you saying I should drop my use of the State monad? If so, why? I like the readability of the do syntax. Okay, now it's my turn to ask a question. :-) I've read about arrows, and while I think I see what they do, I'm not sure why they are seen as so special that they even get new syntax. This question of Shannon's is exactly the point I struggle with. I can see that the arrow operators might be useful with functions, but are they useful for other things too? Yes, http://www.haskell.org/arrows/biblio.html lists a number of papers describing non-trivial applications of Arrows, that is, Arrows other than (-). I found the exposition in http://www.haskell.org/yale/papers/oxford02/ to be quite readable. For example, as monads are one kind of arrow, I thought I would make some of the I/O functions into arrows and see what happened. The result was pretty much the same as using the monad, except slightly less convenient. You can write monadic code without ever using the syntax sugar, and get along. However, do-notation is convenient. OTOH, I am told that programming with Arrows is really quite inconvenient w/o the syntax sugar. Well, forgive me for my newbie-ness: o How important is it that I switch from using the State monad to using arrows? o How important is it that I switch from using | or $ to using arrows? (It seems that using arrows just to replace | or $ is like using a sledge hammer to drive a thumb tack.) o How much will this increase the conceptual complexity of my program--i.e. how much time am I going to have to spend explaining it in my article? o How much will this improve the readability or decrease the amount of code in my program? Thanks! -jj ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: request for code review
On Tuesday 14 March 2006 20:58, you wrote: On 3/14/06, Benjamin Franksen [EMAIL PROTECTED] wrote: On Tuesday 14 March 2006 14:46, Pete Chown wrote: Shannon -jj Behrens wrote: Arrows looks like a replacement for monads. Are you saying I should drop my use of the State monad? If so, why? I like the readability of the do syntax. Okay, now it's my turn to ask a question. :-) I've read about arrows, and while I think I see what they do, I'm not sure why they are seen as so special that they even get new syntax. This question of Shannon's is exactly the point I struggle with. I can see that the arrow operators might be useful with functions, but are they useful for other things too? Yes, http://www.haskell.org/arrows/biblio.html lists a number of papers describing non-trivial applications of Arrows, that is, Arrows other than (-). I found the exposition in http://www.haskell.org/yale/papers/oxford02/ to be quite readable. For example, as monads are one kind of arrow, I thought I would make some of the I/O functions into arrows and see what happened. The result was pretty much the same as using the monad, except slightly less convenient. You can write monadic code without ever using the syntax sugar, and get along. However, do-notation is convenient. OTOH, I am told that programming with Arrows is really quite inconvenient w/o the syntax sugar. Well, forgive me for my newbie-ness: o How important is it that I switch from using the State monad to using arrows? I can see no good reason to do it. o How important is it that I switch from using | or $ to using arrows? Not important. Arrows are just another way to structure a program. However, they have been designed for cases where a monad can /not/ be applied, such as e.g. self-optimizing parser combinators. (It seems that using arrows just to replace | or $ is like using a sledge hammer to drive a thumb tack.) Yes. o How much will this increase the conceptual complexity of my program--i.e. how much time am I going to have to spend explaining it in my article? A lot, so I'd say leave it alone. I would use either plain function application or --perhaps-- a state monad. o How much will this improve the readability or decrease the amount of code in my program? See above. I don't think you gain anything by using (). However, I still recommend using function application ($) instead of inverse application (|) because this closer to idiomatic Haskell. Besides, readability depends on how proficient the reader is. People who regularly program using Arrows may find it easy to read. I don't and have more difficulty understanding it than e.g. monadic code. Cheers, Ben ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: request for code review
Shannon -jj Behrens wrote: o How important is it that I switch from using the State monad to using arrows? Your problem seems to be naturally soved by the State monad, therefore you should use that. o How important is it that I switch from using | or $ to using arrows? Unimportant. However, I'd recommend switching from application ($,|) to composition (.,) where possible. It's more functional and often easier to read. o How much will this increase the conceptual complexity of my program Not at all. You might define locally as f g = \x - g (f x) or just pretend that this definition is contained in Control.Arrow due to a historical accident, thereby completely ignoring the existence of other arrows. Udo. -- Wo die Macht geistlos ist, ist der Geist machtlos. (aus einem Gipfelbuch) signature.asc Description: Digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] (no subject)
Hi Im having a small problem with the portability of my Haskell code. My code uses wxHaskell and the library for which this one is the Haskell interface (that is called wxWidgets) doesnt work in the same away in Windows and Linux. Now I now which code run in Linux and in Windows but I dont want to have to manually change the file in each platform. I tried a solution using the C pre-processor but I getting in trouble. I use code like: #ifdef __WIN32__ (Windows code) #else (Linux code) #endif I also add the --cpp to the ghc and it works for me in Linux but give me linking errors in Windows. Does someone have any hints on how to have different code in Windows and Linux? I would be thankful in some help. Best regards Miguel Vilaça ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] different code in different platforms
Sorry. In the previous email I forgot the subject. Hi Im having a small problem with the portability of my Haskell code. My code uses wxHaskell and the library for which this one is the Haskell interface (that is called wxWidgets) doesnt work in the same away in Windows and Linux. Now I now which code run in Linux and in Windows but I dont want to have to manually change the file in each platform. I tried a solution using the C pre-processor but I getting in trouble. I use code like: #ifdef __WIN32__ (Windows code) #else (Linux code) #endif I also add the --cpp to the ghc and it works for me in Linux but give me linking errors in Windows. Does someone have any hints on how to have different code in Windows and Linux? I would be thankful in some help. Best regards Miguel Vilaça ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] different code in different platforms
Hi, Does it really have to change statically? I use code like: #ifdef __WIN32__ (Windows code) #else (Linux code) #endif In Yhc, we use a runtime test to check between Windows and Linux. It has various advantages - we only have one code base, everything is type checked when we compile, and we've never run into any problems once despite developing on two different platforms. http://www-users.cs.york.ac.uk/~malcolm/cgi-bin/darcsweb.cgi?r=yhc-devel;a=headblob;f=/src/compiler98/Util/FilePath.hs Thanks Neil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: different code in different platforms
Neil Mitchell wrote: Does it really have to change statically? I use code like: #ifdef __WIN32__ (Windows code) #else (Linux code) #endif In Yhc, we use a runtime test to check between Windows and Linux. It has various advantages - we only have one code base, everything is type checked when we compile, and we've never run into any problems once despite developing on two different platforms. http://www-users.cs.york.ac.uk/~malcolm/cgi-bin/darcsweb.cgi?r=yhc-devel;a=headblob;f=/src/compiler98/Util/FilePath.hs There's a lot to be said for using runtime tests instead of conditional compilation, I agree. However, it can't be used exclusively: you can't choose between two foreign calls this way, for example, because one of the calls won't link. Cheers, Simon ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Deepest functor [was: fmap for lists of lists of lists of ...]
[EMAIL PROTECTED] wrote: The code below is more general that required. It also generic: it works for any Functor and any combination of Functors. It performs fmap over arbitrarily deep `collections': lists of maybes of maps of IOs, etc. -- arbitrarily nested fmappable things. Excellent. I guess I'll be brushing up on my typeclass-fu in order to figure out how all this works. Thanks, Greg Buchholz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Deepest functor [was: fmap for lists of lists of lists of ...]
[EMAIL PROTECTED] wrote: The code below is more general that required. It also generic: it works for any Functor and any combination of Functors. It performs fmap over arbitrarily deep `collections': lists of maybes of maps of IOs, etc. -- arbitrarily nested fmappable things. Excellent. I guess I'll be brushing up on my typeclass-fu in order to figure out how all this works. Thanks, Greg Buchholz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: request for code review
Ok, with all the various opinions, I think I'll: o Stick with the State monad. o Switch from | to $ and teach readers how to read it, Think of 'f $ g $ x' as 'f of g of x' or 'f(g(x))'. From that point of view, it may be helpful to read 'f $ g $ x' from right to left. Unless there are any objections, with that one change, I'll consider the coding done and move on to writing the article. Thanks so much for all of your various opinions and suggestions! I feel much more comfortable speaking from a position of authority knowing that all of you have reviewed my code! Best Regards, -jj On 3/15/06, Udo Stenzel [EMAIL PROTECTED] wrote: Shannon -jj Behrens wrote: o How important is it that I switch from using the State monad to using arrows? Your problem seems to be naturally soved by the State monad, therefore you should use that. o How important is it that I switch from using | or $ to using arrows? Unimportant. However, I'd recommend switching from application ($,|) to composition (.,) where possible. It's more functional and often easier to read. o How much will this increase the conceptual complexity of my program Not at all. You might define locally as f g = \x - g (f x) or just pretend that this definition is contained in Control.Arrow due to a historical accident, thereby completely ignoring the existence of other arrows. Udo. -- Wo die Macht geistlos ist, ist der Geist machtlos. (aus einem Gipfelbuch) -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFEF+f5c1ZCC9bsOpURAv2gAJwNirkt2yMFLlbTT9I2twUs3UcxdQCeKqx2 0FVTzx7VJEGtJexlGIJxero= =CPSW -END PGP SIGNATURE- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: different code in different platforms
On Wed, Mar 15, 2006 at 04:13:19PM +, Simon Marlow wrote: There's a lot to be said for using runtime tests instead of conditional compilation, I agree. However, it can't be used exclusively: you can't choose between two foreign calls this way, for example, because one of the calls won't link. A scheme I was considering for jhc was to (optionally) replace any foreign calls that don't link with 'error', a solution for ghc might be to include stub functions with the 'weak' attribute set in the object file for any potentially non-existing functions. then the system versions will override them if they exist, otherwise the stub functions will be called. perhaps there is room for a FFI extension there? allowing 'weak' to be specified on FFI imports that means 'don't complain if the system doesn't provide this function' John -- John Meacham - ⑆repetae.net⑆john⑈ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Learning from scratch
I'm just starting to learn Haskell from scratch and I've just hit a snag. The book Haskell: The Craft of Functional Programming, Second Edition uses some examples that call functions from Prelude.hs. But for some reason, two installations of Haskell that I have on my computer don't have the functions available. I have the OS X version of Hugs (http://www.haskell.org/soe/software.htm) for the book The Haskell School of Expression installed, as well as the latest version of the Glasgow Haskell Compiler. Both of them get errors with the functions such as ord and chr mentioned at the beginning of the first book mentioned. Where can I get Prelude.hs and the other files it needs, and what do I do with them? I'm going to move on to the School of Expression book after the Craft of Functional Programming book, which is why I have the SOE version of hugs installed. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Learning from scratch
For GHC try adding the line import Data.Char or import Char at the top of your Haskell program. Or in ghci, try Char.chr instead of chr, etc. Or try ghci filename.hs where filename.hs is a text file with the line import Char at the top. Now 'chr' should appear in scope. The hierarchical libraries are listed here: http://haskell.org/ghc/docs/latest/html/libraries/ (scroll down to see all the modules listed) You can search for functions here, e.g.: http://haskell.org/hoogle/?q=chr Good luck, Jared. On 3/15/06, Xavier Elizalde [EMAIL PROTECTED] wrote: I'm just starting to learn Haskell from scratch and I've just hit a snag. The book Haskell: The Craft of Functional Programming, Second Edition uses some examples that call functions from Prelude.hs. But for some reason, two installations of Haskell that I have on my computer don't have the functions available. I have the OS X version of Hugs (http://www.haskell.org/soe/software.htm) for the book The Haskell School of Expression installed, as well as the latest version of the Glasgow Haskell Compiler. Both of them get errors with the functions such as ord and chr mentioned at the beginning of the first book mentioned. Where can I get Prelude.hs and the other files it needs, and what do I do with them? I'm going to move on to the School of Expression book after the Craft of Functional Programming book, which is why I have the SOE version of hugs installed. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- http://www.updike.org/~jared/ reverse )-: ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] (no subject)
Hello José, Wednesday, March 15, 2006, 5:54:49 PM, you wrote: JMV #ifdef __WIN32__ i use the following: #if defined(mingw32_HOST_OS) || defined(__MINGW32__) || defined(_MSC_VER) -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe