[Haskell-cafe] Re: Cyclic data declarations
Michal D. wrote: I'm in the process of writing a toy compiler but I'm having some trouble trying to make my datatypes general. For example, using parsec I parse statements as: data Stmt = SIf Test [Stmt] [Stmt] | ... However, when it's time to create a control flow graph it would be nice to represent statements as (the Int's signify the node id's for either case of the if statement): data Stmt = SIf Test Int Int | ... (I recommend to replace Int with something more descriptive, like type Id = Int ) So, in a eureka moment I decided that this should be allowable with the following declaration: data Stmt link = SIf Test link link | ... Ofcourse, the problem is trying to declare the resulting type for parsing: parse - Stmt [Stmt [Stmt ]]. Any hints on whether there is a way to accomplish what I'm trying to do or do I have to bite the bullet and declare two seperate datatypes? I tried being clever and declaring a 'helper' type as type StmtRec = Stmt [StmtRec] but to no avail... GHC won't let it slide: Cycle in type synonym declarations! newtype StmtRec = StmtRec (Stmt [StmtRec]) will do. More generally, you can use newtype Fix f = In { out :: f (Fix f) } and define type StmtRec = Fix ([] `O` Stmt) where O denotes composition of functors newtype O f g a = O (f (g a)) Introducing a parameter in Stmt like you did and tying the recursion afterwards is a known technique, but I can't seem to find a wiki page that concisely explains it right now. Regards, apfelmus -- http://apfelmus.nfshost.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Heap profiling project update
Hi all, It's been a while since I announced anything about the project on the list, but I've been regularly posting about it on my blog [1]. Everyone should feel encouraged to check out the cabalised code [2] and play with it, stress test it. Adventurous ones can also look at the source. ;) Gergely [1] http://just-bottom.blogspot.com/ [2] http://code.google.com/p/hp2any/source/checkout -- http://www.fastmail.fm - Send your email first class ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] funct.prog. vs logic prog., practical Haskell
are you a student (undergrad or grad) or faculty (junior or senior)? These are all very different scenarios and accordingly different goals are realistic. For example, if you're a student, it might be more realistic to start with finding a professor who will be willing to supervise an independent study class. On Sun, Aug 2, 2009 at 6:25 AM, Petr Pudlak d...@pudlak.name wrote: Hi all, I'd like to convince people at our university to pay more attention to functional languages, especially Haskell. Their arguments were that (1) Functional programming is more academic than practical. (2) They are using logic programming already (Prolog); why is Haskell better than Prolog (or generally a functional language better than a logic programming language)? (1) is easier to answer, there are a lots of applications at HaskellWiki, or elsewhere around the Internet, written in Haskell, OCaml, etc. Still, I welcome comments on your experience, for example, if you have written some larger-scale application in Haskell (or another a functional language) that is not at HaskellWiki, and perhaps if/why you would recommend doing so to other people. (2) is harder for me, since I've never programmed in Prolog or another language for logic programming. I'd be happy if anyone who is experienced in both Prolog and Haskell could elaborate the differences, pros cons etc. Thanks, Petr ___ 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] funct.prog. vs logic prog., practical Haskell
On Sun, Aug 02, 2009 at 08:36:27AM -0400, Carter Schonwald wrote: are you a student (undergrad or grad) or faculty (junior or senior)? These are all very different scenarios and accordingly different goals are realistic. I'm a faculty member (postdoc). I've been working in the field of automated theorem proving, but for about a year I'm also very interested in Haskell and in general in the theory behind functional languages. Since I find FP to be a very important programming concept, I'd like to achieve that we start teaching it at the university. Petr ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] funct.prog. vs logic prog., practical Haskell
Have you considered say proposing a class on theorem proving that uses coq? www.*coq*.inria.fr http://www.coq.inria.fr . Such a class would entail teaching how to program using the coq term language, which is itself a pure functional language, albeit one with some restrictions related to everything impure. As a matter of course in such a class you would naturally also mention that there are languages such as haskell which lack such restrictions/ have clever ways around them. -Carter On Sun, Aug 2, 2009 at 8:52 AM, Petr Pudlak d...@pudlak.name wrote: On Sun, Aug 02, 2009 at 08:36:27AM -0400, Carter Schonwald wrote: are you a student (undergrad or grad) or faculty (junior or senior)? These are all very different scenarios and accordingly different goals are realistic. I'm a faculty member (postdoc). I've been working in the field of automated theorem proving, but for about a year I'm also very interested in Haskell and in general in the theory behind functional languages. Since I find FP to be a very important programming concept, I'd like to achieve that we start teaching it at the university. Petr ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] funct.prog. vs logic prog., practical Haskell
That's actually a good idea. I haven't considered this alternative so far, probably because I have always been working with first-order theorem provers. But I guess eventually I'll merge my interests in ATP and FP and start doing some serious work with higher-order theorem provers like coq or Isabelle. Petr On Sun, Aug 02, 2009 at 09:03:14AM -0400, Carter Schonwald wrote: Have you considered say proposing a class on theorem proving that uses coq? www.coq.inria.fr . Such a class would entail teaching how to program using the coq term language, which is itself a pure functional language, albeit one with some restrictions related to everything impure. As a matter of course in such a class you would naturally also mention that there are languages such as haskell which lack such restrictions/ have clever ways around them. -Carter On Sun, Aug 2, 2009 at 8:52 AM, Petr Pudlak d...@pudlak.name wrote: I'm a faculty member (postdoc). I've been working in the field of automated theorem proving, but for about a year I'm also very interested in Haskell and in general in the theory behind functional languages. Since I find FP to be a very important programming concept, I'd like to achieve that we start teaching it at the university. Petr ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] IFL 2009: Call for Papers and Participation
Call for Papers and ParticipationIFL 2009Seton Hall UniversitySOUTH ORANGE, NJ, USAhttp://tltc.shu.edu/blogs/projects/IFL2009/Register at: http://tltc.shu.edu/blogs/projects/IFL2009/registration.html* NEW *Registration and talk submission extended to August 23, 2009! ***The 21st International Symposium on Implementation and Application of Functional Languages, IFL 2009, will be held for the first time in the USA. The hosting institution is Seton Hall University in South Orange, NJ, USA and the symposium dates are September 23-25, 2009. It is our goal to make IFL a regular event held in the USA and in Europe. The goal of the IFL symposia is to bring together researchers actively engaged in the implementation and application of functional and function-based programming languages. IFL 2009 will be a venue for researchers to present and discuss new ideas and concepts, work in progress, and publication-ripe results related to the implementation and application of functional languages and function-based programming.Following the IFL tradition, IFL 2009 will use a post-symposium review process to produce a formal proceedings which will be published by Springer in the Lecture Notes in Computer Science series. All participants in IFL 2009 are invited to submit either a draft paper or an extended abstract describing work to be presented at the symposium. These submissions will be screened by the program committee chair to make sure they are within the scope of IFL and will appear in the draft proceedings distributed at the symposium. Submissions appearing in the draft proceedings are not peer-reviewed publications. After the symposium, authors will be given the opportunity to incorporate the feedback from discussions at the symposium and will be invited to submit a revised full arcticle for the formal review process. These revised submissions will be reviewed by the program committee using prevailing academic standards to select the best articles that will appear in the formal proceedings.Invited Speaker: Benjamin C. Pierce University of Pennsylvania Talk Title: How To Build Your Own Bidirectional Programming LanguageTOPICSIFL welcomes submissions describing practical and theoretical work as well as submissions describing applications and tools. If you are not sure if your work is appropriate for IFL 2009, please contact the PC chair at ifl2...@shu.edu. Topics of interest include, but are not limited to:language concepts type checking contractscompilation techniques staged compilationruntime function specializationruntime code generation partial evaluation (abstract) interpretation generic programming techniques automatic program generation array processing concurrent/parallel programming concurrent/parallel program execution functional programming and embedded systems functional programming and web applications functional programming and security novel memory management techniques runtime profiling and performance measurements debugging and tracing virtual/abstract machine architectures validation and verification of functional programs tools and programming techniques FP in EducationPAPER SUBMISSIONSProspective authors are encouraged to submit papers or extended abstracts to be published in the draft proceedings and to present them at the symposium. All contributions must be written in English, conform to the Springer-Verlag LNCS series format and not exceed 16 pages. The draft proceedings will appear as a technical report of the Department of Mathematics and Computer Science of Seton Hall University.IMPORTANT DATESRegistration deadline August 15, 2009Presentation submission deadline August 15, 2009IFL 2009 Symposium September 23-25, 2009Submission for review process deadline November 1, 2009Notification Accept/Reject December 22, 2009Camera ready version February 1, 2010PROGRAM COMMITTEEPeter Achten University of Nijmegen, The NetherlandsJost Berthold Philipps-Universität Marburg, GermanyAndrew Butterfield University of Dublin, IrelandRobby Findler Northwestern University, USAKathleen Fisher ATT Research, USACormac Flanagan University of California at Santa Cruz, USAMatthew Flatt University of Utah, USAMatthew Fluet Toyota Technological Institute at Chicago, USADaniel Friedman Indiana University, USAAndy Gill University of Kansas, USAClemens Grelck University of Amsterdam/Hertfordshire, The Netherlands/UKJurriaan Hage Utrecht University, The NetherlandsRalf Hinze Oxford University, UKPaul Hudak Yale University, USAJohn Hughes Chalmers University of Technology, SwedenPatricia Johann University of Strathclyde, UKYukiyoshi Kameyama University of Tsukuba, JapanMarco T. Morazán (Chair) Seton Hall University, USARex Page University of Oklahoma, USAFernando Rubio Universidad Complutense de Madrid, SpainSven-Bodo Scholz University of Hertfordshire, UKManuel Serrano INRIA Sophia-Antipolis, FranceChung-chieh Shan Rutgers University, USADavid Walker Princeton University, USAViktória Zsók Eötvös Loránd
[Haskell-cafe] Writing a pnm file
Hi, Now that I've understood how to generate raster points of a line in Haskell - the next thing I want to do is generate a pnm file with it. I've done it in perl as of now. In perl, I can have a scalar variable $x contain a string of 256*256*3 bytes (for 24-bit 256x256 image) and set pixels using substr on LHS. I was wondering how I could do something similar in Haskell? sub setPixel{ my($x,$y,$red,$green,$blue)=...@_; my$pixel=pack CCC,$red,$green,$blue; my$offset=$WIDTH*$y*3 + $x*3; substr($image,$offset,3) = $pixel; } Regards, Kashyap ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Writing a pnm file
On Sun, Aug 2, 2009 at 4:00 PM, CK Kashyap ck_kash...@yahoo.com wrote: Hi, Now that I've understood how to generate raster points of a line in Haskell - the next thing I want to do is generate a pnm file with it. I've done it in perl as of now. In perl, I can have a scalar variable $x contain a string of 256*256*3 bytes (for 24-bit 256x256 image) and set pixels using substr on LHS. I was wondering how I could do something similar in Haskell? sub setPixel{ my($x,$y,$red,$green,$blue)=...@_; my$pixel=pack CCC,$red,$green,$blue; my$offset=$WIDTH*$y*3 + $x*3; substr($image,$offset,3) = $pixel; } There's a library on hackage which does this http://hackage.haskell.org/package/ppm You can install this by doing cabal install ppm Here's an example usage (this uses the binary version of ppm, the docs for ppm has an example for the ASCII version): writePPM fname img = withBinaryFile fname WriteMode (\h - hPutStr h (ppm_p6 img) ) If you're looking for the learning experience, you could always read the source for the library (which is pretty tiny). -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] funct.prog. vs logic prog., practical Haskell
On Sun, Aug 2, 2009 at 12:25, Petr Pudlakd...@pudlak.name wrote: Hi all, I'd like to convince people at our university to pay more attention to functional languages, especially Haskell. Their arguments were that (1) Functional programming is more academic than practical. Which, even if it were true, is an argument *for* instead of *against* teaching it at a university; that is what the word academic means, after all... Thomas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] funct.prog. vs logic prog., practical Haskell
On Sun, 2009-08-02 at 12:25 +0200, Petr Pudlak wrote: (2) is harder for me, since I've never programmed in Prolog or another language for logic programming. I'd be happy if anyone who is experienced in both Prolog and Haskell could elaborate the differences, pros cons etc. I have done some real-world programming in Prolog and SML. The conventional wisdom in the LP community seems to be that the primary path to performance improvement of logic programs is by reduction of non-determinism. To a first approximation, when you have eliminated all the non-determinism from a logic program what you have left is a functional program. The work I was involved with, trying to get quasi-real-time performance from Prolog, bore this out. -- Bill Wood ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re[2]: [Haskell-cafe] funct.prog. vs logic prog., practical Haskell
Hello Bill, Monday, August 3, 2009, 12:01:27 AM, you wrote: I have done some real-world programming in Prolog and SML. The conventional wisdom in the LP community seems to be that the primary path to performance improvement of logic programs is by reduction of non-determinism. and the primary way to make haskell program faster is to emulate imperative language. and the best way to optimize C program is to use it as cpu-independent assembler. it's all natural in von-Neumann world and i personally don't buy these as arguments against everything developed since 1956 actually it supports their's POV: LP is an FP plus non-determinism so why buy a part instead of whole thing? if they need to teach students how to optimize programs, Haskell will be out of luck anyway -- Best regards, Bulatmailto:bulat.zigans...@gmail.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: The Haskell Platform 2009.2.0.2
andrewcoppin: Don Stewart wrote: We're pleased to announce the third release of the Haskell Platform: a single, standard Haskell distribution for everyone. The specification, along with installers (including Windows and Unix installers for a full Haskell environment) are available. Download the Haskell Platform 2009.2.0.2: http://hackage.haskell.org/platform/ Maybe I'm being dense... Is there somewhere which lists what's changed from the last release? Oh, sorry, that will be in the web announcement tomorrow. Essentially, * GHC 6.10.4 * network upgraded to 2.2.1.4 * Improvements to the MacOSX installer * Improvements to crazy popular Windows installer * Significant improvements in Debian support for Haskell * Gentoo now has full support for the Haskell Platform ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: The Haskell Platform 2009.2.0.2
On Mon, Aug 3, 2009 at 1:41 AM, Don Stewart d...@galois.com wrote: * Improvements to crazy popular Windows installer Are you kidding or are indeed many Windows users playing with Haskell these days? Cheers, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: The Haskell Platform 2009.2.0.2
bugfact: On Mon, Aug 3, 2009 at 1:41 AM, Don Stewart d...@galois.com wrote: * Improvements to crazy popular Windows installer Are you kidding or are indeed many Windows users playing with Haskell these days? No, literally, http://donsbot.wordpress.com/2009/07/26/haskell-platform-progress-report/ From the first few minutes of the release, downloads of the various windows installer were running at many times the rate as that for other platforms (there had until now been no single Haskell package for Windows, after all). This surprised us. By the end of July 2009, 90 days later, there had been: * 114,790 downloads of the Windows installer (!!) * 2,790 installs of the generic unix source tarball (complementing the packages provided on each distro). On June 1, the Mac OSX package went live, complementing the MacPorts GHC version. * 1,300 installs of the Mac OSX package. Since that was published there have been another 13.9k downloads of the Windows installer -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] funct.prog. vs logic prog., practical Haskell
On Sun, Aug 2, 2009 at 6:25 AM, Petr Pudlak d...@pudlak.name wrote: Hi all, I'd like to convince people at our university to pay more attention to functional languages, especially Haskell. Their arguments were that (1) Functional programming is more academic than practical. (2) They are using logic programming already (Prolog); why is Haskell better than Prolog (or generally a functional language better than a logic programming language)? Why can't a language be both? Get them to take a look at Mercury, which is *both* a logic programming language *and* a (strict) functional programming language, with Haskell-style type-classes and Clean-style uniqueness types. Mercury has been described as Prolog for serious software engineers. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANN: yst 0.2.1
I'm pleased to announce the release of yst, now available on HackageDB. yst generates static websites from YAML or CSV data files and StringTemplates. This approach combines the speed, security, and ease of deployment of a static website with the flexibility and maintainability of a dynamic site that separates presentation and data. The easiest way to get a feel for yst is to try it: cabal update cabal install yst yst create testsite cd testsite yst yst attempts to fill a niche between two kinds of site creation tools. On the one hand you have simple static site generators like webgen, webby, nanoc, and my old custom system using make and pandoc. On the other hand, you have dynamic web frameworks like rails and django. For my own smallish websites, I found that the dynamic frameworks were overkill. Nobody but me was going to edit the pages, and I didn't want the trouble of writing and deploying a dynamic site, setting up a web server, and administering a database. A static site would be faster, easier to deploy, and more secure. But the dynamic frameworks offered one thing that the static site generators did not: an easy way to separate data from presentation. This was becoming increasingly important to me as I found myself constantly updating the same information (say, publication data for a paper) in multiple places (say, a LaTeX CV and a differently formatted web listing of papers). What I wanted was a site generation tool that used YAML text files as a database and allowed different kinds of documents to be produced from the same data. I couldn't find anything that did just what I wanted, so I wrote yst. By way of illustration, here are the build instructions for HTML and LaTeX versions of a CV, plus a web page with a list of papers: - url: cv.html title: CV template: cv.st data_common: cvdata contact: from contact.yaml jobsbyemployer: from jobs.yaml order by start group by employer degrees: from degrees.yaml order by year desc awards: from awards.yaml order by year desc group by title papers: from papers.yaml order by year desc where (not (type = 'review')) reviews: from papers.yaml order by year desc where type = 'review' talks: from talks.yaml where date '2009-09-01' order by date desc group by title dissertations: from dissertations.yaml order by role then year group by role theses: from theses.yaml order by year then student courses: from courses.yaml order by number group by title data: : *cvdata html: yes - url: cv.tex title: CV inmenu: no template: cv.st layout: layout.tex.st data: : *cvdata html: yes - url: papers.html title: Papers template: papers.st data: papersbyyear: from papers.yaml order by year desc then title group by year yst's query language is limited, and there are lots of things you can do with a full-fledged database that you can't do with yst. But yst is ideal, I think, for small to medium data-driven sites that are maintained by a single person who likes working with plain text. It scratched my itch, anyway, and I release it in case anyone else has the same itch. Code, documentation, and bug reports: http://github.com/jgm/yst/tree/master John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Cyclic data declarations
newtype StmtRec = StmtRec (Stmt [StmtRec]) That's pretty much were I threw in the towel last night. Except I had a bunch of places where I had to add the extra constructor statements. I wish there was a solution that didn't require these... they really butcher pattern matching clarity. will do. More generally, you can use newtype Fix f = In { out :: f (Fix f) } and define type StmtRec = Fix ([] `O` Stmt) where O denotes composition of functors newtype O f g a = O (f (g a)) Thanks for that! This provoked some thought on my part about what exactly is going on. I think I could solve this if I added some way to identify that a type parameter is actually referring to the whole type. Say we had a reserved word fixpoint for this. Then we'd have something like: data Stmt x = SIf x x then when we actually go to use it, it would be referred to as the type: Stmt [fixpoint] Which would get treated exactly like the data declaration: data Stmt = SIf [Stmt] [Stmt] I'll need to add the newtype declaration for the code but I'd be interested if anyone had further thoughts on this topic. I have an implementation of both approaches on a toy parser, but I doubt anyone's interested in seeing that. Michal ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] funct.prog. vs logic prog., practical Haskell
I would have thought that a major motivation for the study of haskell,or for that matter ML, Clean, would be their type systems: statically typed higher order parametric polymorphism which is certainlly different enough from that of prolog to warrant study. So from the perspective of type systems and associated gaurantees functional programming languages probably represent the best environment in which to study these concepts. - Original Message - From: Petr Pudlak d...@pudlak.name To: Haskell Cafe haskell-cafe@haskell.org Sent: Sunday, August 02, 2009 8:25 PM Subject: [Haskell-cafe] funct.prog. vs logic prog., practical Haskell Hi all, I'd like to convince people at our university to pay more attention to functional languages, especially Haskell. Their arguments were that (1) Functional programming is more academic than practical. (2) They are using logic programming already (Prolog); why is Haskell better than Prolog (or generally a functional language better than a logic programming language)? (1) is easier to answer, there are a lots of applications at HaskellWiki, or elsewhere around the Internet, written in Haskell, OCaml, etc. Still, I welcome comments on your experience, for example, if you have written some larger-scale application in Haskell (or another a functional language) that is not at HaskellWiki, and perhaps if/why you would recommend doing so to other people. (2) is harder for me, since I've never programmed in Prolog or another language for logic programming. I'd be happy if anyone who is experienced in both Prolog and Haskell could elaborate the differences, pros cons etc. Thanks, Petr ___ 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] ANN: atom 0.1.0
Hi Thomas, No, unfortunately the documentation is limited to the sparse Haddock comments. We intend to assemble more detailed examples, but our program is consuming all our time at the moment. With the limited documentation, frankly I was a bit surprised folks where able to pick it up and run with it. Don, I'm eagerly awaiting a Galois tech talk. Though Haskell is well entrenched in my group, it has yet to spread to other programs in the company despite our best marketing efforts. Sometimes it helps if words of wisdom come from the outside. -Tom On Fri, Jul 31, 2009 at 4:33 PM, Thomas DuBuissonthomas.dubuis...@gmail.com wrote: Tom, I was asking earlier about any good sources of information for atom. It seems the once-good wiki is gone - are there tutorials for Atom hiding in forgotten corners? Thomas On Fri, Jul 31, 2009 at 1:49 PM, Tom Hawkinstomahawk...@gmail.com wrote: Atom is a Haskell DSL for hard realtime applications. This release includes support for assertions and functional coverage to aid simulation and testing. The rev of the minor version indicates a bit of library stability. This is the version we're using for our application, which officially went into production and hit the road last month -- literally. http://hackage.haskell.org/package/atom -Tom ___ 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] Writing a pnm file
Thanks Sebastian, ppm module is indeed very useful. So, I guess my question then just boils down to, how can I write a function to mimic the setPixel function - Basically, a blank white image would look like this (as per ppm module) [ [ (255, 255, 255) , (255, 255, 255) , (255, 255, 255) ] , -- 3 columns of row 1 [ (255, 255, 255) , (255, 255, 255) , (255, 255, 255) ]--- 3 columns of row 2 ] setPixel x y r g b when called like this - setPixel 0,0,255,0,0 [ [ (255, 0, 0) , (255, 255, 255) , (255, 255, 255) ] , -- 3 columns of row 1 [ (255, 255, 255) , (255, 255, 255) , (255, 255, 255) ]--- 3 columns of row 2 ] What would be a good way to implement such a function? Regards, Kashyap From: Sebastian Sylvan sebastian.syl...@gmail.com To: CK Kashyap ck_kash...@yahoo.com Cc: haskell-cafe@haskell.org Sent: Sunday, August 2, 2009 9:30:08 PM Subject: Re: [Haskell-cafe] Writing a pnm file On Sun, Aug 2, 2009 at 4:00 PM, CK Kashyap ck_kash...@yahoo.com wrote: Hi, Now that I've understood how to generate raster points of a line in Haskell - the next thing I want to do is generate a pnm file with it. I've done it in perl as of now. In perl, I can have a scalar variable $x contain a string of 256*256*3 bytes (for 24-bit 256x256 image) and set pixels using substr on LHS. I was wondering how I could do something similar in Haskell? sub setPixel{ my($x,$y,$red,$green,$blue)=...@_; my$pixel=pack CCC,$red,$green,$blue; my$offset=$WIDTH*$y*3 + $x*3; substr($image,$offset,3) = $pixel; } There's a library on hackage which does this http://hackage.haskell.org/package/ppm You can install this by doing cabal install ppm Here's an example usage (this uses the binary version of ppm, the docs for ppm has an example for the ASCII version): writePPM fname img = withBinaryFile fname WriteMode (\h - hPutStr h (ppm_p6 img) ) If you're looking for the learning experience, you could always read the source for the library (which is pretty tiny). -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe