Re: [Haskell-cafe] Category Theory woes
2010/2/2 Álvaro García Pérez agar...@babel.ls.fi.upm.es You may try Pierce's Basic Category Theory for Computer Scientists or Awodey's Category Theory, whose style is rather introductory. Both of them (I think) have a chapter about functors where they explain the Hom functor and related topics. I think Awodey's book is pretty fantastic, actually, but I'd avoid Pierce. Unlike Types and Programming Languages, I think Basic Category Theory... is a bit eccentric in its presentation and doesn't help the reader build intuition. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What *is* a DSL?
2009/10/7 Robert Atkey bob.at...@ed.ac.uk: What is a DSL? How about this as a formal-ish definition, for at least a pretty big class of DSLs: A DSL is an algebraic theory in the sense of universal algebra. I.e. it is an API of a specific form, which consists of: a) a collection of abstract types, the carriers. Need not all be of kind *. b) a collection of operations, of type t1 - t2 - ... - tn where tn must be one of the carrier types from (a), but the others can be any types you like. c) (Optional) a collection of properties about the operations (e.g. equations that must hold) Haskell has a nice way of specifying such things (except part (c)): type classes. Examples of type classes that fit this schema include Monad, Applicative and Alternative. Ones that don't include Eq, Ord and Show. The Num type class would be, if it didn't specify Eq and Show as superclasses. An implementation of a DSL is just an implementation of corresponding type class. Shallowly embedded DSLs dispense with the type class step and just give a single implementation. Deeply embedded implementations are *initial* implementations: there is a unique function from the deep embedding to any of the other implementations that preserves all the operations. The good thing about this definition is that anything we do to the deep embedding, we can do to any of the other implementations via the unique map. Thanks to Church and Reynolds, we can always get a deep embedding for free (free as in Theorems for Free). If our DSL is defined by some type class T, then the deep embedding is: type DeepT = forall a. T a = a (and so on, for multiple carrier types, possibly with type parameterisation). Of course, there is often an easier and more efficient way of representing the initial algebra using algebraic data types. Conor McBride often goes on about how the initial algebra (i.e. the deep embedding) of a given specification is the one you should be worrying about, because it often has a nice concrete representation and gives you all you need to reason about any of the other implementations. It's funny, because I wouldn't have thought about this in terms of type classes from the top of my head. What I've been thinking about a lot lately (because I'm trying to prepare notes on it) is building classifying categories from signatures, then considering the category of all possible functorial models (read: dsl embeddings) into the target category.I guess we're essentially talking about the same thing. The difference from looking at it as type classes is that you really do get all your equations preserved with product preserving functors from your classifying category; however, the topic came up earlier today of what would a language look like if it had a built in notion of functorial semantics - my guess is that it'd be like a stronger version of ML functors, but I don't really know. Cheers, C ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Monad transformer, liftIO
On Fri, Apr 3, 2009 at 11:49 AM, Michael Roth mr...@nessie.de wrote: Hello list, maybe I'm just stupid, I'm trying to do something like this: import Control.Monad import Control.Monad.Trans import Control.Monad.List foobar = do a - [1,2,3] b - [4,5,6] liftIO $ putStrLn $ (show a) ++ ++ (show b) return (a+b) main = do sums - foobar print sums But this apparently doesn't work... I'm total clueless how to achieve the correct solution. Maybe my mental image on the monad transformer thing is totally wrong? Okay, so I think what you want is import Control.Monad import Control.Monad.Trans import Control.Monad.List foobar :: ListT IO Int foobar = do a - msum . map return $ [1,2,3] b - msum . map return $ [4,5,6] liftIO $ putStrLn $ (show a) ++ ++ (show b) return (a+b) main = do sums - runListT foobar print sums There were a couple of things going on here: first, that you tried to use literal list syntax in do notation which I believe only works in the actual [] monad. Second, you didn't have the runListT acting on the foobar, which is how you go from a ListT IO Int to a IO [Int]. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] The votes are in!
2009/3/24 John Van Enk vane...@gmail.com: Is this the part where all the pundits come out and talk about how Jeff isn't a citizen, eats babies, and wants to turn Haskell into an imperative language? Well given the fact that Haskell has been called the world's best imperative language, that we have a multinational community, and that baby eating is an acceptable part of Haskell optimization* I think he'll fit in just fine. * Don Stewart might have a blog post about this, but I'm too lazy to look it up. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Request: warn about language extensions that are not used
2009/3/11 Peter Verswyvelen bugf...@gmail.com: When I put {-# OPTIONS_GHC -Wall -Werror #-} in my source file, I don't get compiler (GHC) warnings about redundant language extensions that I enabled. It would be nice if the compiler gave warnings about this, since after refactoring, some language extensions might not be needed anymore, and hence should be removed since fewer language extensions mean more stable and portable code no? What do you think? So you mean something like if you put {-# LANGUAGE GeneralizedNewtypeDeriving #-} in a file, but never do newtype deriving, it would warn you? I have no idea how hard that'd be to implement, but that sounds kind of cool. Useful for both refactoring and when you've inherited old code. Cheers, C ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell] ANN : happs-tutorial 0.8
Hello, I'd like to announce the release of the happstack-0.2 compatible release of happs-tutorial on hackage and available for perusing on tutorial.happstack.com. A number of changes occurred in this release: * General cleanup of code for readability * Migration to the new Happstack.Server.SimpleHTTP api * Addition of a chapter on multimaster, the Spread Toolkit based system for syncing your applications across multiple Happstack instances. * Revised chapters on introducing Happstack.Server and Happstack.State, with an emphasis on simple, well-commented examples showing the orthogonality of these separate libraries. * Minor bug fixes Cheers, Creighton ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell-cafe] ANN : happs-tutorial 0.8
Hello, I'd like to announce the release of the happstack-0.2 compatible release of happs-tutorial on hackage and available for perusing on tutorial.happstack.com. A number of changes occurred in this release: * General cleanup of code for readability * Migration to the new Happstack.Server.SimpleHTTP api * Addition of a chapter on multimaster, the Spread Toolkit based system for syncing your applications across multiple Happstack instances. * Revised chapters on introducing Happstack.Server and Happstack.State, with an emphasis on simple, well-commented examples showing the orthogonality of these separate libraries. * Minor bug fixes Cheers, Creighton ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell] ANN : Crypto 4.2.0 Related News
Hello Haskellers, I'm pleased to announce version 4.2.0 of Crypto has been uploaded to Hackage that I am taking over maintenance of the library from Dominic Steinitz. As of this release it should be cabal install'able on GHC 6.10.1. I'm also pleased to announce that the darcs repo will be moving from code.haskell.org to being hosted on Patch-Tag at http://patch-tag.com/repo/crypto/home. You don't need to sign up for Patch-Tag to use the read only repos, but you will need an account if you want to be given write access to the crypto repository. Please feel free to e-mail me with any issues or questions. Cheers, Creighton ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Re: [Haskell-cafe] ANN : Crypto 4.2.0 Related News
On Mon, Feb 16, 2009 at 7:30 PM, Antoine Latter aslat...@gmail.com wrote: On Mon, Feb 16, 2009 at 12:48 PM, Creighton Hogg wch...@gmail.com wrote: Hello Haskellers, I'm pleased to announce version 4.2.0 of Crypto has been uploaded to Hackage that I am taking over maintenance of the library from Dominic Steinitz. As of this release it should be cabal install'able on GHC 6.10.1. I'm also pleased to announce that the darcs repo will be moving from code.haskell.org to being hosted on Patch-Tag at http://patch-tag.com/repo/crypto/home. You don't need to sign up for Patch-Tag to use the read only repos, but you will need an account if you want to be given write access to the crypto repository. Please feel free to e-mail me with any issues or questions. Cheers, Creighton It's nice to see dogfooding of haskell frameworks - are there any announcements or blog postings anywhere for Patch-Tag? Maybe I missed something. Also I'm getting a 'not authorized' message when opening the above link. Ah, the repo was accidentally marked private. I've fixed that now. There have been a few bits of news about Patch-Tag so far, actually, but I think a good place to look right now is their blog http://blog.patch-tag.com/. Cheers, C ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell-cafe] ANN : Crypto 4.2.0 Related News
Hello Haskellers, I'm pleased to announce version 4.2.0 of Crypto has been uploaded to Hackage that I am taking over maintenance of the library from Dominic Steinitz. As of this release it should be cabal install'able on GHC 6.10.1. I'm also pleased to announce that the darcs repo will be moving from code.haskell.org to being hosted on Patch-Tag at http://patch-tag.com/repo/crypto/home. You don't need to sign up for Patch-Tag to use the read only repos, but you will need an account if you want to be given write access to the crypto repository. Please feel free to e-mail me with any issues or questions. Cheers, Creighton ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN : Crypto 4.2.0 Related News
On Mon, Feb 16, 2009 at 7:30 PM, Antoine Latter aslat...@gmail.com wrote: On Mon, Feb 16, 2009 at 12:48 PM, Creighton Hogg wch...@gmail.com wrote: Hello Haskellers, I'm pleased to announce version 4.2.0 of Crypto has been uploaded to Hackage that I am taking over maintenance of the library from Dominic Steinitz. As of this release it should be cabal install'able on GHC 6.10.1. I'm also pleased to announce that the darcs repo will be moving from code.haskell.org to being hosted on Patch-Tag at http://patch-tag.com/repo/crypto/home. You don't need to sign up for Patch-Tag to use the read only repos, but you will need an account if you want to be given write access to the crypto repository. Please feel free to e-mail me with any issues or questions. Cheers, Creighton It's nice to see dogfooding of haskell frameworks - are there any announcements or blog postings anywhere for Patch-Tag? Maybe I missed something. Also I'm getting a 'not authorized' message when opening the above link. Ah, the repo was accidentally marked private. I've fixed that now. There have been a few bits of news about Patch-Tag so far, actually, but I think a good place to look right now is their blog http://blog.patch-tag.com/. Cheers, C ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell] ANN : happs-tutorial 0.7
Hello, I'm pleased to announce the release of happs-tutorial 0.7 on Hackage. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/happs-tutorial This is the first release of happs-tutorial built against the new Happstack project. Not much has changed in content since the last release except a few minor cleanups a little bit of reorganization. The 0.8 release will consist of more extensive additions, with the primary focus being a walk through of multimaster. I've taken over the development of the tutorial from Thomas Hartman, who has already put a rather massive effort into making HAppS/Happstack more accessible. Please feel free to e-mail me with any comments, errata, or threats of bodily harm. Cheers, Creighton Hogg ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell-cafe] ANN : happs-tutorial 0.7
Hello, I'm pleased to announce the release of happs-tutorial 0.7 on Hackage. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/happs-tutorial This is the first release of happs-tutorial built against the new Happstack project. Not much has changed in content since the last release except a few minor cleanups a little bit of reorganization. The 0.8 release will consist of more extensive additions, with the primary focus being a walk through of multimaster. I've taken over the development of the tutorial from Thomas Hartman, who has already put a rather massive effort into making HAppS/Happstack more accessible. Please feel free to e-mail me with any comments, errata, or threats of bodily harm. Cheers, Creighton Hogg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Happstack 0.1 Released!
On Thu, Feb 5, 2009 at 6:58 PM, Don Stewart d...@galois.com wrote: andrewcoppin: Jochem Berndsen wrote: The HAppS project has been abandoned, see http://groups.google.com/group/HAppS/msg/d128331e213c1031 . The Happstack project is intended to continue development. For more details, see http://happstack.com/faq.html . So we've got HAppS, Happstack, WASH, Turbinado, probably others... Does anybody know how all these relate to each other? Where their strengths and weaknesses lie? It's nice to have choice, but without knowing what you're choosing between, it's hard to use it well. A comparative analysis of the 10+ Haskell web frameworks would be awesome. happstack, wash, fastcgi.., turbinado, perpubplat, riviera, salvia, kibro, ella, what was that one launched yesterday? *ah, yesod... That's a lot of frameworks to try compare and I don't think any one person would have the time to do more than a couple, but perhaps we could all agree on some kind of non-trivial, but still simple, application that we could implement deploy in the most natural way for each framework. It'd probably be easy to just point prospective framework users to the resulting series of blog posts elucidating the features of each. I'd vote for something like a trimmed down reddit clone, something that I'd expect everyone could do whether they deploy it via Apache or something that's part of the framework such as happstack-server. Cheers, C ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Why binding to existing widget toolkits doesn't make any sense
2009/1/29 Conal Elliott co...@conal.net: Hi Achim, I came to the same conclusion: I want to sweep aside these OO, imperative toolkits, and replace them with something genuinely functional, which for me means having a precise simple compositional (denotational) semantics. Something meaningful, formally tractable, and powefully compositional from the ground up. As long as we build on complex legacy libraries (Gtk, wxWidgets, Qt, OpenGL/GLUT, ...), we'll be struggling against (or worse yet, drawn into) their ad hoc mental models and system designs. As Meister Eckhart said, Only the hand that erases can write the true thing. I think working on a purely functional widget toolkit would actually be a really cool project. Do you have any ideas, though, on what should be the underlying primitives? The initial gut feeling I have is that one should just ignore any notion of actually displaying widgets instead focus on a clean algebra of how to 'add' widgets that relates the concepts of inheritance relative position. What I mean by inheritance, here, is how to direct a flow of 'events'. I don't necessarily mean events in the Reactive sense, because I think it'd be important to make the model completely independent of how time actual UI actions are handled. Any thoughts to throw in, here? Cheers, C ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Why binding to existing widget toolkits doesn't make any sense
On Mon, Feb 2, 2009 at 3:28 PM, Conal Elliott co...@conal.net wrote: On Mon, Feb 2, 2009 at 11:39 AM, Creighton Hogg wch...@gmail.com wrote: snip I think working on a purely functional widget toolkit would actually be a really cool project. Do you have any ideas, though, on what should be the underlying primitives? Again, my goal would not be a purely functional library, because even IO is purely functional. My goal is a denotational library, i.e., one that has an elegant (denotational) semantics, and hence is powerfully compositional and good for reasoning. Well, that is essentially what I meant but your point about clarity is taken. A truly mathematical semantic model is above beyond what is meant by purely functional. The initial gut feeling I have is that one should just ignore any notion of actually displaying widgets instead focus on a clean algebra of how to 'add' widgets that relates the concepts of inheritance relative position. What I mean by inheritance, here, is how to direct a flow of 'events'. I don't necessarily mean events in the Reactive sense, because I think it'd be important to make the model completely independent of how time actual UI actions are handled. Any thoughts to throw in, here? Cheers, C The Fruit paper, Genuinely Functional User Interfaces, gives a semantic model, which could be a starting place for thinking about possibilities. At the very least, I'd like to take it to 3D. The idea there is that a UI is a function from flows (behaviors/signals) to flows, where the input includes mouse keyboard stuff and the output includes an image. An image is, as in Pan, a function from R^2 - Color, where color includes partial opacity. When UIs are transformed in time and/or space, they correspondingly see inversely-transformed input, thanks to a general principle of transforming functions. Thanks. I'm reading it now. Cheers, C ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Employment
On Tue, Jan 20, 2009 at 1:50 PM, Paul Johnson p...@cogito.org.uk wrote: Tom Hawkins wrote: Such a database would help me counter by boss's argument that it's impossible to find and hire Haskell programmers. There was a thread last week where someone asked who would be interested in a hypothetical Haskell job. He got about 20 positive responses. This agrees with the experience of Microsoft Research in 2006 when they advertised for a third person to help with GHC development. They also had about 20 applicants. So next time I hear the you can't get the programmers line I'm going to respond with something like this: If you post an advert for a Haskell developer you will get 20 applicants. All of those people will be the kind of developer who learns new programming languages to improve their own abilities and stretch themselves, because nobody yet learns Haskell just to get a job. If you post an advert for a Java developer you will get 200 applicants. Most of them will be the kind of developer who learned Java because there are lots of Java jobs out there, and as long as they know enough to hold down a job then they see no reason to learn anything. Also, as an employee, I have to admit that any company that can say it uses Haskell for even part of its codebase immediately goes up in my esteem puts it on the shortlist for where to send my resume. The same way that programmers knowing Haskell implies a certain interest in CS beyond I want ma money, an employer using Haskell implies technically interesting software a stronger commitment to quality over expediency. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Comments from OCaml Hacker Brian Hurt
On Thu, Jan 15, 2009 at 10:46 AM, Ross Mellgren rmm-hask...@z.odi.ac wrote: snip Usually when encountering something like Monoid (if I didn't already know it), I'd look it up in the library docs. The problem I've had with this tactic is twofold: First, the docs for the typeclass usually don't give any practical examples, so sometimes it's hard to be sure that the append in mappend means what you think it means. Second is that there appears to be no way to document an _instance_. It would be really handy if there were even a single line under Instances Monoid ([] a) that explained how the type class was implemented for the list type. As it is, if you know what a Monoid is already, it's easy to figure out how it would be implemented. If you don't, you're either stuck reading a bunch of pages on the generic math term monoid and then finally realizing that it means appendable (and other similar things), or grovelling through the library source code seeing how the instance is implemented. I think you have a good point regarding documentation. Usually what I end up doing is just going into ghci testing out the instances with some trivial cases to make sure I have good intuition for how it's going to work. I don't think this a problem with the term 'monoid' though, but just a very generic problem with documentation. I have to do the same thing to understand an instance of Foldable despite how literal the name is. I don't know if it's very practical, but I like the idea of haddock generating either links to the source of the instance or some kind of expandable block that will show you the literal code. Cheers, Creighton ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Comments from OCaml Hacker Brian Hurt
On Thu, Jan 15, 2009 at 10:18 PM, Jonathan Cast jonathancc...@fastmail.fm wrote: On Thu, 2009-01-15 at 17:06 -0500, Steve Schafer wrote: On Thu, 15 Jan 2009 13:21:57 -0800, you wrote: Where, in the history of western civilization, has there ever been an engineering discipline whose adherents were permitted to remain ignorant of the basic mathematical terminology and methodology that their enterprise is founded on? Umm, all of them? Really. So the engineer who designed the apartment building I'm in at the moment didn't know any physics, thought `tensor' was a scary math term irrelevant to practical, real-world engineering, and will only read books on engineering that replace the other scary technical term `vector' with point-direction-value-thingy? I think I'm going to sleep snip It feels like this conversation is going in circles. What I'm taking away from the two very different arguments being made is that 1) math terms have their place when they describe the concept very precisely, e.g. monoid 2) the Haskell docs _don't_ do good enough a job at giving intuition for what math terms mean If we fix #2, then #1 is no longer a problem, yes? For you folks who work on GHC, is it acceptable to open tickets for poor documentation of modules in base? I think leaving the documentation to the tragedy of the commons isn't the best move, but if even a few of us could remember to open tickets when new Haskell'ers complain about something being confusing then it could be on _someone's_ docket. Cheers, Creighton ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell not ready for Foo [was: Re: Hypothetical Haskell job in New York]
2009/1/9 John A. De Goes j...@n-brain.net: If you're looking for a project to take on, I would suggest starting with the following: A high-level, type-safe AMQP client written in 100% Haskell, which provides a clean way of handling hundreds of unique message types. Then it would be possible to hook it up to any AMQP broker (most likely RabbitMQ). There are logical steps beyond the above (an embedded Haskell broker), but the above project is far from trivial. And the main undertaking, I think, consists not in coding to the spec (for which there is some help; a JSON representation of the AMQP specification can be processed and used to emit language-specific code), but in finding a design that works well in Haskell. snip reorder I apologize, but my question was geared more towards understanding what high-level OTP-like libraries Haskell is lacking, not full blown applications that haven't been written in Haskell. It sounded like you had some specific insight into this. Cheers, Creighton ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell not ready for Foo [was: Re: Hypothetical Haskell job in New York]
On Thu, Jan 8, 2009 at 8:32 AM, John A. De Goes j...@n-brain.net wrote: Haskell's networking support is very rudimentary. Erlang's is quite sophisticated. For network intensive applications, especially those requiring messaging, fault-tolerance, distribution, and so forth, there's no doubt that Erlang is a more productive choice. Not because of the language, per se, but because of all the stuff that is packaged with it, or available for it. Now I understand that there aren't(?) any Haskell implementations that can act as distributed nodes the way the Erlang implementation can, but I'm not familiar enough with Erlang to understand what it has for networking that the Haskell network packages don't have. Could you explain a bit further? I've been thinking a lot about network programming anyway lately am looking for library opportunities. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell not ready for Foo [was: Re: Hypothetical Haskell job in New York]
On Thu, Jan 8, 2009 at 12:06 PM, Don Stewart d...@galois.com wrote: wchogg: On Thu, Jan 8, 2009 at 8:32 AM, John A. De Goes j...@n-brain.net wrote: Haskell's networking support is very rudimentary. Erlang's is quite sophisticated. For network intensive applications, especially those requiring messaging, fault-tolerance, distribution, and so forth, there's no doubt that Erlang is a more productive choice. Not because of the language, per se, but because of all the stuff that is packaged with it, or available for it. Now I understand that there aren't(?) any Haskell implementations that can act as distributed nodes the way the Erlang implementation can snip There's nothing stopping you using Haskell nodes in a distributed fashion, and indeed there are groups doing this. Didn't realize it was charted territory. Sorry about that. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell not ready for Foo [was: Re: Hypothetical Haskell job in New York]
On Thu, Jan 8, 2009 at 2:02 PM, John A. De Goes j...@n-brain.net wrote: On Jan 8, 2009, at 12:56 PM, Tim Newsham wrote: You replied to someone discussing using Haskell at a CDN to implement things like web servers by saying that Haskell wasn't suitable for the task. That is incorrect. I replied to Achim's message asking for elaboration on Haskell's unsuitability. It was a convenient point to discuss Haskell's networking deficiencies. Part of the problem I'm having with this discussion, though, is that it's still not clear to me what critical features are lacking. I know you've said Haskell doesn't have anything quite like the Erlang OTP library, but that doesn't really help me much. I've only looked a little at OTP I don't think I understand what you get from its behaviors that you don't get from Control.Concurrent + mtl, i.e. various forms of state error handling independent of the concurrency underneath. Can you elucidate a bit more? I don't want the conversation to degenerate. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Reading group for Programming Collective Intelligence
Hello Haskellers, For those of your who aren't nose-deep in Real World Haskell at the moment, I'd like to start a small group for the O'Reilly book Programming Collective Intelligence*. I think it might be very instructive to convert the examples exercises to Haskell. I think it would be good experience for doing neat applications in Haskell may provide opportunities for adding to Hackage if the book relies on Python libraries that we don't have an equivalent for. If anyone is interested, just e-mail me I can work on the organization. Cheers, Creighton * http://tinyurl.com/7x4rga ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: hsc2hs problem
On Fri, Dec 5, 2008 at 9:49 AM, Duncan Coutts [EMAIL PROTECTED] wrote: On Thu, 2008-12-04 at 13:06 -0600, Creighton Hogg wrote: Hello, Since hsc2hs is distributed with GHC, I thought this might be a decent place to ask. I tried to run hsc2hs on a file that I know worked with my 6.8.3 installation, but now I'm getting the error /usr/local/lib/ghc-6.10.1/hsc2hs-0.67/template-hsc.h:4:19: error: HsFFI.h: No such file or directory Unfortunately the hsc2hs instance is specific to one ghc version. You've presumably got ghc-6.8.3 and ghc-6.10.1 installed. You're building stuff using ghc-6.8.3 but the hsc2hs from ghc-6.10.1 and so hsc2hs is getting passed the wrong include paths. If you use the hsc2hs from the ghc-6.8.3 installation then it should work. We should look into making it more independent of the ghc version. Funny you'd mention this! I was worried that this was the problem, so I cleaned out all my ghc instances then reinstalled ghc 6.10.1 from the binaries. I still had the same problem after that. Perhaps something was still lingering? I'm not sure what, though. Cheers, Creighton ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
hsc2hs problem
Hello, Since hsc2hs is distributed with GHC, I thought this might be a decent place to ask. I tried to run hsc2hs on a file that I know worked with my 6.8.3 installation, but now I'm getting the error /usr/local/lib/ghc-6.10.1/hsc2hs-0.67/template-hsc.h:4:19: error: HsFFI.h: No such file or directory Thanks, Creighton ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: hsc2hs problem
Ah, just to reply to myself the problem was rather simple: hsc2hs couldn't find any of the header files in the ghc/include directory. It was easy enough to fix that, but it was weird that installing ghc didn't take of that for me. Especially since I never had this problem with previous versions. Cheers, Creighton On Thu, Dec 4, 2008 at 1:06 PM, Creighton Hogg [EMAIL PROTECTED] wrote: Hello, Since hsc2hs is distributed with GHC, I thought this might be a decent place to ask. I tried to run hsc2hs on a file that I know worked with my 6.8.3 installation, but now I'm getting the error /usr/local/lib/ghc-6.10.1/hsc2hs-0.67/template-hsc.h:4:19: error: HsFFI.h: No such file or directory Thanks, Creighton ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
What causes loop?
Hello, So I'm trying to debug an issue that is causing GHC to emit the loop warning. I was hoping to get more information about what exactly that tells me about the kind of problem, other than the obvious interpretation that I appear to be getting into some kind of infinite loop. What is GHC detecting when it emits that warning? Thanks, Creighton ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
[Haskell-cafe] Questions for Free!
Hello Haskellers, So I have a bit of a follow up question after reading Theorems For Free! this weekend. There's a throw away comment near the beginning about how you can recast the results into category theoretic form, but using lax natural transformations. Now I'm assuming this means a natural transformation but where the naturality square holds only up to isomorphism instead of equality, but is that correct? Also, why would you need such a condition? Cheers, Creighton ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] FFI Newbie: c functions that want pointers to objects
On Thu, Oct 16, 2008 at 7:28 AM, Mauricio [EMAIL PROTECTED] wrote: Hi, Some functions in C changes data using pointers, like this example: void change_int (int *n) { *n ++; } What is the proper way to handle that? I guess I should wrap it like this: foreign ccall change_int change_int :: Ptr CInt - IO () Can I use that on a CInt in Haskell code? Like this obviously wrong code, but that probably shows what I want: do let myN = 5 change_int myN Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe (Sending to the list as well as just Mauricio this time...oops) You are wrapping the function correctly, but you need to actually create the Ptr CInt using the function malloc from Foreign.Marshal.Alloc, or more conveniently, the function new from Foreign.Marshal.Utils. Your code snippet would become do myNPtr - new 5 change_int myNPtr ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Where did House/hOp go?
2008/10/16 Donnie Jones [EMAIL PROTECTED]: Hello Svein Ove Aas, On Thu, Oct 16, 2008 at 12:31 PM, Svein Ove Aas [EMAIL PROTECTED] wrote: I'd finally gotten to the point in learning haskell at which they might be interesting to look at, and then.. they were gone. Does anyone know what happened to these projects? They used to be open-source, so the code should still be around somewhere, right? Below are a few links that hopefully you will find useful. Haskell and Operating Systems: http://www.haskell.org/haskellwiki/Applications_and_libraries/Operating_system House OS official home page: http://programatica.cs.pdx.edu/House/ This page doesn't seem to be loading at the moment, which I hope is only a temporary problem. I know the source code was available there a few months ago since I downloaded the code to House myself. The site is working for me even now. Unfortunately, the site hasn't really been updated much over the past couple of years and when I e-mailed some people on the Programatica project about the status of House Osker I never got anything back. The biggest obstacle you may find when trying to set up House hOp is that hOp is based upon a modified version of a very old GHC and from the last time I looked at it the GHC runtime has changed enough that making a new hOp will be non-trivial. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Where did House/hOp go?
On Thu, Oct 16, 2008 at 3:47 PM, Kenny Graunke [EMAIL PROTECTED] wrote: Hello! On Thu, Oct 16, 2008, Donnie Jones donnie at darthik.com wrote: [snip] The site is working for me even now. Unfortunately, the site hasn't really been updated much over the past couple of years and when I e-mailed some people on the Programatica project about the status of House Osker I never got anything back. The biggest obstacle you may find when trying to set up House hOp is that hOp is based upon a modified version of a very old GHC and from the last time I looked at it the GHC runtime has changed enough that making a new hOp will be non-trivial. Indeed! House 0.8, as listed on the official programatica page, is based on GHC 6.2...not so fun to work with these days. I've spent the last year or so working on House as part of my research, and have updated it to GHC 6.8.2 (with a lot of help). You can get a copy of my unofficial House 0.8.91 sources here: http://web.cecs.pdx.edu/~kennyg/house/ It's still a bit of a challenge to build. Notably, you'll need a 32-bit Linux system - it doesn't build on 64-bit linux nor Mac OS X (yet). If you just want a floppy image, you may as well stick with House 0.8 from http://programatica.cs.pdx.edu/House/ ... it's basically the same. Awesome! Thanks for working on this! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Network trouble: what to do?
So in my quest to create bindings to BlueZ in Haskell, I've hit a bit of a snag: sockets programming. In C, you can use the standard sockets library and just pass around addresses as arrays of 6 bytes instead of arrays of 4 bytes like you normally would. The problem I'm having is that in Network.Socket, there's no such wiggle room and you have to either provide a Word32 or four Word32's to represent the address. Is there a way around this that I just haven't seen, or should I write a patch to Network to add an extra constructor to SockAddr and code to handle it? Cheers, Creighton ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Network trouble: what to do?
On Wed, Oct 15, 2008 at 12:26 PM, Bryan O'Sullivan [EMAIL PROTECTED] wrote: On Wed, Oct 15, 2008 at 6:54 AM, Creighton Hogg [EMAIL PROTECTED] wrote: Is there a way around this that I just haven't seen, or should I write a patch to Network to add an extra constructor to SockAddr and code to handle it? Linux and Windows support Bluetooth sockets, but they have different ideas of what the address family is called (AF_BTH vs AF_BLUETOOTH). Less popular platforms are all over the map: some (Solaris) have no support, others (NetBSD) don't use sockets for Bluetooth. I don't think that a patch to Network.Socket is the way to go for this, since it won't be portable enough. Perhaps a Network.Bluetooth package is in order to hide all the platform-specific gunk. Ah, I've only ever used Bluetooth on Linux and didn't realize how different it was between platforms. I think you're right, then, and a Network.Bluetooth would be a good idea. Cheers, Creighton ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: Salsa: A .NET Bridge for Haskell
On Mon, Oct 13, 2008 at 1:35 PM, Albert Y. C. Lai [EMAIL PROTECTED] wrote: Alex Queiroz wrote: On Fri, Oct 10, 2008 at 5:48 PM, Andrew Coppin In what way? As far as I'm aware, .NET never really caught on and has long since become obsolete. In what alternate universe? Anthropic Principle: Everyone is in a different bubble of observable reality. Dude! Invoking the Anthropic Principle is the Physics equivalent of calling someone a Nazi: you automatically lose the discussion. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] A round of golf
Hey Haskell, So for a fairly inane reason, I ended up taking a couple of minutes and writing a program that would spit out, to the console, the number of lines in a file. Off the top of my head, I came up with this which worked fine with files that had 100k lines: main = do path - liftM head $ getArgs h - openFile path ReadMode n - execStateT (countLines h) 0 print n untilM :: Monad m = (a - m Bool) - (a - m ()) - a - m () untilM cond action val = do truthy - cond val if truthy then return () else action val (untilM cond action val) countLines :: Handle - StateT Int IO () countLines = untilM (\h - lift $ hIsEOF h) (\h - do lift $ hGetLine h modify (+1)) If this makes anyone cringe or cry you're doing it wrong, I'd actually like to hear it. I never really share my projects, so I don't know how idiosyncratic my style is. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A round of golf
On Thu, Sep 18, 2008 at 1:29 PM, Don Stewart [EMAIL PROTECTED] wrote: wchogg: Hey Haskell, So for a fairly inane reason, I ended up taking a couple of minutes and writing a program that would spit out, to the console, the number of lines in a file. Off the top of my head, I came up with this which worked fine with files that had 100k lines: main = do path - liftM head $ getArgs h - openFile path ReadMode n - execStateT (countLines h) 0 print n untilM :: Monad m = (a - m Bool) - (a - m ()) - a - m () untilM cond action val = do truthy - cond val if truthy then return () else action val (untilM cond action val) countLines :: Handle - StateT Int IO () countLines = untilM (\h - lift $ hIsEOF h) (\h - do lift $ hGetLine h modify (+1)) If this makes anyone cringe or cry you're doing it wrong, I'd actually like to hear it. I never really share my projects, so I don't know how idiosyncratic my style is. This makes me cry. import System.Environment import qualified Data.ByteString.Lazy.Char8 as B main = do [f] - getArgs s - B.readFile f print (B.count '\n' s) Compile it. $ ghc -O2 --make A.hs $ time ./A /usr/share/dict/words 52848 ./A /usr/share/dict/words 0.00s user 0.00s system 93% cpu 0.007 total Against standard tools: $ time wc -l /usr/share/dict/words 52848 /usr/share/dict/words wc -l /usr/share/dict/words 0.01s user 0.00s system 88% cpu 0.008 total So both you Bryan do essentially the same thing and of course both versions are far better than mine. So the purpose of using the Lazy version of ByteString was so that the file is only incrementally loaded by readFile as count is processing? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A round of golf
On Thu, Sep 18, 2008 at 1:55 PM, Don Stewart [EMAIL PROTECTED] wrote: wchogg: On Thu, Sep 18, 2008 at 1:29 PM, Don Stewart [EMAIL PROTECTED] wrote: snip This makes me cry. import System.Environment import qualified Data.ByteString.Lazy.Char8 as B main = do [f] - getArgs s - B.readFile f print (B.count '\n' s) Compile it. $ ghc -O2 --make A.hs $ time ./A /usr/share/dict/words 52848 ./A /usr/share/dict/words 0.00s user 0.00s system 93% cpu 0.007 total Against standard tools: $ time wc -l /usr/share/dict/words 52848 /usr/share/dict/words wc -l /usr/share/dict/words 0.01s user 0.00s system 88% cpu 0.008 total So both you Bryan do essentially the same thing and of course both versions are far better than mine. So the purpose of using the Lazy version of ByteString was so that the file is only incrementally loaded by readFile as count is processing? Yep, that's right The streaming nature is implicit in the lazy bytestring. It's kind of the dual of explicit chunkwise control -- chunk processing reified into the data structure. To ask an overly general question, if lazy bytestring makes a nice provider for incremental processing are there reasons to _not_ reach for that as my default when processing large files? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A round of golf
On Thu, Sep 18, 2008 at 1:55 PM, Don Stewart [EMAIL PROTECTED] wrote: wchogg: On Thu, Sep 18, 2008 at 1:29 PM, Don Stewart [EMAIL PROTECTED] wrote: wchogg: Hey Haskell, So for a fairly inane reason, I ended up taking a couple of minutes and writing a program that would spit out, to the console, the number of lines in a file. Off the top of my head, I came up with this which worked fine with files that had 100k lines: main = do path - liftM head $ getArgs h - openFile path ReadMode n - execStateT (countLines h) 0 print n untilM :: Monad m = (a - m Bool) - (a - m ()) - a - m () untilM cond action val = do truthy - cond val if truthy then return () else action val (untilM cond action val) countLines :: Handle - StateT Int IO () countLines = untilM (\h - lift $ hIsEOF h) (\h - do lift $ hGetLine h modify (+1)) If this makes anyone cringe or cry you're doing it wrong, I'd actually like to hear it. I never really share my projects, so I don't know how idiosyncratic my style is. This makes me cry. import System.Environment import qualified Data.ByteString.Lazy.Char8 as B main = do [f] - getArgs s - B.readFile f print (B.count '\n' s) Compile it. $ ghc -O2 --make A.hs $ time ./A /usr/share/dict/words 52848 ./A /usr/share/dict/words 0.00s user 0.00s system 93% cpu 0.007 total Against standard tools: $ time wc -l /usr/share/dict/words 52848 /usr/share/dict/words wc -l /usr/share/dict/words 0.01s user 0.00s system 88% cpu 0.008 total So both you Bryan do essentially the same thing and of course both versions are far better than mine. So the purpose of using the Lazy version of ByteString was so that the file is only incrementally loaded by readFile as count is processing? Yep, that's right The streaming nature is implicit in the lazy bytestring. It's kind of the dual of explicit chunkwise control -- chunk processing reified into the data structure. Hi Don, I have a bit more of a followup, actually. You make use of the built in bytestring consumer count, which itself is built upon the foldlChunks function which is only exported in the ByteString.Lazy.Internal. If I want to make my own efficient bytestring consumer, is that what I need to use in order to preserve the inherent laziness of the datastructure? Also, I feel a little at a loss for how to make a good bytestring producer for efficiently _writing_ large swaths of data via writeFile. Would it be possible to whip up a small example? Oh, and lastly, I apologize to both you Bryan for making you cry. I hope you can forgive my cruelty. Thanks, Creighton ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] one-way monads
On Wed, May 21, 2008 at 6:37 PM, Neil Mitchell [EMAIL PROTECTED] wrote: Hi Real Haskell Programmers Only Use Top Level IO! (But then again, real programmers wouldn't use Haskell: http://www.pbm.com/~lindahl/real.programmers.htmlhttp://www.pbm.com/%7Elindahl/real.programmers.html ) It's amazing how many phone interviews I've done where the HR person at the other end tries to tick the knows Pascal box, despite me trying my hardest to pronounce Haskell. Maybe Haskell == Pascal, under some fairly light equality Thanks Neil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe I've had the same experience! I don't swallow my 'h's in the slightest, so I'm presuming that it's just overly eager pattern matching. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Couple of formal questions
On Mon, May 5, 2008 at 9:53 AM, Wouter Swierstra [EMAIL PROTECTED] wrote: On 1 May 2008, at 16:58, Michael Karcher wrote: Wouter Swierstra [EMAIL PROTECTED] wrote: Hi Creighton, Where could I find a proof that the initial algebras final coalgebras of CPO coincide? I saw this referenced in the Bananas.. paper as a fact, but am not sure where this comes from. I couldn't find the statement you are referring to in Functional Programming with Bananas, Lenses, Envelopes, and Barbed Wire - but I'm not sure if this holds for every CPO. Probably he was referring to the last paragraph of the introduction: Working in CPO has the advantage that the carriers of intial algebras and final co-algebras coincide, thus there is a single data type that comprises both finite and infinite elements. Ah - thanks for pointing that out. According to my more categorically inclined office mates, Marcelo Fiore's thesis is a good reference: https://www.lfcs.inf.ed.ac.uk/reports/94/ECS-LFCS-94-307/ Hope that answers your question, Wouter I've had a lot of good reading material from this thread, and I greatly appreciate it: As a more background reading on this, I think Meijer Fokkinga's Program Calculation Properties of Continuous Algebras is good, though the notation is a little idiosyncratic. http://citeseer.ist.psu.edu/717129.html I've also liked Baez et al's Rosetta Stone paper as food for thought http://math.ucr.edu/home/baez/rosetta.pdf Creighton Hogg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Couple of formal questions
Hello Haskell, So there's two questions that have been bothering me lately while they are, as usual, a little off topic I figured this might be a good forum: Where could I find a good treatment on data vs. codata the difference between well-founded recursion well-founded(?) corecursion? Where could I find a proof that the initial algebras final coalgebras of CPO coincide? I saw this referenced in the Bananas.. paper as a fact, but am not sure where this comes from. Thanks, Creighton Hogg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Problems with Bananas
Hi, This isn't about Haskell per se, but I was reading the old Meijer et al. paper Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire I think there's a notational pun that's really confusing me. On page 12 we have the CataEval equation (|phi|) . in = phi . (|phi|)_L Now, the subscript L the following example of cons lists implies that L is a functor in this equation, yet the line immediately after this equation says that (CataEval) states how to evaluate an application of (|phi|) to an arbitrary element of L so then that makes it sound like the L here is the fixed point of some functor F, not the functor itself. I'm sure I'm just being dumb, but this is really bugging me. Thanks, Creighton Hogg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Pierce on type theory and category theory
On 9/25/07, Philippa Cowderoy [EMAIL PROTECTED] wrote: On Tue, 25 Sep 2007, Seth Gordon wrote: Are Benjamin C. Pierce's _Types and Programming Languages_ and/or _Basic Category Theory for Computer Scientists_ suitable for self-study? Basic Category Theory depends on your mindset somewhat. TaPL is great though, and frequently recommended. The follow-up is also good. Basic Category Theory is cute, but I think the exercises are sometimes phrased strangely. In some ways, the book makes more sense if you've already seen these ideas once are trying to get a more CS perspective of the math. I'll probably be alone in this, but I think Mac Lane is a fantastic book for learning category theory. It's hard, but if you trudge along and do the exercises you learn quite a bit. It's fun! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] [Math] Category theory research programs?
Hi Haskell, Sorry to contribute to the noise but given that we've been talking about categories lately, I was wondering if anyone had any opinions on good universities for studying category theory. I'm trying to figure out where to apply for my phd. I want to either be at a place with a strong category theory program or a strong differential geometry program. Thanks, Creighton ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Clearly, Haskell is ill-founded
On 7/9/07, Dan Piponi [EMAIL PROTECTED] wrote: On 7/8/07, Thomas Conway [EMAIL PROTECTED] wrote: The basic claim appears to be that discrete mathematics is a bad foundation for computer science. I suspect the subscribers to this list would beg to disagree. Wearing my tin foil hat for the moment, I think that there is a conspiracy by some computer scientists to drive a wedge between mathematicians and computer scientists. You can see hints of it in many places where both mathematicians and computer scientists hang out and there have been quite a few recent articles setting up mathematics and computer science as somehow in competition with each other. Many of the structures studied by mathematicians are algebraic. Many of the structures studied by computer scientists are coalgebraic (eg. the web itself can be seen as a vast coalgebraic structure). Okay Mr. Piponi, as a math geek I can't let that comment about the web slide without further explanation. Is it just the idea that coalgebras can capture the idea of side affects (a - F a) or is there something more specific that you're thinking of? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Clearly, Haskell is ill-founded
On 7/9/07, Conor McBride [EMAIL PROTECTED] wrote: Hi all On 9 Jul 2007, at 06:42, Thomas Conway wrote: I don't know if you saw the following linked off /. http://www.itwire.com.au/content/view/13339/53/ [..] The basic claim appears to be that discrete mathematics is a bad foundation for computer science. I suspect the subscribers to this list would beg to disagree. It's true that some systems are better characterised as corecursive coprograms, rather than as recursive programs. This is not a popular or well-understood distinction. In my career as an advocate for total programming (in some carefully delineated fragment of a language) I have many times been gotcha'ed thus: but an operating system is a program which isn't supposed to terminate. No, an operating system is supposed to remain responsive. And that's what total coprograms do. I'm sorry, but can you expand a little further on this? I guess I don't understand how a corecursion = responsive to input but not terminating. Where does the idea of waiting for input fit into corecursion? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: In-place modification
On 7/10/07, Aaron Denney [EMAIL PROTECTED] wrote: On 2007-07-10, Sebastian Sylvan [EMAIL PROTECTED] wrote: On 10/07/07, Andrew Coppin [EMAIL PROTECTED] wrote: Sebastian Sylvan wrote: That might eliminate the concurrency imperative (for a while!), but it doesn't adress the productivity point. My hypothesis is this: People don't like using unproductive tools, and if they don't have to, they won't. When the next mainstream language comes along to solve the concurrency problem (to some extent), it would seem highly likely that there will relatively soon be compilers for it for most embedded devices too, so why would you make your life miserable with C in that case (and cost your company X dollars due to inefficiency in the process)? ...because only C works on bizzare and unusual hardware? By what magic is this the case? Hardware automatically supports C without the efforts of compiler-writers? No, of course not. But the most popular architectures support C with /much smaller/ efforts of compiler writers. Now is this just because of the relative simplicity of C, because of a larger amount of collective experience in writing C compilers, or something else entirely ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Very freaky
On 7/10/07, Jim Burton [EMAIL PROTECTED] wrote: Andrew Coppin wrote: On the one hand, it feels exciting to be around a programming language where there are deep theoretical discoveries and new design territories to be explored. (Compared to Haskell, the whole C / C++ / Java / JavaScript / Delphi / VisualBasic / Perl / Python thing seems so boring.) On the other hand... WHAT THE HECK DOES ALL THAT TEXT *MEAN*?! _ I agree, it's exciting to use Haskell because of its theoretical underpinning and the sense of it as a lab for PL ideas. The cost of taking part in that (even as an observer) is the background knowledge and common vocabulary you need in order to make sense of a lot of the papers that you may get referred to, presuming you start asking the kind of questions that elicit answers like that. I don't think the amount of background knowledge required is actually that big but if it's missing you will feel like you're going one step forwards and two steps back. The Getting Started thread on Lambda the Ultimate is good - maybe we need a wikipage like that but of links to sources of the type theoretical background to Haskell (is there one already? I see Research Papers, which obviously has a different purpose). I don't know where the best place to start would be but, as I said in another thread Andrew, TAPL is great. Re. Curry-Howard, have a look Simon Thompson's book (online for free) http://www.cs.kent.ac.uk/people/staff/sjt/TTFP/ . Not quick reads (by any means!), but depending on your learning style, better value than asking ad hoc questions and joining the dots via blog posts/wiki pages etc. I'd like throw in another vote for TAPL. I've been reading it lately and it honestly makes type theory feel fairly simple and natural. I think Pierce's writing is very clear, but occasionally the exercises make the problem sound harder than it is and it gets a little confusing. A friend of mine has the same problem with his category theory book. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Collections
A lot of people have had comments on this thread, but I have a off-hand question: what data types are required by the 98 standard? I figured it was just lists tuples because they have syntactic support, but is that true? Thanks, Creighton ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] yi or not to yi was: IDE?
On 6/18/07, Andrew Coppin [EMAIL PROTECTED] wrote: Pasqualino 'Titto' Assini wrote: I think that we should not underestimate the transforming power of dogged determination. Think of Linux: only a terminal idiot could have conceived the plan of writing from scratch a clone of a 20 years old operating system (Unix) when everybody knew that momentum was on the side of the weaker solution (Microsoft) in the PC market and on the many existing commercial Unix versions in the professional market. Well, we all know what that stupid idea has led to. I certainly do, as I am writing this message under Linux. That reminds me... Somebody should write an *OS* in Haskell! :-D If that happened, then maybe at last I'd be able to have a choice other than M$ Windows (with all it's well-documented faults), and Unix (with its legendary unfriendliness and unecessary complexity). OTOH... how the heck do you write an operating system in a language that doesn't even support I/O? :-S Well, there hasn't been a lot of work done on the subject but you probably should look at http://programatica.cs.pdx.edu/House/ Now if you're seriously asking how one would do it, the basic approach taken in the paper was to create a monad H that was a controlled subset of IO that did all the fundamental interactions with the the hardware. The operations of H, as with IO, have to be primitives in the runtime that you're using and probably written in C or assembly. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] IDE?
On 6/18/07, Andrew Coppin [EMAIL PROTECTED] wrote: Mark T.B. Carroll wrote: Are KWrite and Kate something to do with KDE or something? One of the first things I do with a new Linux install is to dump all the KDE and Gnome stuff on the basis that it's an enormous amount of bloatware for little gain. Others may think differently! (-: Yeah, that'll be it then. ;-) Gnome and KDE are both rather bloated... Unfortunately, nothing better exists. :-( But then, the entire Linux world is too messy for me... hence my request for a petter OS. Well, since we're on the subject and it's only the Cafe list, what is it that you find messy about Linux that you would want to be solved by some hypothetical Haskell OS? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] yi or not to yi was: IDE?
On 6/18/07, Andrew Coppin [EMAIL PROTECTED] wrote: Creighton Hogg wrote: On 6/18/07, *Andrew Coppin* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: That reminds me... Somebody should write an *OS* in Haskell! :-D Well, there hasn't been a lot of work done on the subject but you probably should look at http://programatica.cs.pdx.edu/House/ Now if you're seriously asking how one would do it, the basic approach taken in the paper was to create a monad H that was a controlled subset of IO that did all the fundamental interactions with the the hardware. The operations of H, as with IO, have to be primitives in the runtime that you're using and probably written in C or assembly. I read about House once. It seemed too far-out to be true. OTOH, it's only a proof-of-concept system. I doubt it will ever become a real, usable system, sadly. Well if no one works on it, that's kind of a given. :-P But more seriously, what seems so far out about it? I'm curious. Also, if this thread of operating systems functional programming isn't interesting to other people then we should probably just take it to e-mail not the list. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] OS design FP aesthetics
On 6/18/07, Andrew Coppin [EMAIL PROTECTED] wrote: Creighton Hogg wrote: Well, since we're on the subject and it's only the Cafe list, what is it that you find messy about Linux that you would want to be solved by some hypothetical Haskell OS? This is drifting off-topic again, but here goes... Yeah, so I'll just split this off into a different thread. There are lots of things to like about Linux. It doesn't cost money. It's fast. It's reliable. It's flexible. It's secure. Okay, I'm not sure if I'd agree with the reliable secure points. I mean, relative to what could be done. I'm a rank amateur when it comes to OS work but when I've looked at recent papers Linux really isn't that cutting edge. I mean, it may be reliable in comparison to Windows 98 has less known exploits than any Windows system, but in terms of how good it *could* be I think there's an awful lot of room for growth. However, unfortunately it's still Unix. In other words, it's a vast incoherant mess of largely incompatible ad-hoc solutions to individual problems implemented independently by unrelated hackers over the 40+ years of history that this software has been around. New software has to emulate quirks in old software, and client programs work around the emulated quirks in the new software to get the functionallity it actually wants. One vast tangled mess of complexity and disorder. Exhibit A: Package managers exist. Exhibit B: Autoconf exists. I rest my case. Okay, but these don't seem to really be design flaws so much as the inevitable results of age and the need for backwards compatibility. I'm looking more for technical problems that you would want to see fixed in our magical UberOS. An operating system should have a simple, clear, consistent design. Not unlike a certain programming language named after a dead mathematition, come to think of it... (Have you ever programmed in C? You can certainly see where Unix gets its features from - terse, cryptic and messy.) This is another thing we're just going to disagree on. I think C++ is a pretty messy language, but feel that straight up C is rather simple and elegant. I had only used C++ before, but a friend rather easily convinced me that C is in fact a very sexy language when used in its intended design space. Still, I don't have the skill to write a functioning operating system - much less one that's ready for the desktop - so that's that I suppose... (I did seriously investigate the task once. Indeed, I got as far as writing a bootloader. It worked too!) Would you mind sharing the code? I'd be interested. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] OS design FP aesthetics
On 6/18/07, Creighton Hogg [EMAIL PROTECTED] wrote: On 6/18/07, Andrew Coppin [EMAIL PROTECTED] wrote: Creighton Hogg wrote: There are lots of things to like about Linux. It doesn't cost money. It's fast. It's reliable. It's flexible. It's secure. Okay, I'm not sure if I'd agree with the reliable secure points. I mean, relative to what could be done. I'm a rank amateur when it comes to OS work but when I've looked at recent papers Linux really isn't that cutting edge. I mean, it may be reliable in comparison to Windows 98 has less known exploits than any Windows system, but in terms of how good it *could* be I think there's an awful lot of room for growth. Isn't there a lot of room for improvement in *any* product? Well, I'm not just talking about improvement. I'm talking about things like capabilities, self-healing kernels, separation kernels, exo kernels, things that may have serious advantages but can't necessarily be strapped on to a preexisting kernel such as Linux. Bah. Of course after I say this I get a bad feeling, so I checked the interwebs and found out that there has been work on incorporating self-healing into Linux. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] OS design FP aesthetics
On 6/18/07, Thomas Conway [EMAIL PROTECTED] wrote: On 6/19/07, Creighton Hogg [EMAIL PROTECTED] wrote: Okay, I remember seeing an example of this before , but I'm not sure if I see what language based security Haskell's type system could provide in protecting address spaces from each other. Normally I've seen capabilities used so that you can't access anything you can't name. Can you elaborate a little? Nothing new here. Haskell might be more elegant than some of the earlier proposals, but the idea is old. FWIW, my PhD supervisor, Zoltan Somogyi did his PhD thesis on exactly such a scheme, using logic programming, rather than lazy functional programming. I'm not sure if the thesis itself is online. Actually it is! Thank you for the reference. http://www.cs.mu.oz.au/~zs/papers/papers.html in case anyone else is interested ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Just for a laugh...
On 5/31/07, Brandon S. Allbery KF8NH [EMAIL PROTECTED] wrote: On May 31, 2007, at 15:47 , Andrew Coppin wrote: If you're bored... can you come up with a solution to this? http://warp.povusers.org/ProgrammingChallenge.html Is it me, or does this look like a job for Data.Binary? It's not just you. When I read it I thought First I'd steal code from Data.Binary... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Memoization
On 5/26/07, Mark Engelberg [EMAIL PROTECTED] wrote: I'd like to write a memoization utility. Ideally, it would look something like this: memoize :: (a-b) - (a-b) memoize f gives you back a function that maintains a cache of previously computed values, so that subsequent calls with the same input will be faster. I've searched the web for memoization examples in Haskell, and all the examples use the trick of storing cached values in a lazy list. This only works for certain types of functions, and I'm looking for a more general solution. In other languages, one would maintain the cache in some sort of mutable map. Even better, in many languages you can rebind the name of the function to the memoized version, so recursive functions can be memoized without altering the body of the function. I don't see any elegant way to do this in Haskell, and I'm doubting its possible. Can someone prove me wrong? Now maybe I'm being dense here, but would you really *want* a way in Haskell to do something like memo :: (a-b) - a-b since it changes the semantics of the function? It seems like a better abstraction would be to have memo :: (a-b)- M a b where M is an instance of Arrow so that you can keep a proper notion of composition between memoized functions. Is there something wrong with my thinking? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Language extensions [was: Memoization]
On 5/29/07, Andrew Coppin [EMAIL PROTECTED] wrote: Claus Reinke wrote: phantom types: the types of ghost values (in other words, we are only interested in the type, not in any value of that type). Mmm... Still not seeing a great amount of use for this one. Okay, well phantom types are something I like because they allow some notion of static capabilities, a la http://okmij.org/ftp/papers/lightweight-static-capabilities.pdf One of my big interests is how much of a true capability based security system can be pushed up into the type level. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Memoization
On 5/30/07, Isaac Dupree [EMAIL PROTECTED] wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Creighton Hogg wrote: Now maybe I'm being dense here, but would you really *want* a way in Haskell to do something like memo :: (a-b) - a-b since it changes the semantics of the function? It seems like a better abstraction would be to have memo :: (a-b)- M a b where M is an instance of Arrow so that you can keep a proper notion of composition between memoized functions. Is there something wrong with my thinking? memoize f gives you back a function that maintains a cache of previously computed values, so that subsequent calls with the same input will be faster. Speed isn't part of Haskell function semantics (luckily, or we wouldn't be able to have an optimizer in the first place). memoize does not change the semantics of the function (I think) Your better abstraction is, anyway, better in terms of being implementable in existing Haskell - you might need an (Eq a) context or something. However it interferes with code structure for a non-semantical change (strong effects on memory use and speed which you might _want_ to manage more explicitly, but that's not theoretically affecting purity) Eh, I guess I was just being fascist. I suppose that even if there are side effects involved in the memoization, it doesn't break referential transparency which is the real measure of purity. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] OpenGL
On 5/30/07, Jon Harrop [EMAIL PROTECTED] wrote: I've found HOpenGL and the Debian package libghc6-opengl-dev. The former seems to be very out of date (last release 2003) but I can't find any demos for the latter. Where should I go to get started with OpenGL and Haskell? For at least GHC you can use the libraries that come with. Check out this blog entry as a nice starting place http://blog.mikael.johanssons.org/archive/2006/09/opengl-programming-in-haskell-a-tutorial-part-1/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] New book: Real-World Haskell!
On 5/23/07, Tom Harper [EMAIL PROTECTED] wrote: I really hope they choose the flying squirrel. They should just use that picture of Philip Wadler as Lambda-Man. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] instance monad problem
Hi On 5/14/07, Veer Singh [EMAIL PROTECTED] wrote: Hello, I am trying to learn haskell , but i am struggling with types , its been around 7 days , it will be very kind if some explain it why this error , i think this is the only stumbling block . I am looking for the comparison on why similar code works , while other code not . I get this error on ghci : {- `a' is not applied to enough type arguments Expected kind `*', but `a' has kind `* - *' In the type `SS a' In the type `(Monad a) = {Monad (SS a)}' In the instance declaration for `Monad (SS a)' -} Here is the very small code with comments: data SS a = SS a Int data Maybe1 a = Nothing1 | Just1 a instance Monad Maybe1 where (Just1 x) = f = f x --^^ this loads fine in ghci -- where as this instance (Monad a)= Monad (SS a) where (SS x y) = f = f (x y) --^^ does not work , so whats the difference , both have type parameters -- something similar works like this : instance (Eq a)=Eq (SS a) where (SS x y) == (SS b c) = (y == c) (x == b) The problem is that you've overspecified the monad SS. Notice that you only had to write instance Monad Maybe1 not instance Monad (Maybe1 a) That's because you declared Maybe1 to only take in one type parameter. SS also takes in only one type parameter, so you're actually telling it that it should make SS a b into a monad, but there is no SS a b. It might help to look at the definition of the State monad in All About Monads http://www.haskell.org/all_about_monads/html/ You'll see that state is defined as newtype State s a =... and they declare instance Monad (State s) not instance Monad (State s a) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Monad pronounced like gonad?
On 5/10/07, Dan Weston [EMAIL PROTECTED] wrote: I've been pronouncing monad like gonad (moh-nad), but it occurs to me that it might be pronounced like monoid (mah-nad). Is there an official way to pronouce this word - maybe with a Scottish accent? :) I've always said mah-nad, mah-noyd, and I think it might be because I always heard mah-no-morphism, not mo-no-morphism. I'll admit that doesn't really make sense, given then it's ho-mo-morphism. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Topoi, the categorical Analysis of Logic
Hi, I've been reading it off and on for a couple of months. I definitely wouldn't say it'll make you a better programmer, but it's a pretty nice, gentle, introduction to some basic category theory and some uses of topoi. Read it if you're interested in all that, not if you're just focused on programming. On 5/6/07, Philippe de Rochambeau [EMAIL PROTECTED] wrote: Hello, has anybody on this list read Goldblatt's Topoi, the categorical Analysis of Logic? Did reading that book make you a better Haskell programmer? If so, how? Cheers, phiroc ___ 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
Re: [Haskell-cafe] Monad/Functor Book
On 3/27/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Given the amount of material posted at haskell.org and elsewhere explaining IO, monads and functors, has anyone considered publishing a comprehensive book explaining those subjects? (I am trying to read all the material online, but books are easier to read and don't require sitting in front of a computer to do so. Plus I can write in books :-). ) Well, how much in depth are you interested in getting? I started reading Categories for the Working Mathematician a couple of months ago, and while it sometimes takes a bit of work it's a very good introduction. The only caution I have is that if you don't have that strong of a math background, or hadn't done it in a few years (like myself), you may have to lookup a lot of definitions in order to understand his examples. Wikipedia usually provides enough of a detailed description that you can get the point. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Monad/Functor Book
On 3/27/07, Dan Piponi [EMAIL PROTECTED] wrote: On 3/27/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Given the amount of material posted at haskell.org and elsewhere explaining IO, monads and functors, has anyone considered publishing a comprehensive book explaining those subjects? (I am trying to read all the material online, but books are easier to read and don't require sitting in front of a computer to do so. Plus I can write in books :-). ) I've thought about writing extended tutorials on the relationship between Haskell programming and category theory but there's a problem I run into. It's tempting to make the identifications: types-objects, Haskell function-arrows, suitably polymorphic functions-natural transformations, and so on. But the fact is, this doesn't really work in the obvious way even though it seems like it should at first (eg. Haskell functions aren't always total functions in the mathematical sense and if you allow partial functions you can do weird stuff). So either: (1) we need some technical work to patch up the differences (and unfortunately I don't know what the patch-up is), (2) we restrict ourselves to certain types of Haskell function for which the theory works or (3) we deliberately leave things a little vague. I usually tend to go for option (3), but that wouldn't be satisfactory for an extended treatment. Has anyone else given this subject much thought? I consider myself to be distinctly in the target audience of a thorough treatment of CT it's relationship to Haskell, so I'll throw out there that I think some superposition of options (2) and (3) would be the most satisfying. You can handwave a little bit, but knowing *where* the naive mappings between category theoretic constructs and Haskell's system breakdown would be very nice. Personally, one of the biggest things for me is not really having any intuition for what kind of category the Haskell type system lives in. I mean, it looks cartesian closed because you can do currying but what more to it is there than that? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: [Haskell] Call-by-name: moved to haskell-cafe
On 3/20/07, Dan Weston [EMAIL PROTECTED] wrote: Dan Weston wrote: Douglas Philips wrote: On 2007 Mar 20, at 3:30 PM, Dan Weston indited: I looked up John Backus on wikipedia and followed a link to ALGOL: http://en.wikipedia.org/wiki/ALGOL_60 where the following undesirable property of call-by-name is mentioned. ALGOL 60 allowed for two evaluation strategies for parameter passing: the common call-by-value, and call-by-name. Call-by-name had certain limitations in contrast to call-by-reference, making it an undesirable feature in language design. For example, it is impossible in ALGOL 60 to develop a procedure that will swap the values of two parameters if the actual parameters that are passed in are an integer variable and an array that is indexed by that same integer variable. However, call-by-name is still beloved of ALGOL implementors for the interesting thunks that are used to implement it. I suppose that call-by-name is still beloved of Haskell implementors as well? Notice that the problem with call-by-name is when side-effects are involved. In a pure-functional-environment those problems don't arise... --Doug It was the phrase making it an undesirable feature in language design that jumped out at me. Here language is an implicitly universally quantified variable, and the phrase beta-reduces to call-by-name is an undesirable feature in Haskell design. Ah, but since everything on wikipedia is true yet the conclusion you reached by beta-reduction is false, I believe you have shown that beta-reduction is invalid. That's alright though, I never liked function application much anyway. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Strange memory consumption problems in something that should be tail-recursive
On 2/13/07, Duncan Coutts [EMAIL PROTECTED] wrote: On Tue, 2007-02-13 at 15:27 -0500, Jefferson Heard wrote: Hi, I am running the following code against a 210 MB file in an attempt to determine whether I should use alex or whether, since my needs are very performance oriented, I should write a lexer of my own. I thought that everything I'd written here was tail-recursive Isn't that exactly the problem - that it's tail recursive? You do not want it to be tail recursive since then it must consume the whole input before producing any output. You want it to be as lazy as possible so that it can start producing tokens as soon as possible without having to consume everything. This may be silly of me, but I feel like this is an important point: so you're saying that tail recursion, without strictness, doesn't run in constant space? So for example in the case of, facTail 1 n' = n' facTail n n' = facTail (n-1) (n*n') You'll just be building a bunch of unevaluated thunks until you hit the termination condition? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Strange memory consumption problems in something that should be tail-recursive
On 2/13/07, Bernie Pope [EMAIL PROTECTED] wrote: Creighton Hogg wrote: This may be silly of me, but I feel like this is an important point: so you're saying that tail recursion, without strictness, doesn't run in constant space? It is an important point, and a classic space bug (see foldl in the Prelude). It it not the fault of tail recursion per se, in fact tail recursion is often important in Haskell too. So for example in the case of, facTail 1 n' = n' facTail n n' = facTail (n-1) (n*n') The problem with this example is that it will build up an expression of the form: (n1 * n2 * n3 .) in the second argument. It's size will be proportional to the number of recursive calls made (n). You'll just be building a bunch of unevaluated thunks until you hit the termination condition? To fix it you will want the function to evaluate its second argument eagerly: facTail n n' = facTail (n-1) $! (n*n') Awesome. For a long time now I've been interested in Haskell, and studied it from the math side, but haven't actually really written anything. This mailing list, the wiki, and #haskell are proving to be a great resource. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] pythags
On 2/12/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello, the Advanced Monads page in the Haskell Wikibook (http://en.wikibooks.org/wiki/Haskell/Advanced_monads) contains the following example of a List Monad pythags = do x - [1..] y - [x..] z - [y..] guard (x^2 + y^2 == z^2) return (x, y, z) However, whenever you load that function definition into Hugs or GHCi, you get a message saying that guard is an undefined variable. Does anyone know why? Thanks. phiroc In the context of the tutorial, guard isn't defined until the next section: additive monads. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Optimization fun
On 2/10/07, Matthew Brecknell [EMAIL PROTECTED] wrote: Rafael Almeida said: I've always found the following definition of the sieve of eratosthenes the clearest definition one could write: sieve [] = [] sieve (x:xs) = x : sieve [y | y - xs, y `mod` x /= 0] It doesn't perform better than Augustsson's solution. It does fairly worse, actually, but it performs way better than Hogg's 13s algorithm. It took around 0.1s on my machine. Interesting. I found the sieve to be somewhere around the 13s mark, while Lennart's solution was about 0.15s. But that may just be because I haven't yet made the jump from GHC 6.4.2 to 6.6... I also found that a handcrafted loop-fusion reduced Lennart's solution to 0.08s: primes :: [Int] primes = 2 : filter isPrime [3,5..] where f x p r = x p*p || mod x p /= 0 r isPrime x = foldr (f x) True primes This looks really slick to me, thanks. So if I understand correctly, the main thing that makes this work is that 'ing the test with the accumulator r will make it bail out of the fold as soon as one of the two tests is failed because the result must be False? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Optimization fun
Hello Haskell-ers, So a friend and I were thinking about making code faster in Haskell, and I was wondering if there was a way to improve the following method of generating the list of all prime numbers. It takes about 13 seconds to run, meanwhile my friend's C version took 0.1. I'd love to learn a bit more about how to optimize Haskell code. Cheers, Creighton Hogg -- Naive way to calculate prime numbers, testing each new n to see if it has prime factors less than sqrt(n). import Data.List primes = 2:(foldr (\x y - if isPrime x then x:y else y) [] [3..]) where isPrime x = foldl' (\z y - z (if x `mod` y == 0 then False else True)) True (take (floor $ sqrt $ fromIntegral x) primes) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization fun
On 2/10/07, Lennart Augustsson [EMAIL PROTECTED] wrote: There are many things that makes your code slow. * The default for Haskell is to compute with Integer, not Int. So that makes from Integral and floor very slow. * foldl' is a bad choice, because it is too strict, you want to abort the loop as soon as possible. Now why is foldl' too strict? I don't think I understand? * your take is really wrong. The number of primes you need to take cannot be computed like that. You want to take primes while the sqrt of x is larger than the prime. Yeah, I don't know what the %#*( happened there. I should have proofread. Also, your code is not idiomatic Haskell. Here's a different version: primes :: [Int] primes = 2:filter isPrime [3,5..] where isPrime x = all (\ y - x `mod` y /= 0) $ takeWhile (\ p - p*p = x) primes On Feb 10, 2007, at 21:02 , Creighton Hogg wrote: primes = 2:(foldr (\x y - if isPrime x then x:y else y) [] [3..]) where isPrime x = foldl' (\z y - z (if x `mod` y == 0 then False else True)) True (take (floor $ sqrt $ fromIntegral x) primes) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization fun
On 2/10/07, Creighton Hogg [EMAIL PROTECTED] wrote: On 2/10/07, Lennart Augustsson [EMAIL PROTECTED] wrote: There are many things that makes your code slow. * The default for Haskell is to compute with Integer, not Int. So that makes from Integral and floor very slow. * foldl' is a bad choice, because it is too strict, you want to abort the loop as soon as possible. Now why is foldl' too strict? I don't think I understand? I think I can explain my confusion better. For a finite list, I thought a fold would always pass through the entire list. I take it that what you mean is that, since the fold is over an , then it can bail as soon as it encounters the first false, but it only does that if it's allowed to not be strict. I suppose this reveals my ignorance of how laziness really works. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization fun
On 2/10/07, Peter Berry [EMAIL PROTECTED] wrote: Gah! Gmail has really broken defaults for posting to lists. On 10/02/07, Creighton Hogg [EMAIL PROTECTED] wrote: Hello Haskell-ers, So a friend and I were thinking about making code faster in Haskell, and I was wondering if there was a way to improve the following method of generating the list of all prime numbers. It takes about 13 seconds to run, meanwhile my friend's C version took 0.1. I'd love to learn a bit more about how to optimize Haskell code. Which subproblem takes 13 seconds? (Surely generating a list of all primes will take an infinite amount of time, since there are infinitely many of them?) Apparently I shouldn't send e-mails quickly, as it comes out as gibberish. It was the first 1. The thirteen seconds was just approximate, but it showed the C one was much faster, which I figured was because I had constructed it poorly. Apparently I had, and I even managed to type it in wrong. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Optimization fun
On 2/10/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Creighton Hogg wrote: Hello Haskell-ers, So a friend and I were thinking about making code faster in Haskell, and I was wondering if there was a way to improve the following method of generating the list of all prime numbers. It takes about 13 seconds to run, meanwhile my friend's C version took 0.1. I'd love to learn a bit more about how to optimize Haskell code. Of course, the best optimization is a better algorithm. In case this is what you're after, have a look at Colin Runciman, Lazy Wheel Sieves and Spirals of Primes http://citeseer.ist.psu.edu/runciman97lazy.html snip helpfullness The glitches may have been unintentional, but the flaw intentionally degrades performance: you should not use a strict all' but the lazy all prop = foldr (\y z - prop y z) True from the Prelude. The point is that the lazy version stops inspecting the elements of the remaining list whenever (prop y) turns False for the first time. This is because is lazy: False x = False for whatever x we supply. For example, take the list [True, False, True, True] ++ replicate 100 True Here, all returns False after inspecting the first two elements while all' inspects every one of the 104 list elements just to return False afterwards. As every second number is even, your all' is busy wasting time like crazy. Okay, this is sinking in a good bit better, thank you. I think I've had a conceptual block about what laziness really means. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Picking out elements of a heterogenous list
Hi Haskell-ers, So I think I understand the idea of creating a heterogenous list using typeclasses and existentials, but I don't see how to filter the list to retrieve elements of the list that are of only one type. More concretely, taking the example herehttp://haskell.org/haskellwiki/Existential_typehow could we take a list of shapes [Shape] and pull out all objects that are Squares? I don't see an obvious way this makes sense. Is there a way of doing heterogenous lists that would make this possible? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] More threading confusion
Good afternoon Haskellers,So I'm trying to understand how STM works, and wrote a quick 'eating philosophers' example to see if I understood how it's supposed to work.The problem is that while it executes, it doesn't appear to *do* anything. Did I completely write things wrongheadedly or am I being bitten by something more subtle?Thanks.import Control.Concurrent.STMimport Control.Concurrentimport Data.Arrayimport System.Random think :: IO ()think = do ms - randomRIO (20,1000) threadDelay msdata Philosopher = Philosopher {left::Bool,right::Bool,neighbors::(Int,Int)} deriving ShowmakeInitPhilosopher a = Philosopher {left=False,right=False,neighbors=a} initPhilosophers = listArray (0,4) (map makeInitPhilosopher [(1,4),(2,0),(3,1),(4,2),(0,3)])main = do z - atomically $ newTVar initPhilosophers mapM_ (\x - forkIO (loop x z 0 1)) [0,1,2,3,4]loop n tps c l | c l = (atomically (readTVar tps)) = (\x - print x) | otherwise = dothink atomically $ eat n tps loop n tps (c+1) leat :: Int - TVar (Array Int Philosopher) - STM ()eat n tps = do takeLeft n tps takeRight n tps releaseLeft n tps releaseRight n tpstakeLeft :: Int - TVar (Array Int Philosopher) - STM ()takeLeft n tps = do ps - readTVar tps let p = ps ! n if right (ps ! (fst $ neighbors p)) == False then (writeTVar tps $ ps // [(n,p{left=True})]) else retrytakeRight :: Int - TVar (Array Int Philosopher) - STM ()takeRight n tps = do ps - readTVar tps let p = ps ! n if left (ps ! (snd $ neighbors p)) == False then (writeTVar tps $ ps // [(n,p{right=True})]) else retryreleaseLeft n tps = do ps - readTVar tps let p = ps ! n writeTVar tps $ ps // [(n,p{left=False})] releaseRight n tps = do ps - readTVar tps let p = ps ! n writeTVar tps $ ps // [(n,p{right=False})] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Questions on threads and IO
Hello Haskell'rs, I've been playing with threads and I tried to do a toy example (that used java) from a class. When run, the program should print a prompt and accept commands just like a linux shell. It doesn't have to do anything fancy, just spawn new threads that make system calls when commands are entered at the prompt. The problem is that the UI doesn't work very well. It will seem fine at first, but in order to get back a prompt you have to hit enter one more time than you should. I've tried playing with the buffering settings but it seems to cause the same problem no matter what. The problem seems to be coming from calls of the form (forkIO . system_) ls /usr/bin Just entering this into ghci I get the same thing where I need to hit enter *again* in order to get back to the ghci prompt. I'm sure this is something silly on my part, but it is rather confusing. import Control.Concurrent import System import System.IO main = do putStr z - getLine runCommands z main genWords :: Char - String - [String] genWords c s = gwhelper c s [] [] gwhelper :: Char - String - [String] - String - [String] gwhelper c [] acc temp = acc ++ [(reverse temp)] gwhelper c (x:xs) acc temp | x /= c = gwhelper c xs acc (x:temp) | otherwise = gwhelper c xs (acc++[(reverse temp)]) [] runCommands s = mapM_ (forkIO .system_) (genWords '' s) system_ :: String - IO () system_ s = do system s return () ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Building head numerics project
On 5/5/06, Simon Peyton-Jones [EMAIL PROTECTED] wrote: | in general, it's too complex problem, otherwise Simons may alreadywork| on it, because current ghc-generated code is, say, 3 times slower than| it could be.Thank you for believing in our expertise, but you should not assume that something we have not done is necessarily very difficult.GHC has ahuge surface area these days, so we spend a lot of time just keepingeverything working.Then we are researchers too (e.g. Simon M is on the ICFP program committee) -- maintaining GHC isn't even our real job.As a result there are many not-very-hard jobs that we simply do not getaround to.(I don't know if this is one of them, though.)So I say an enthusiastic Yes to anyone who's willing to jump in and start helping.We need more people familiar with GHC's innards.Well I'm going to take you up on that enthusiastic yes.In order to get familiar with GHC's innards, is there anything particular I should begin with? At the moment I'm just reading through the user's guide. Cheers,Creighton Hogg ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Building head numerics project
Hi,So I'm interested in working on the project on improving numerics performance in GHC proposed on the SoC page herehttp://hackage.haskell.org/trac/summer-of-code/ticket/13 Since I have a full time job, I'd just like to do this on my own time rather than take up an SoC slot.In that vein, Don Stewart suggested that the first thing to do was check out the most recent ghc code from darcs and build it. Well, I've been getting the same problems as herehttp://hackage.haskell.org/trac/ghc/ticket/715and I was wondering if anyone knew of a workaround or if we could figure out an environment set up that *could* build ghc correctly. Thanks,Creighton Hogg ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
[Haskell-cafe] Re: [Haskell] Haskell.org and Google Summer of Code 2006
Well, now that we've started this discussion I presume it's okay if I ask a few things. I don't know if these are good ideas, but I thought I'd throw them out. Basically, I am a student and would be eligible for the SoC. I'd like to work on something related to numerics support or performance in Haskell. Either building on existing gsl bindings, making something out of whole cloth, or spending some intensive work on compiler optimizations. My dream would be to build up enough monte carlo support in haskell that things like high energy physics event simulators could be coded in the language without sacrificing too much performance and having a hundred times the flexibility and *maintainability*. Creighton Hogg On 4/22/06, Paolo Martini [EMAIL PROTECTED] wrote: Hello everybody, nice to meet you all. Last year I did work on an Haskell project during the first year of the Google Summer of Code programme[1]. I wrote the bindings to the Cairo Vector Graphics library and integrated them in Gtk2Hs. You can see last year's announcement on the website[2]. I had to take Google itself as my mentoring organization, in absence of a better-suited one, no wonder I was the only one with an Haskell project, eventually I got one of its 13 slots available -- Chris DiBona[3], the project leader, seem to like Haskell very much! They recently announced they would be running the programme again this year, and I thought we could surely do better! My idea is that the best way we are going to get more Haskell projects done is having Haskell.org as a mentoring organization this year. Let me briefly summarize how the project works; it starts with a number of mentoring organizations that support active open source projects. They are required to publish a list of projects for students to apply for, and some mentors which will take care of the pupils during their work. Part of the fun is of course that the students can propose their own projects too. Each successful applicant gets an initial $500, three months of coding time, a mid- term $2,000 of are doing well and a final $2,000 on successful completion of the project (The site[4] does explain it all.) I contacted many of the people who usually reside in the #haskell IRC channel asking for collaboration, and they promptly accepted, forming a quite big number of well organized people -- as now, those three people are in charge for the administrative work: - Isaac Jones http://www.syntaxpolice.org/, - Donald Bruce Steward http://www.cse.unsw.edu.au/~dons/, - David Himmelstrup http://darcs.haskell.org/~lemmih/aboutMe.html. Not surprisingly, since the people of the channel are known to be very kind and helpful, answering questions at every time of the day, I've got a good number of volunteers for mentoring too (which I'm very happy about): - David Himmelstrup, - John Goerzen http://www.complete.org/, - Cale Gibbard http://www.haskell.org/hawiki/CaleGibbard, - Einar Karttunen http://www.cs.helsinki.fi/u/ekarttun/, - Shae Matijs Erisson http://www.ScannedInAvian.com/, - Duncan Coutts http://haskell.org/gtk2hs/development/. - Andres L\¨oh http://www.iai.uni-bonn.de/~loeh, - Ian Lynagh http://web.comlab.ox.ac.uk/oucl/work/ian.lynagh/, And the list is getting bigger and bigger! Unsure about where to get an authoritative answer about things like this I have mailed Simon Peyton-Jones, he likes the idea (Thanks very much!) He explained to me that since the Haskell community is very decentralized I would better send a message to the Haskell mailing list to propose this project. I hope you will be as enthusisatic as I am. Hacking Haskell code during the summer, funded enough to keep up with the other things (and getting some pretty cool hardware lately), was a *great* experience. I sincerely hope that many students will apply for Haskell works. We need projects done! I'll be mailing you the url of the wikipage collecting projects and details. Thank you very much, Paolo. -- [1] http://code.google.com/summerofcode.html [2] http://haskell.org/gtk2hs/?p=30 [3] http://dibona.com ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Fundeps: I feel dumb
On 13 Apr 2006 03:27:03 -, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Creighton Hogg wrote: No instance for (MatrixProduct a (Vec b) c) arising from use of `*' at interactive:1:3-5 Probable fix: add an instance declaration for (MatrixProduct a (Vec b) c) In the definition of `it': it = 10 * (vector 10 ([0 .. 9])) Let us look at the instance class MatrixProduct a b c | a b - c where (*) :: a - b - c instance (Num a) = MatrixProduct a (Vec a) (Vec a) where it defines what happens when multiplying a vector of some numeric type 'a' by a value _of the same_ type. Let us now look at the error message: (MatrixProduct a (Vec b) c) That is, when trying to compile your expression 10 * (vector 10 ([0 .. 9])) the typechecker went looking for (MatrixProduct a (Vec b) c) where the value and the vector have different numeric types. There is no instance for such a general case, hence the error. It is important to remember that the typechecker first infers the most general type for an expression, and then tries to resolve the constraints. In your expression, 10 * (vector 10 ([0 .. 9])) we see constants 10, 10, 0, 9. Each constant has the type Num a = a. Within the expression 0 .. 9, both 0 and 9 must be of the same type (because [n .. m] is an abbreviation for enumFromThen n m, and according to the type of the latter enumFromThen :: a - a - [a] both arguments must be of the same type). But there is nothing that says that the first occurrence of 10 must be of the same numeric type as the occurrence of 9. So, the most general type assignment will be (Num a = a) for 10, and (Num b = b) for 9. Thank you very much for the explanation: it makes alot of sense. So, if one does not want to for alot of type declarations into the code, which would be fairly awkward, is there a way to do this with fundeps or other type extensions that will be alot prettier or is any way of defining type classes going to run into the same problems? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Fundeps: I feel dumb
Hi, So I'm trying the fun-deps example from http://www.haskell.org/hawiki/FunDeps and seeing if I can use it, but I can't really get things to work the way I want. The code follows below, and the error I get if I try to multiply 10 * (vector 10 [0..9]) is No instance for (MatrixProduct a (Vec b) c) arising from use of `*' at interactive:1:3-5 Probable fix: add an instance declaration for (MatrixProduct a (Vec b) c) In the definition of `it': it = 10 * (vector 10 ([0 .. 9])) import Array -- The elements and the size data Vec a = Vec (Array Int a) Int deriving (Show,Eq) type Matrix a = (Vec (Vec a)) class MatrixProduct a b c | a b - c where (*) :: a - b - c instance (Num a) = MatrixProduct a (Vec a) (Vec a) where (*) num (Vec a s) = Vec (fmap (*num) a) s vector n elms = Vec (array (0,n-1) $ zip [0..n-1] elms) n ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Matching constructors
Hi, If I have something like data Patootie = Pa Int | Tootie Int and I want to pull out the indices of all elements of a list that have type constructor Tootie, how would I do that? I thought I might be able to use findIndices, but I don't know how to express the predicate. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Comment Syntax
On Thu, 2 Feb 2006, Henrik Nilsson wrote: Hi all, To corroborate Wadler's law further. Josef wrote: Oh yes, it does happen that a single line comment begins with a special symbol. It has happened to me on several occations when using haddock annotation to my source code. It is all to easy to forget that extra space. With incomprehensible error messages as a result. But might that not just mean that the error messages ought to be improved? I don't know how hard that would be, but after having played around a bit with GHC, the messages I get are either of the type parse error on input '--|' or of the type Not in scope: `--' (followed by lots of other stuff not being in scope etc). If this really is a big problem for beginners, it would not seem totally infeasible to add some special code that helpfully suggests that a space perhaps ought to be inserted? Or have you seen significantly worse error messages? Well, if anecdotal evidence from a real live beginner would help, I've never had problems with the comments. I think I made that mistake once, looked at the line it failed on, and added the space. ___ Haskell-prime mailing list Haskell-prime@haskell.org http://haskell.org/mailman/listinfo/haskell-prime
[Haskell-cafe] Encapsulation in Haskell
Hi guys, So one of the big things in object oriented programming is encapsulation, and I'm wondering how to do it properly in Haskell. How do you define new data types but minimize the dependence of external packages on the exact nature of the data definition? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Tutorial uploaded
On Wed, 21 Dec 2005, Robin Green wrote: Henning Thielemann wrote: Starting with IO in Haskell is like starting LaTeX with rotating text and making it colorful. Not at all! Indeed IO _is_ complicated regardless of whether it is modelled by Monads in Haskell or differently in other languages. Rubbish! 10 PRINT WHAT IS YOUR NAME? 20 INPUT NAME IO isn't complicated in BASIC. I agree. Not that it's *really* complicated in haskell, though. I think all a tutorial needs to do is explain = means a definition, - means the left side is the result of the right side In order to show that x = getLine means that x is the function getLine while x - getLine means that x is the result of getLine Monads can come *way* later I think, but even then they're not difficult at all. Beginners should start with non-monadic functions in order to later avoid IO in their functions whereever possible. Whilst localising IO to a small part of the program is generally a good idea, beginners should not be scared off by the thought that IO in Haskell is so hard it has to be covered on page 94. This is not the case. It should be introduced on page 1. If people want Haskell to be treated as a practical language, not just something for doing academic teaching and research with, it should be taught as a practical language - which means that things like IO and space/time usage come to the forefront. I agree with this wholeheartedly. When I first started playing with Haskell, some of the tutorials made it look like it was very difficult to do anything practical with it because doing real input and output seemed like an advanced topic. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Functions with side-effects?
On Wed, 21 Dec 2005, Daniel Carrera wrote: Hi all, I'm a Haskell newbie and I don't really understand how Haskell deals with functions that really must have side-effects. Like a rand() function or getLine(). I know this has something to do with monads, but I don't really understand monads yet. Is there someone who might explain this in newbie terms? I don't need to understand the whole thing, I don't need a rand() function right this minute. I just want to understand how Haskell separates purely functional code from non-functional code (I understand that a rand() function is inevitably not functional code, right?) Well, it's *all* functional fundamentally but when people say non-functional in relation to Haskell code what they mean is in a monad. Monads, I believe, can be just thought of as containers for state. So like I said in an e-mail on the tutorial thread the only distinction you need to make is between = which is truly a statement of definition and not subject to change, and - which says that the left hand side is the result of the action of the right hand side. In terms of types, - strips away the monadic type. Note for example that if you want your main program to take in a string and then print it to the screen, it is *NOT* main = putStrLn . getLine (which was I first thought) or main = putStrLn (getLine) (which you might guess from the type sig) but rather main = do x - getLine putStrLn x Because you want putStrLn to act on the string that *resulted* from getLine, and not on getLine itself. I'd check out this link from HaWiki on monads, http://haskell.org/hawiki/MonadsAsContainers ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Tutorial uploaded
On Wed, 21 Dec 2005, Henning Thielemann wrote: On Wed, 21 Dec 2005, Creighton Hogg wrote: I agree with this wholeheartedly. When I first started playing with Haskell, some of the tutorials made it look like it was very difficult to do anything practical with it because doing real input and output seemed like an advanced topic. The drawback is that I saw many Haskell programs implemented with IO read/write functions which could be easily implemented without IO, using laziness. Can you think of any examples of things like that? Given that I'm still learning how to take advantage of laziness it'd be pretty interesting. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Functions with side-effects?
On Wed, 21 Dec 2005, Daniel Carrera wrote: Thanks for all the help. I think things are much clearer now. And this bit: main = do putStrLn Hello, what is your name? name - getLine putStrLn (Hello, ++ name ++ !) Looks quite straight forward. I just wrote my very first IO program with Haskell: --//-- main = do x - getLine putStrLn( show(length x) ) --//-- That's not so scary. The next thing I need to figure out is how to act on the input data itself (not just its length). For example, if I wanted a program to output the nth element of the fibonacci sequence: --//-- $ ./fib 12 144 --//-- My first inclination would be to write it as: --//-- main = do x - getLine putStrLn( show(fib x) ) --//-- Of course that won't work because x is an IO String and 'fib' wants an Int. To it looks like I need to do a conversion IO a - b but from what Cale said, that's not possible because it would defeat the referential transparency of Haskell. x is a String, getLine has type IO String. That's what I was getting at in one of my last e-mails. So you just need something that can read in a string and convert it to an int. Something like let y = (read x) putStrLn $ show $ fib y should work, yes? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Functions with side-effects?
On Wed, 21 Dec 2005, Daniel Carrera wrote: Creighton Hogg wrote: x is a String, getLine has type IO String. That's what I was getting at in one of my last e-mails. Hmm... let's see if I understand: * getLine() has type IO String. * The - will convert an IO String to a plain String * So if I do x - getLine() then x has the type String. So, the - effectively ammounts to an IO a - a conversion. Yeah, pretty much. You're saying that x is the result of action getLine, and in terms of types it means you're getting the a out of m a. In another email John Hughes said that one could think of IO a as a set of instructins for obtaining a. I guess that means that IO is a sort of imperative layer that helps the purely functional code interact with the outside world. So I can have an IO bit (e.g. a do-block) that calls functions (which are purely functional code) but I can't have a function that executes any IO. For example, it is not possible to write a function my_read_file that could work like this: my_data = my_read_file(my_file.txt) Correct? Otherwise this would be a function that is not referentially transparent. Assuming I understand correctly, then you are right. = implies definition. my_data is the symbol assigned to the result of a computation, not a defined constant or function. That's at least how I think of referential transparency. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: problems with square roots...
On Wed, 21 Dec 2005, Scherrer, Chad wrote: From: Daniel Carrera [EMAIL PROTECTED] Hey, The sqrt function is not doing what I want. This is what I want: round sqrt(2) --- Daniel, A lot of Haskell folks like to avoid parentheses as much as possible, and there's a really convenient way to do this. There is a Prelude function ($) f x = f x which is right-associative, so you can write round $ sqrt x == round (sqrt x) This becomes really convenient when multiple application is involved: print $ round $ sqrt x == print (round (sqrt x)) Doesn't it sometimes feel like the $ operator is Haskell's way of saying We're not with those Lisp guys, seriously? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Learning about haskell compilers
Hi guys, I was wondering where I should get started in learing about how to implement a haskell compiler? Are there papers, wiki entries, or other things people think would be helpful or should I just start looking at the source of one of the compilers? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Learning about haskell compilers
On Tue, 20 Dec 2005, John Meacham wrote: On Tue, Dec 20, 2005 at 10:36:36AM -0600, Creighton Hogg wrote: I was wondering where I should get started in learing about how to implement a haskell compiler? Snip Absolute Awesomeness Wow! That was a great response, with more references than I could have ever hoped for. I am totally saving that e-mail. I have learned the basics of compilers. I just finished a class on it that I took basically for the purpose of being able to work on a functional language like haskell. I really want to be able to help with all the work in Haskell and help improve both its performance and capabilities. Haskell lisp are the two languages I love most and I really want to be able to use them in my own native land of physics. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell School of Expression?
Hi, Has anyone recently tried to install the graphics libraries included on http://haskell.org/soe/software.htm ? I've tried to make the libraries, but I get these errors. make: Entering directory `/home/wchogg/coding/haskell/GraphicsLib/lib/x11' ffihugs +G +LX_stub_ffi.c X.hs Warning: unknown toggle `G'; ignoring. Warning: unknown toggle `L'; ignoring. runhugs: Unable to initialise Hugs (Unrecognised option ) I honestly can't figure out what the incompatibility is? I'm using version 20050308 of Hugs ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell] Making Haskell more open
On Fri, 11 Nov 2005, Gour wrote: Wolfgang Jeltsch ([EMAIL PROTECTED]) wrote: The advantage of newsgroups over mailing lists is that newsgroups are designed for discussions among several people and therefore newsgroup software supports this kind of usage very well while mailing lists are actually a hack. I do not follow newgroups, but can you please explain a bit what features are in newsgroup software that support this kind of discussion, which are missing in the mailing lists? (Pls. do not see this as a provocation, I'm realy interested to hear.) Well, you don't have to be registered to post on it, which is actually rather nice. Also, I think the archiving would work better. The current Haskell mailing list archives don't seem to run very fast. If it was a newsgroup, then you could use google groups to browse through old messages. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell-cafe] Monads as control structures?
Hi, so I'm a newbie getting used to Haskell. I'm writing some simple things like genetic algorithms in it for practice, and I keep coming across something that really bugs me: are there any standard libraries that allow you to do imperative style for or while loops using monads to keep track of state? I know there's things like until, but honestly that's not quite what I'm looking for. I just think there should be a simple way to say execute this block of code 10 times without having to wrap it up in recursion. Haskell seems to me to be a very powerful language, and it looks like it should be possible to define control structures such as for loops using monads. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Monads as control structures?
On Thu, 27 Oct 2005, Creighton Hogg wrote: On Thu, 27 Oct 2005, Robert Dockins wrote: On Oct 27, 2005, at 11:54 AM, Creighton Hogg wrote: Hi, so I'm a newbie getting used to Haskell. I'm writing some simple things like genetic algorithms in it for practice, and I keep coming across something that really bugs me: are there any standard libraries that allow you to do imperative style for or while loops using monads to keep track of state? One way is to create a list of the actions you want to execute, and then use one of the sequence family of functions. The actions can share state with an IORef or STRef or whatever. Another option is to use a fold with = to allow actions to pass their results directly to the next action. This works even in stateless monads like the list monad. Some examples using sequence: forMonad :: Monad m = a - (a - Bool) - (a - a) - (a - m ()) - m () forMonad init cond inc f = sequence_ $ map f $ takeWhile cond $ iterate inc init xTimes :: Monad m = Int - (Int - m ()) - m () xTimes x f = sequence_ $ map f [0..(x-1)] main = do { forMonad 0 (10) (+1) (putStrLn . show); xTimes 10 (\_ - putStrLn hi) } Thanks to all who answered, this gives me a lot to chew on. I especially like these examples, because it makes me realize that I've been thinking about monads and evaluation wrong. I think doing genetic programming in Haskell is going to be easier than I thought. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe