lack of automatic recompilation after library updating
Hello glasgow-haskell-bugs, i just reinstalled FPS library with new version downloaded via darcs (both old and new versions are 0.7, difference is few days only) i run the following to update lib: runghc Setup.hs unregister runghc Setup.hs clean runghc Setup.hs build runghc Setup.hs install and then i try to rebuild my app. it does not feels that FPS library was updated and don't recompiled modules that use it. can this be considered as bug? ghc 6.4.2/windows -- Best regards, Bulat mailto:[EMAIL PROTECTED] ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #795: ghc-6.5.20060607: panic! (the 'impossible' happened) ... initC: srt
#795: ghc-6.5.20060607: panic! (the 'impossible' happened) ... initC: srt +--- Reporter: [EMAIL PROTECTED] | Owner: Type: bug| Status: new Priority: normal | Milestone: Component: Compiler |Version: 6.5 Severity: normal | Resolution: Keywords: | Os: Linux Difficulty: Unknown| Architecture: x86 +--- Comment (by [EMAIL PROTECTED]): I also verified that the code in question compiles without incident with 6.4.2. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/795 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
External Core: %local tag
Hello, this is not really a bug-report. I'm currently busy with some programming involving hcr files. I noticed that GHC does not make use of the %local-tag as it is specified in An External Representation for the GHC Core Language (DRAFT for GHC5.02) on page 3. I'd be very grateful if anyone who feels competent/responsible fixed this. If demanded, I'd submit a patch for this, but actually I don't yet feel worthy modifying the glorious Glasgow Haskell Compiler. Regards Jan ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
[GHC] #796: Literate pre-processor fails to see end of code in LaTeX
#796: Literate pre-processor fails to see end of code in LaTeX -+-- Reporter: Adam |Owner: Type: bug | Status: new Priority: normal|Milestone: Component: Compiler | Version: 6.4.2 Severity: normal| Keywords: Literate pre-processor latex Os: Windows | Difficulty: Unknown Architecture: x86 | -+-- Using the code environment in a LaTeX document to place Haskell source, if trying to read the file, the Literate pre-processor fails to see the \end{code} tag, as in the following example: \begin{code} module Main where main = do someStuff \end{code} -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/796 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [Haskell] STM applications and examples?
On 6/13/06, Simon Marlow [EMAIL PROTECTED] wrote: Hi Folks, I'm interested in gathering information about existing STM applications and example code that people might be working on or have lying around. It would be great to maintain a list of such applications and example code on the wiki somewhere, and use it as a resource for learning STM and research into STM implementations. If you have an application using STM, please let us know. If you can supply the code, even better. Similarly if you have some STM code that might be suitable as samples or benchmarks, we'd love to collect it. Conjure (a bittorrent client) is using STM quite heavily. It isn't usable as a whole but it has some interesting parts. Darcs repository: http://darcs.haskell.org/~lemmih/conjure/ -- Friendly, Lemmih ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
installing a Cabal package non-exposed
Hi, how can install a Cabal package hidden directly? Currently I simply install it and have to hide it afterwards, manually. (Meanwhile one could get a conflict with new exposed modules.) I've tried ./setup register --gen-script and edit the file register.sh, but that does not install the .a file. Thanks Christian ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Any way to catch runtime errors in a DLL?
Simon Marlow wrote: Michael Marte wrote: if a runtime error occurs inside a DLL compiled by ghc (like irrefutable pattern match failed or exceptions caused by error), the application that called the DLL function dies. This is ok for development but unacceptable when it happens with a user sitting in front of the display. (It has not yet happened but it's only a question of time.) So my question is: Is there any way to catch and process runtime errors? I am looking for some way to map those errors to exceptions on the C++ side that can be caught if required. It would be ok to kill the Haskell runtime system and unload the DLL if necessary. The FFI doesn't provide any way to propagate exceptions from Haskell to the caller of a foreign export, because there's no standard way to do this. It is your responsibility to catch the exception in Haskell and return an appropriate error code to the caller. To raise a C++ exception, you would probably need another C++ wrapper around each foreign export, translating an error code into the C++ exception. I think my intial problem description should have mentioned that I already have an exception handler: catch (do let result = ... write result to file return 1) (\_ - return 0) However, this handler catches IO exceptions only! Following the advice from this thread I changed the handler as follows: Control.Exception.catch (do result - Control.Exception.evaluate (...) write result to file return 1) (\_ - return 0) This handler actually catches all exceptions. I found that it is important to use Control.Exception.catch, just catch does not work. I do not yet know whether I have to use evaluate. Next thing is to pass the exception messages to the C++ side and I think I know how to achieve this. Michael ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Any way to catch runtime errors in a DLL?
Exceptions generated from Haskell you can catch, but the really bad ones are those that the runtime system itself generates (when something really bad happens, like a failed malloc). I have a set of patches that fixes those, so you can actually write safe DLLs. One of these days I'll file a bug report with them. :) -- Lennart Michael Marte wrote: Hello *, if a runtime error occurs inside a DLL compiled by ghc (like irrefutable pattern match failed or exceptions caused by error), the application that called the DLL function dies. This is ok for development but unacceptable when it happens with a user sitting in front of the display. (It has not yet happened but it's only a question of time.) So my question is: Is there any way to catch and process runtime errors? I am looking for some way to map those errors to exceptions on the C++ side that can be caught if required. It would be ok to kill the Haskell runtime system and unload the DLL if necessary. Michael ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell] ANNOUNCE: Haskell Communities Activities Report (10th ed., June 2006)
Hello Andres, Monday, June 12, 2006, 8:19:54 PM, you wrote: Haskell Communities and Activities Report (10th edition, June 2006) thank you for this huge work, Andres! can you please add to the list of competitors information about http://www.haskell.org/haskellwiki/Libraries_and_tools page? due to the great work done by Donald Bruce Stewart now it almost reflects full state-of-the-art in these areas. he wrote the following to me in April: == About a month ago I went through the entire HWN archives, the haskell@ archives back to 1990 (Check the Old_news page!) and the last HCAR, adding over 100 entries to the libraries page. So, I argue it is the most complete list we have. And if anything's missing, you know how to edit the wiki. == now i return to the discussion about all these competitors. imagine that i am Johnny the developer which wrote great Stream library. now i want to make information about it available to all interested souls. what should i do? 1) write announcement to mail list 2) write tiny description for HWN (now Donald does this for us) 3) put information to the haskellwiki/Libraries_and_tools page 4) upload it to the Hackage 5) after half year, write description for HCAR too much, i think. and HCAR is in bad position here because it refreshed only once for 6 months and need centralized work. i prefer medias that is real-time and can be updated by anyone interested. wiki seems the best candidate for this role, but it is just unstructured text, it doesn't allow to extract, for example, information about new projects for last week, or look only at libs that supports both Hugs and GHC. so, the best media will be some sort of online database, like CPAN. it should - have enough fields to allow any required searches - by date of publication, category, author - automatically extracts this information from cabal files - support various entry types, such as individuals, papers and all other mentioned in current HCAR - allow anyone to add new entries, with or without uploading actual implementations this database should allow to find information about all the new/updated packages for last week, making possible automatic generation of this HWN part. in this case to announce his work, developer should just describe it at this server, and then 1) automatic announcement for this mail list will be generated 2) next week HWN will automatically include description of this package 3) anyone interested to see new/updated packages for last year or last month can run appropriate query on this server site 4) anyone who want to see full list of described packages or list split by categories can do it again using this site interface the good news is what we already have this database - yes, it's HCAR itself, what is internally keeps as database, afaik. it has many fields required, although we should add more following the .cabal file structure. so we can start this online database just now. the only thing required is the web interface for editing/searching data the next important things will be keeping history of updates (especially version updates to allow search for libraries whose major version was updated during, for example, last 6 months); adding subscription to package that allows to be warned via email when libraries i interested are updated; interaction with Hackage -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] STM applications and examples?
On 6/13/06, Simon Marlow [EMAIL PROTECTED] wrote: Hi Folks, I'm interested in gathering information about existing STM applications and example code that people might be working on or have lying around. It would be great to maintain a list of such applications and example code on the wiki somewhere, and use it as a resource for learning STM and research into STM implementations. If you have an application using STM, please let us know. If you can supply the code, even better. Similarly if you have some STM code that might be suitable as samples or benchmarks, we'd love to collect it. Conjure (a bittorrent client) is using STM quite heavily. It isn't usable as a whole but it has some interesting parts. Darcs repository: http://darcs.haskell.org/~lemmih/conjure/ -- Friendly, Lemmih ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
RE: [Haskell] ANNOUNCE: Haskell Communities Activities Report (10thed., June 2006)
I believe that this is just what HackageDB is for (described in HCAR p20). I have no idea of how complete Hackage is, thus far, though. Simon | so, the best media will be some sort of online database, like CPAN. | it should | | - have enough fields to allow any required searches - by date of | publication, category, author | - automatically extracts this information from cabal files | - support various entry types, such as individuals, papers and all | other mentioned in current HCAR | - allow anyone to add new entries, with or without uploading actual | implementations | | this database should allow to find information about all | the new/updated packages for last week, making possible automatic | generation of this HWN part. in this case to announce his work, | developer should just describe it at this server, and then | | 1) automatic announcement for this mail list will be generated | 2) next week HWN will automatically include description of this package | 3) anyone interested to see new/updated packages for last year or last | month can run appropriate query on this server site | 4) anyone who want to see full list of described packages or list | split by categories can do it again using this site interface | | the good news is what we already have this database - yes, it's HCAR | itself, what is internally keeps as database, afaik. it has many | fields required, although we should add more following the .cabal | file structure. so we can start this online database just | now. the only thing required is the web interface for | editing/searching data | | the next important things will be keeping history of updates | (especially version updates to allow search for libraries whose major | version was updated during, for example, last 6 months); adding | subscription to package that allows to be warned via email when | libraries i interested are updated; interaction with Hackage ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] ANNOUNCE: Haskell Communities Activities Report (10thed., June 2006)
Paolo Martini will most likely continue the development of HackageDB as part of his SoC project. On 6/15/06, Simon Peyton-Jones [EMAIL PROTECTED] wrote: I believe that this is just what HackageDB is for (described in HCAR p20). I have no idea of how complete Hackage is, thus far, though. Simon | so, the best media will be some sort of online database, like CPAN. | it should | | - have enough fields to allow any required searches - by date of | publication, category, author | - automatically extracts this information from cabal files | - support various entry types, such as individuals, papers and all | other mentioned in current HCAR | - allow anyone to add new entries, with or without uploading actual | implementations | | this database should allow to find information about all | the new/updated packages for last week, making possible automatic | generation of this HWN part. in this case to announce his work, | developer should just describe it at this server, and then | | 1) automatic announcement for this mail list will be generated | 2) next week HWN will automatically include description of this package | 3) anyone interested to see new/updated packages for last year or last | month can run appropriate query on this server site | 4) anyone who want to see full list of described packages or list | split by categories can do it again using this site interface | | the good news is what we already have this database - yes, it's HCAR | itself, what is internally keeps as database, afaik. it has many | fields required, although we should add more following the .cabal | file structure. so we can start this online database just | now. the only thing required is the web interface for | editing/searching data | | the next important things will be keeping history of updates | (especially version updates to allow search for libraries whose major | version was updated during, for example, last 6 months); adding | subscription to package that allows to be warned via email when | libraries i interested are updated; interaction with Hackage ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell -- Friendly, Lemmih ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
RE: [Haskell] ANNOUNCE: Haskell Communities Activities Report (10thed., June 2006)
Indeed; but it sounds like just the kind of project that would benefit from many contributors. Simon | -Original Message- | From: Lemmih [mailto:[EMAIL PROTECTED] | Sent: 15 June 2006 09:12 | To: Simon Peyton-Jones | Cc: Bulat Ziganshin; Andres Loeh; haskell@haskell.org | Subject: Re: [Haskell] ANNOUNCE: Haskell Communities Activities Report (10thed., June 2006) | | Paolo Martini will most likely continue the development of HackageDB | as part of his SoC project. | | On 6/15/06, Simon Peyton-Jones [EMAIL PROTECTED] wrote: | I believe that this is just what HackageDB is for (described in HCAR | p20). I have no idea of how complete Hackage is, thus far, though. | | Simon | | | so, the best media will be some sort of online database, like CPAN. | | it should | | | | - have enough fields to allow any required searches - by date of | | publication, category, author | | - automatically extracts this information from cabal files | | - support various entry types, such as individuals, papers and all | | other mentioned in current HCAR | | - allow anyone to add new entries, with or without uploading actual | | implementations | | | | this database should allow to find information about all | | the new/updated packages for last week, making possible automatic | | generation of this HWN part. in this case to announce his work, | | developer should just describe it at this server, and then | | | | 1) automatic announcement for this mail list will be generated | | 2) next week HWN will automatically include description of this | package | | 3) anyone interested to see new/updated packages for last year or last | | month can run appropriate query on this server site | | 4) anyone who want to see full list of described packages or list | | split by categories can do it again using this site interface | | | | the good news is what we already have this database - yes, it's HCAR | | itself, what is internally keeps as database, afaik. it has many | | fields required, although we should add more following the .cabal | | file structure. so we can start this online database just | | now. the only thing required is the web interface for | | editing/searching data | | | | the next important things will be keeping history of updates | | (especially version updates to allow search for libraries whose major | | version was updated during, for example, last 6 months); adding | | subscription to package that allows to be warned via email when | | libraries i interested are updated; interaction with Hackage | ___ | Haskell mailing list | Haskell@haskell.org | http://www.haskell.org/mailman/listinfo/haskell | | | | -- | Friendly, | Lemmih ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re[2]: [Haskell] ANNOUNCE: Haskell Communities Activities Report (10thed., June 2006)
Hello Lemmih, Thursday, June 15, 2006, 12:11:50 PM, you wrote: Paolo Martini will most likely continue the development of HackageDB as part of his SoC project. are you have plans to implement all things i mentioned? can we now import HCAR database into HackageDB? can HackageDB work with external libraries, non-cabalized libraries, hold information about individuals and so on? -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: Re[2]: [Haskell] ANNOUNCE: Haskell Communities Activities Report (10thed., June 2006)
On 6/15/06, Bulat Ziganshin [EMAIL PROTECTED] wrote: Hello Lemmih, Thursday, June 15, 2006, 12:11:50 PM, you wrote: Paolo Martini will most likely continue the development of HackageDB as part of his SoC project. are you have plans to implement all things i mentioned? can we now import HCAR database into HackageDB? can HackageDB work with external libraries, non-cabalized libraries, hold information about individuals and so on? HackageDB is only for keeping track of Cabal packages and that's how it's gonna stay (with the possible exception of hosting documentation and darcs repositories, etc). A separate user-editable community report could then refer to packages on HackageDB. -- Friendly, Lemmih ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re[4]: [Haskell] ANNOUNCE: Haskell Communities Activities Report (10thed., June 2006)
Hello Lemmih, Thursday, June 15, 2006, 1:25:27 PM, you wrote: HackageDB is only for keeping track of Cabal packages and that's how it's gonna stay (with the possible exception of hosting documentation and darcs repositories, etc). A separate user-editable community report could then refer to packages on HackageDB. yes, now we returns to the reasons why i propose to create separate database from HCAR data. one possible distinction may be that HackageDB is for robots that need to automatically install packages required in the TRUSTED way, while HcarDB is for humans searching for information about any haskell-related activity just an example - i know about existence of XYZ library, but i'm not the author. i want to just describe it so that anyone can find info about this lib. can i go to HackageDB? i think no - it's only for authors that upload their libs there. using of unstructured wiki pages is bad - it don't allow to search on complex criteries, don't allow to track history, don't allow to automatically notify about new versions, don't allow to make automatic HWN reports and so on so i propose either to extend HackageDB to allow inclusion of descriptions without libs itself, inlusion of papers, individuals and so on, or develop new web database with such abilities. we definitely need a libraries repository! but HackageDB on this moment contains only about 10 projects, mostly your own. why? lack of advertisement, or just because there are too many places where developer should register his library (maillist, hcar, wiki, hackage)? i propose to search for the way that will allow to move information from HCAR and wiki pages to some web database, be it Hackage or new db. this should allow to create cpan-like database just now and don't wait while developers will grok advantages of HackageDB -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: Re[4]: [Haskell] ANNOUNCE: Haskell Communities Activities Report (10thed., June 2006)
On 6/15/06, Bulat Ziganshin [EMAIL PROTECTED] wrote: Hello Lemmih, Thursday, June 15, 2006, 1:25:27 PM, you wrote: HackageDB is only for keeping track of Cabal packages and that's how it's gonna stay (with the possible exception of hosting documentation and darcs repositories, etc). A separate user-editable community report could then refer to packages on HackageDB. yes, now we returns to the reasons why i propose to create separate database from HCAR data. one possible distinction may be that HackageDB is for robots that need to automatically install packages required in the TRUSTED way, while HcarDB is for humans searching for information about any haskell-related activity just an example - i know about existence of XYZ library, but i'm not the author. i want to just describe it so that anyone can find info about this lib. can i go to HackageDB? i think no - it's only for authors that upload their libs there. using of unstructured wiki pages is bad - it don't allow to search on complex criteries, don't allow to track history, don't allow to automatically notify about new versions, don't allow to make automatic HWN reports and so on so i propose either to extend HackageDB to allow inclusion of descriptions without libs itself, inlusion of papers, individuals and so on, or develop new web database with such abilities. A new web database is needed. we definitely need a libraries repository! but HackageDB on this moment contains only about 10 projects, mostly your own. why? lack of advertisement, or just because there are too many places where developer should register his library (maillist, hcar, wiki, hackage)? It's most likely because cabal-get and cabal-put are really difficult to install. Of course, this will change when the tools are distributed with Cabal (which a paid hacker will be working on). I believe that the mailing list, the community report, the wiki and HackageDB all serve different needs. The mailing list is for announcements, the report is for semi-formal listing, the wiki is for casual listing and HackageDB is for automatic downloads. There is some overlap but it's not a lot. i propose to search for the way that will allow to move information from HCAR and wiki pages to some web database, be it Hackage or new db. this should allow to create cpan-like database just now and don't wait while developers will grok advantages of HackageDB We all want a neat, central package-database but few are willing to take the first step. (: -- Friendly, Lemmih ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] CFP: Partial Evaluation and Program Manipulation (PEPM'07)
-- Call For Papers ACM SIGPLAN 2007 Workshop on PARTIAL EVALUATION AND PROGRAM MANIPULATION (PEPM'07) Nice, France January 15-16, 2007 (Co-located with POPL 2007) http://www.program-transformation.org/PEPM07 -- The PEPM Symposium/Workshop series aims to bring together researchers and practitioners working in the areas of program manipulation, partial evaluation, and program generation. PEPM focuses on techniques, theory, tools, and applications of analysis and manipulation of programs. The 2007 PEPM workshop will be based on a broad interpretation of semantics-based program manipulation and continue last year's successful effort to expand the scope of PEPM significantly beyond the traditionally covered areas of partial evaluation and specialization and include practical applications of program transformations such as refactoring tools, and practical implementation techniques such as rule- based transformation systems. In addition, the scope of PEPM covers manipulation and transformations of program and system representations such as structural and semantic models that occur in the context of model-driven development. In order to reach out to practitioners, a separate category of tool demonstration papers will be solicited. -- Topics of interest for PEPM'07 include, but are not limited to: + Program and model manipulation techniques such as transformations driven by rules, patterns, or analyses, partial evaluation, specialization, slicing, symbolic execution, refactoring, aspect weaving, decompilation, and obfuscation. + Program analysis techniques that are used to drive program/model manipulation such as abstract interpretation, static analysis, binding-time analysis, dynamic analysis, constraint solving, and type systems. + Analysis and transformation for programs/models with advanced features such as objects, generics, ownership types, aspects, reflection, XML type systems, component frameworks, and middleware. + Techniques that treat programs/models as data objects including meta-programming, generative programming, staged computation, and model-driven program generation and transformation. + Application of the above techniques including experimental studies, engineering needed for scalability, and benchmarking. Examples of application domains include legacy program understanding and transformation, domain-specific language implementations, scientific computing, middleware frameworks and infrastructure needed for distributed and web-based applications, resource-limited computation, and security. We especially encourage papers that break new ground including descriptions of how program/model manipulation tools can be integrated into realistic software development processes, descriptions of robust tools capable of effectively handling realistic applications, and new areas of application such as rapidly evolving systems, distributed and web-based programming including middleware manipulation, model-driven development, and on-the-fly program adaptation driven by run-time or statistical analysis. -- Submission Categories and Guidelines Regular research papers must not exceed 10 pages in ACM Proceedings style. Tool demonstration papers must not exceed 4 pages in ACM Proceedings style, and authors will be expected to present a live demonstration of the described tool at the workshop. Suggested topics, evaluation criteria, and writing guidelines for both research tool demonstration papers will be made available on the PEPM'07 web site. Papers should be submitted electronically via the workshop web site. The workshop proceedings will be published in the ACM Digital Library and selected papers will be invited for a journal special issue dedicated to PEPM'07. -- Important Dates + Abstracts due: October 18, 2006 + Submission:October 20, 2006 + Notification: December 1, 2006 + Camera-ready: December 18, 2006 + Workshop: January 15-16, 2007 --- Program Chairs * G. Ramalingam (IBM Research, Bangalore) * Eelco Visser (Utrecht University, The Netherlands) Program Committee Members * Ras Bodik (University of California, Berkeley, USA) * Albert Cohen (INRIA, France) * Jim Cordy (Queen's University, Canada) * Martin Erwig (Oregon State University, USA) * Bernd Fischer (University of Southampton, UK) * John Hatcliff (Kansas State University,
Re: [Haskell] ANNOUNCE: Haskell Communities Activities Report (10th ed., June 2006)
Andres Loeh wrote: On behalf of the many, many contributors, I am pleased to announce that the Haskell Communities and Activities Report (10th edition, June 2006) http://www.haskell.org/communities/ This is a gem ... many thanks! It will be very useful to me when I manage to get some time to use Haskell again. So much has been happening, it would be difficult to catch up without a great overview like this. #g -- Graham Klyne For email: http://www.ninebynine.org/#Contact ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell-cafe] do we have something like isDefined or isNull in Haskell?
Suppose there is a data definition in Haskell: data MyType = MyType { date :: Double, weight :: Double, height:: Double } deriving (Eq, Ord, Show) Is it possible to check if the field height, for example, is filled in(defined)? Can we give default values in Haskell? Many thanks and sorry fro so sily questions. Vladimir _ The new MSN Search Toolbar now includes Desktop search! http://join.msn.com/toolbar/overview ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] do we have something like isDefined or isNull in Haskell?
On 6/15/06, Vladimir Portnykh [EMAIL PROTECTED] wrote: Suppose there is a data definition in Haskell: data MyType = MyType { date :: Double, weight :: Double, height:: Double } deriving (Eq, Ord, Show) Is it possible to check if the field height, for example, is filled in(defined)? Can we give default values in Haskell? Many thanks and sorry fro so sily questions. Vladimir You could make date, weight, and height Maybe Doubles, then isDefined = isJust and isNull = isNothing. Bryan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] do we have something like isDefined or isNull in Haskell?
On Thu, 2006-06-15 at 12:43 +0100, Vladimir Portnykh wrote: Suppose there is a data definition in Haskell: data MyType = MyType { date :: Double, weight :: Double, height:: Double } deriving (Eq, Ord, Show) Is it possible to check if the field height, for example, is filled in(defined)? Can we give default values in Haskell? There is no implicit null, standard technique is to use an explicit null using the Maybe type: data MyType = MyType { date :: Maybe Double, weight :: Maybe Double, height :: Maybe Double } deriving (Eq, Ord, Show) The Maybe type is defined like this: data Maybe a = Nothing | Just a so a value of type 'Maybe a' can be either Just x or Nothing. So you can represent your lack of a value using Nothing. You can get something similar to default values in a record by using the ordinary record update syntax. Suppose we start with a default record value: default :: MyType default = MyType { date = Nothing, weight = Nothing, height = Nothing } then you can construct your records using: foo = default { weight = 3.2 } so foo will get all the default values except for the ones you explicitly set. Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Rotating matrices
Dear list, I'm currently engaged in an attempt to wrap my head around type arithmetic. To make sure that I've understood, I plan to write a few operations on matrices a la Oleg's Number Parameterised Types. Before I get down to it, I've been making sure I know how to implement the operations (so that all I need to think about later is the type arithmetic). Today I've been looking at rotating matrices, i.e: taking a column- wise matrix and making it row-wise and, in the process, swapping the dimensions (thus a 3*2 matrix becomes a 2*3 matrix). I've been working with lists of lists for simplicity and have come up with: rotate' :: [[a]] - [[a]] rotate' [] = [] rotate' xs = (map (head) xs ):(rotate' $ filter (not . null) $ map (tail) xs) which seems to work just fine. While this solution is adequate (it seems to work for infinite structures as well, which is good), I originally set out to solve this problem with a fold or a mapAccum of some sort (I don't really care if it doesn't work with infinite structures). Can anyone suggest a way to write this with a fold (or tell me why it isn't a good idea)? Cheers, Thomas Sutton ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Rotating matrices
On Thu, 15 Jun 2006, Thomas Sutton wrote: Today I've been looking at rotating matrices, i.e: taking a column-wise matrix and making it row-wise and, in the process, swapping the dimensions (thus a 3*2 matrix becomes a 2*3 matrix). You mean 'matrix transposition' which is available as Data.List.transpose. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Rotating matrices
Thomas, rotate' :: [[a]] - [[a]] rotate' [] = [] rotate' xs = (map (head) xs ):(rotate' $ filter (not . null) $ map (tail) xs) which seems to work just fine. While this solution is adequate (it seems to work for infinite structures as well, which is good), I originally set out to solve this problem with a fold or a mapAccum of some sort (I don't really care if it doesn't work with infinite structures). Can anyone suggest a way to write this with a fold (or tell me why it isn't a good idea)? transpose = foldr (zipWith (:)) (repeat []) HTH, Stefan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Receiving multicasts
Hello, Has anyone figured out a way to receive multicasts in a Haskell program? It doesn't appear that Network.Socket.setSocketOption provides enough information to join a multicast address. Any information would be appreciated. -- Rich AIM : rnezzy ICQ : 174908475 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] what do you think of haskell ? (yes, it's a bit general ...:)
hi all folks, i'm diving into haskell for more than one year now. the reason for that is just that i like haskell. (i'm a computer science student) but i consider to move back to c/c++. here are my thoughts. i've no specific question but i'd like to have your opinion. here we go: haskell is really nice : short phrased, declarative, math-feeling, the type system ensure low bug amount (i surely forget other nice things). but haskell is quite ugly in some way : * array : if i want to write something involving array, i could use list, and a lot (too much!) of array types (io/st, mutable/immutable, c-friendly (storable). worst, code involving one type can need to be rewritten for another type. * laziness / array (again) (i am biased since i have no knowledge of haskell profiling / performance seeking) always with array code, i was forced (maybe it's because i dont know enough) to use iouarray : if not, performance|memory consumption were low|high. but with iouarray, i cant use an array of MyType; i have to use an array of (say) float (it's ok if i have only float in MyType). that kind of thing is what i think is *really* low-level. in c, i can have an array of what-i-want. * randomIO side-effect is nicely resolved with monad. and you have to thread your state. if you're writing your monad or use a transformer, things are quite explicitly (even if it's implicit in the do notation) threaded. but the threading of the randomIO argument is really not explicit for me : it just means that the underlying/threaded state in the IO monad can encapsulated a lot of things. it feels exactly like a c function. but usually, you cant design a c-like function in haskell (i.e. a function with state). * more things i dont remember... * generally my general feeling for haskell vs c is: in haskell i always have to learn new things to get my work done ; although haskell is really easy to learn in the first step, it's becoming increasingly hard to get what's the *trick* to do what i want. e.g. writing myfunction x1 .. xn | x1 `seq` ... False = undefined is not declarative (and i still have to learn to identify where it helps and where it doesn't) the c language take some more time to learn at the beginning but that's it! what you can learn by after is better c programming. there are memory management, pointers, side-effects, but you can do what you want, it behaves as expected and you dont have to learn (in a academic paper) how to use an array or how to do io. :) please don't tell me you're stupid, go back to your c and leave this glorious mailing list did you had the same feeling ? does it disappear ? how ? thanks a lot, vo minh thu ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Fibonacci numbers generator in Haskell
Fibonacci numbers implementations in Haskell one of the classical examples. An example I found is the following: fibs :: [Int] fibs = 0 : 1 : [ a + b | (a, b) - zip fibs (tail fibs)] To get the k-th number you do the following: Result = fibs !! k It is elegant but creates a list of all Fibonacci numbers less than k-th, and the code is not very readable :). I wrote my own Fibonacci numbers generator: fib :: Int - [Int] fib 0 = [0,0] fib 1 = [1,0] fib n = [sum prevFib, head prevFib] where a = fib (n - 1) To get the k-th number you do the following: result = head (fib k) It does not generate full list of Fibonacci numbers, but keeps only 2 previous numbers, and has only one recursive call. Because the list always has only 2 elements using the functions head and sum is a bit overkill. Can we do better? _ Are you using the latest version of MSN Messenger? Download MSN Messenger 7.5 today! http://join.msn.com/messenger/overview ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what do you think of haskell ? (yes, it's a bit general ...:)
Hi Minh, When I write Haskell, its because I want to write the code quickly, not because I want it to run quickly. GHC is a wonderful compiler and makes things go fast, but Hugs is faster at compiling, so I always use Hugs (WinHugs in fact). If your focus is on things going fast, then with Haskell you have to think harder to get this - but its certainly possible, see the shootout benchmarks. * array Why do you want to write things with Array's - in C the default type of everything is an Array, and you occasionally use a Linked List. In Haskell its the opposite - linked lists are very nice and natural - I never use arrays. * laziness / array (again) Laziness often makes my code go faster - because I am lazy and Haskell's laziness means that when I combine things in just lazy ways Haskell drops the things I did that were useless. * randomIO side-effect is nicely resolved with monad. and you have to thread your state. if you're writing your monad or use a transformer, things are quite explicitly (even if it's implicit in the do notation) threaded. Yes, C is nicer for this kind of thing, in my opinion - nicer from a practical view, even if it is pretty horrid in the end. * generally my general feeling for haskell vs c is: in haskell i always have to learn new things to get my work done ; although haskell is really easy to learn in the first step, it's becoming increasingly hard to get what's the *trick* to do what i want. I think I know very few tricks, and have never felt the need to know more. If you stick to simple Haskell it keeps your brain for other things. I think what you seem to be saying is that to write fast Haskell programs requires more effort and more work than C programming? Exactly what Haskell programs were you trying to write, and did you try just writing them in a naive way and checking that just simple and stupid doesn't give you the performance you need? Maybe if you learnt the FFI aspects of Haskell, you could write your code in Haskell, and then either optimise the Haskell or just give up and move that portion to C, keeping the rest in Haskell. Thanks Neil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Fibonacci numbers generator in Haskell
Here's some code I wrote a while back for computing the nth Fibonacci number. It has O(log n) time complexity rather than O(n). It isn't the most elegant example, but it should be one of the fastest approaches. import Data.Bits (shiftR, xor, (.|.), (..)) import Data.Word (Word32) fibo :: Word32 - Integer fibo n = loop (highestBitMask n) 1 0 where loop :: Word32 - Integer - Integer - Integer loop i a b | i == 0 = b | n .. i /= 0 = (loop (shiftR i 1) $! a*(2*b + a)) $! a*a + b*b | otherwise= (loop (shiftR i 1) $! a*a + b*b) $! b*(2*a - b) highestBitMask :: Word32 - Word32 highestBitMask x = case (x .|. shiftR x 1) of x - case (x .|. shiftR x 2) of x - case (x .|. shiftR x 4) of x - case (x .|. shiftR x 8) of x - case (x .|. shiftR x 16) of x - (x `xor` (shiftR x 1)) Cheers, Spencer Janssen On 6/15/06, Vladimir Portnykh [EMAIL PROTECTED] wrote: Fibonacci numbers implementations in Haskell one of the classical examples. An example I found is the following: fibs :: [Int] fibs = 0 : 1 : [ a + b | (a, b) - zip fibs (tail fibs)] To get the k-th number you do the following: Result = fibs !! k It is elegant but creates a list of all Fibonacci numbers less than k-th, and the code is not very readable :). I wrote my own Fibonacci numbers generator: fib :: Int - [Int] fib 0 = [0,0] fib 1 = [1,0] fib n = [sum prevFib, head prevFib] where a = fib (n - 1) To get the k-th number you do the following: result = head (fib k) It does not generate full list of Fibonacci numbers, but keeps only 2 previous numbers, and has only one recursive call. Because the list always has only 2 elements using the functions head and sum is a bit overkill. Can we do better? _ Are you using the latest version of MSN Messenger? Download MSN Messenger 7.5 today! http://join.msn.com/messenger/overview ___ 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] what do you think of haskell ? (yes, it's a bit general ...:)
hi, thanks for your answer. the kind of thing i want to do : computer graphics programming. so array is better than list (no ?) to represent images ... bye vo minh thu (hey, my last name is VO, and my first name is Thu, not Minh :) 2006/6/15, Neil Mitchell [EMAIL PROTECTED]: Hi Minh, When I write Haskell, its because I want to write the code quickly, not because I want it to run quickly. GHC is a wonderful compiler and makes things go fast, but Hugs is faster at compiling, so I always use Hugs (WinHugs in fact). If your focus is on things going fast, then with Haskell you have to think harder to get this - but its certainly possible, see the shootout benchmarks. * array Why do you want to write things with Array's - in C the default type of everything is an Array, and you occasionally use a Linked List. In Haskell its the opposite - linked lists are very nice and natural - I never use arrays. * laziness / array (again) Laziness often makes my code go faster - because I am lazy and Haskell's laziness means that when I combine things in just lazy ways Haskell drops the things I did that were useless. * randomIO side-effect is nicely resolved with monad. and you have to thread your state. if you're writing your monad or use a transformer, things are quite explicitly (even if it's implicit in the do notation) threaded. Yes, C is nicer for this kind of thing, in my opinion - nicer from a practical view, even if it is pretty horrid in the end. * generally my general feeling for haskell vs c is: in haskell i always have to learn new things to get my work done ; although haskell is really easy to learn in the first step, it's becoming increasingly hard to get what's the *trick* to do what i want. I think I know very few tricks, and have never felt the need to know more. If you stick to simple Haskell it keeps your brain for other things. I think what you seem to be saying is that to write fast Haskell programs requires more effort and more work than C programming? Exactly what Haskell programs were you trying to write, and did you try just writing them in a naive way and checking that just simple and stupid doesn't give you the performance you need? Maybe if you learnt the FFI aspects of Haskell, you could write your code in Haskell, and then either optimise the Haskell or just give up and move that portion to C, keeping the rest in Haskell. Thanks Neil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what do you think of haskell ? (yes, it's a bit general ...:)
On 6/15/06, minh thu [EMAIL PROTECTED] wrote: hi, thanks for your answer. the kind of thing i want to do : computer graphics programming. so array is better than list (no ?) to represent images ... This may not be very helpful, but I would say that an Image is neither a list nor an array - it's a function! :-) /S -- Sebastian Sylvan +46(0)736-818655 UIN: 44640862 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what do you think of haskell ? (yes, it's a bit general ...:)
On Jun 15, 2006, at 6:18 PM, Sebastian Sylvan wrote: This may not be very helpful, but I would say that an Image is neither a list nor an array - it's a function! :-) How exactly do you manipulate the bits and bytes of a function? -- http://wagerlabs.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what do you think of haskell ? (yes, it's a bit general ...:)
right :) i had to say a discrete image ... or a raster, or an *array* of pixels ! sylvan, it must be nice to talk with you (an funny) about haskell and cg :) mt 2006/6/15, Sebastian Sylvan [EMAIL PROTECTED]: On 6/15/06, minh thu [EMAIL PROTECTED] wrote: hi, thanks for your answer. the kind of thing i want to do : computer graphics programming. so array is better than list (no ?) to represent images ... This may not be very helpful, but I would say that an Image is neither a list nor an array - it's a function! :-) /S -- Sebastian Sylvan +46(0)736-818655 UIN: 44640862 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what do you think of haskell ? (yes, it's a bit general ...:)
On 6/15/06, Joel Reymont [EMAIL PROTECTED] wrote: On Jun 15, 2006, at 6:18 PM, Sebastian Sylvan wrote: This may not be very helpful, but I would say that an Image is neither a list nor an array - it's a function! :-) How exactly do you manipulate the bits and bytes of a function? Well I suppose by returning a new function which produces the required changes, and perhaps refers back to the old function in certain cases. It's a neat abstraction, anyway, even if you at the very bottom have some low level representation using pedestrian concepts such as bytes and bits :-) /S -- Sebastian Sylvan +46(0)736-818655 UIN: 44640862 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] do we have something like isDefined or isNull in Haskell?
Duncan Coutts wrote: On Thu, 2006-06-15 at 13:11 +0100, Duncan Coutts wrote: then you can construct your records using: foo = default { weight = 3.2 } Oops, as David House pointed out to me that should of course be foo = default { weight = Just 3.2 } I think the correct response in these cases is: That was left as an exercise for the type checker. On another note, who picked the word `Just' for this type and how did we end up with Some x | None in O'Caml and Just x | Nothing in Haskell? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what do you think of haskell ? (yes, it's a bit general ...:)
On Thu, 15 Jun 2006, minh thu wrote: * randomIO side-effect is nicely resolved with monad. and you have to thread your state. if you're writing your monad or use a transformer, things are quite explicitly (even if it's implicit in the do notation) threaded. You know that random generators are not bounded to IO? 'random' and related functions work just like the random generators in object oriented designs. In OO languages the random generator is usually an object which hides a state and there can be several instances of random generators. In Haskell the random generator can be viewed as a State monad. But you are right, you have to carry the monad with you all the time. Alternatively it is sometimes simpler to consume values from a list generated by randomRs. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Fibonacci numbers generator in Haskell
On Thu, 15 Jun 2006, Vladimir Portnykh wrote: Fibonacci numbers implementations in Haskell one of the classical examples. An example I found is the following: fibs :: [Int] fibs = 0 : 1 : [ a + b | (a, b) - zip fibs (tail fibs)] To get the k-th number you do the following: Result = fibs !! k It is elegant but creates a list of all Fibonacci numbers less than k-th, and the code is not very readable :). The garbage collector will free storage for values that are no longer needed. So if the garbage collector is hard working there will be no more than 2 previous values stored per computation of a new value. I wrote my own Fibonacci numbers generator: fib :: Int - [Int] fib 0 = [0,0] fib 1 = [1,0] fib n = [sum prevFib, head prevFib] where a = fib (n - 1) To get the k-th number you do the following: result = head (fib k) It does not generate full list of Fibonacci numbers, but keeps only 2 previous numbers, and has only one recursive call. Because the list always has only 2 elements using the functions head and sum is a bit overkill. If you want to do it that way, better use pairs of numbers instead of lists. Lists can have any number of elements, pairs have exactly two members. So the latter is more type safe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Everything but the lazyness - idea for force/delay lists
minh thu wrote: hi in fact, i think that for a while ... moreover, i thought to translate to some kind of readable c (because there s so much c libs all around). i think it's even possible to retain laziness where it's ok ( for data structure essentially). Hi Thu - Someone pointed out (offlist) a useful paper by Phil Wadler How to add laziness to a strict language without even being odd which shows how laziness can be used without needing a lifted type system. Once you've understood the subtleties of the FFI, it's relatively easy to use it link to C libs. is-it possible to know what you're doing at metamilk ? Well I'd tell you if I knew myself! :-) Seriously though, at the moment my aim is to develop an integrated programming environment for a language similar to Haskell, either Haskell itself or a non-lazy version of it, also with some syntactic modifications to make it easier to use. It's in very early stages though. I'm trying as much as possible to write everything from scratch (including the GUI) in Haskell so I can see what the advantages/disadvantages of Haskell are and where improvements in the syntax would be useful. My experience so far is that the typeclasses and existentials that Haskell supports are an advantage over OCaml or SML, but that the lazyness is a real nusiance but with some extra effort it's possible to mostly get rid of it. Regards, Brian. mt 2006/6/13, Brian Hulley [EMAIL PROTECTED]: Hi - I've been thinking about how to get an extremely fast language with all the benefits of Haskell ie completely pure with no side effects, but with monads, higher order functions, type classes etc, but without the lazyness. -- Logic empowers us and Love gives us purpose. Yet still phantoms restless for eras long past, congealed in the present in unthought forms, strive mightily unseen to destroy us. http://www.metamilk.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what do you think of haskell ? (yes, it's a bit general ...:)
hi, yes i know about that, but i was talking about randomIO which breaks that view; and i find that quite weird for a 'clean' language. * another thing i remember now : binary io. there are some libraries but it's not really standard. and it's weird to learn all (well, or just one) that libraries just to do io. cheers, mt 2006/6/15, Henning Thielemann [EMAIL PROTECTED]: On Thu, 15 Jun 2006, minh thu wrote: * randomIO side-effect is nicely resolved with monad. and you have to thread your state. if you're writing your monad or use a transformer, things are quite explicitly (even if it's implicit in the do notation) threaded. You know that random generators are not bounded to IO? 'random' and related functions work just like the random generators in object oriented designs. In OO languages the random generator is usually an object which hides a state and there can be several instances of random generators. In Haskell the random generator can be viewed as a State monad. But you are right, you have to carry the monad with you all the time. Alternatively it is sometimes simpler to consume values from a list generated by randomRs. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] do we have something like isDefined or isNull in Haskell?
Vladimir, I think you forgot to put Haskell-cafe as a recipient of this email, so first I'll repost what you wrote. On 6/15/06, Vladimir Portnykh [EMAIL PROTECTED] wrote: many thanks. i have the follwoing code: module MyType (DataContainer(..)) where import Maybe data DataContainer = MyType { date :: [Maybe Double], weight ::[Maybe Double], height ::[Maybe Double] } deriving (Eq, Ord, Show) myType = MyType { date = [38548,38562,38576,38590,38604,38618,38632,38646,38660,38674], weight = [], height = [] } reportProblem = if isJust (height myType !! (length (date myType) - 1)) then 0 else 1 it failed to compiled saying No instance for (Num (Maybe Double)) arising from the literal 38674 . After reading your code for a while, I still don't know if I quite understand. Can you explain exactly what you are trying to do? My thought is that maybe you just want a list of objects, since you are indexing height at the same index as date. Then you just want a list of the structures that Duncan described. myObjects = [default {weight = 3.2}, default {weight = 7.9, date=38458},...] If not, hopefully somebody a little more knowledgable than I can help you. Bryan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Learning C after Haskell
I did the transition the other way, and even now the real-world keeps me using more C-like languages (Java, Python). Unlike the transition from imperative languages to Haskell, I don't think there's much you have to unlearn or rethink. But I suspect you may feel a degree of frustration at how incredibly primitive C may seem after learning to use the power that Haskell makes available. Where you can map Haskell idioms into C, I think they may serve you well (I've found this to be the case with Python, but the gap from Haskell to C is somewhat greater). You mention high performance computing. I think there are two ways of achieving this: the C way might be described as micro optimization -- getting the small but important things to run as efficiently as possible The Haskell was is more a case of macro optimization -- getting the overall algorithmic approach to be as smart as possible. There's a place for both, but once you get involved in micro-optimization it can be very difficult to go back and fix the macro performance issues. So you might do well to first code algorithms in Haskell first, and experiment with the algorithms, if only as a way of specifying the solution to be implemented in C. #g -- Chad Scherrer wrote: Ok, so I'm doing things somewhat backward. I've been using Haskell for a while now, whenever I get a chance to. But in order to become more involved in high-performance computing projects at my work, I need to learn C. I've heard a lot of people say that experience in Haskell can improve one's abilities in other languages, but I also wonder how different the C way of doing things is different from Haskell's. My question is, as I learn C, are there any particular Haskell concepts I should keep in the back of my mind, or is it better to approach C from scratch? Thanks in advance! Preparing for a foot-shooting, Chad ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Graham Klyne For email: http://www.ninebynine.org/#Contact ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what do you think of haskell ? (yes, it's a bit general ...:)
minh thu wrote: hi all folks, i'm diving into haskell for more than one year now. the reason for that is just that i like haskell. (i'm a computer science student) but i consider to move back to c/c++. There is also OCaml and SML, both of which have freely available compilers to generate fast native code (SML has MLton - a whole program optimizing compiler), and which use side effects instead of monads. here are my thoughts. i've no specific question but i'd like to have your opinion. here we go: haskell is really nice : short phrased, declarative, math-feeling, the type system ensure low bug amount (i surely forget other nice things). but haskell is quite ugly in some way : * array : if i want to write something involving array, i could use [snip] Bulat's written a new array library - see http://www.haskell.org//pipermail/haskell/2006-June/018044.html but with iouarray, i cant use an array of MyType; i have to use an array of (say) float (it's ok if i have only float in MyType). that kind of thing is what i think is *really* low-level. in c, i can have an array of what-i-want. There is a compromise between using IOArray versus IOUArray. IOArrays might even be more efficient than unboxed arrays in some situations: 1) When (large) elements are shared between different arrays or different data structures, since only the pointer needs to be copied 2) Compared to C++ templates, only one piece of code needs to be generated to handle them, so there might be fewer cache misses at runtime * randomIO side-effect is nicely resolved with monad. and you have to thread your state. if you're writing your monad or use a transformer, things are quite explicitly (even if it's implicit in the do notation) threaded. but the threading of the randomIO argument is really not explicit for me : it just means that the underlying/threaded state in the IO monad can encapsulated a lot of things. it feels exactly like a c function. but usually, you cant design a c-like function in haskell (i.e. a function with state). You can instead write a function that returns an action in whatever monad you're using. For example using a Reader monad to hold IORefs, you can easily update the state of these IORefs. Of course this is more work than just declaring some global variable in C and updating it in the function, but it gives you more flexibility in the long run - you now have full control over the environment that the function sees, just by running it in another Reader containing different IORefs. * more things i dont remember... * generally my general feeling for haskell vs c is: in haskell i always have to learn new things to get my work done ; although haskell is really easy to learn in the first step, it's becoming increasingly hard to get what's the *trick* to do what i want. Maybe you are expecting too much of your code. A while back I was agonizing over the perfect way to write something using higher order functions, then a comment by Bulat ( http://www.haskell.org//pipermail/haskell-cafe/2006-May/015540.html ) helped me put things in perspective: imho, it's typical functional style, but without using higher-level functions So now I just concentrate on getting code to work and leave the highly obfuscated cleverness for later... ;-) e.g. writing myfunction x1 .. xn | x1 `seq` ... False = undefined is not declarative (and i still have to learn to identify where it helps and where it doesn't) Bang patterns would at least make the syntax easier to write. Strictness annotations work both ways - perhaps the question should be: where does *lazyness* help? I don't think anyone really has a clear answer to this at the moment. the c language take some more time to learn at the beginning but that's it! what you can learn by after is better c programming. I think (as someone who has spent at least 16 years programming in C++) that there are millions of complicated things there as well. The syntax and semantics of a language is only the very start. C and C++ have idioms to learn too, and like anything, it takes a lot of time and experience to know which trick to use in a given situation. Just as the object oriented community has spent many years slowly trying to understand how to design object oriented programs and made major mistakes at the beginning (eg using implementation inheritance instead of interfaces and composition (exactly what is fully supported in Haskell by classes and instances)). there are memory management, pointers, side-effects, but you can do what you want, it behaves as expected and you dont have to learn (in a academic paper) how to use an array or how to do io. Haskell has a difficult learning curve. I remember the first few times I looked at the type signatures for the methods of Data.IArray and it was certainly not at all clear! :-) In the worst case, you can always use the FFI to link with some C if there is some especially
Re: [Haskell-cafe] what do you think of haskell ? (yes, it's a bit general ...:)
minh thu wrote: but i consider to move back to c/c++. I'm led to believe that you just haven't got the hang of the things that just aren't there in C, such as Monads and higher order functions. So you cannot yet see what you would miss in C. (And I guess, you're not feeling at home in C++ either, since there is no language named C/C++.) Whatever, if you believe a person can only master a single programming language, it might as well be C for you... * array : if i want to write something involving array, i could use list, and a lot (too much!) of array types (io/st, mutable/immutable, c-friendly (storable). I've never understood peoples preoccupation with arrays. You lose all flexibility just for O(1) lookup and O(1) destructive(!) update. Most of the time you're better served with a finite map. worst, code involving one type can need to be rewritten for another type. Huh? It doesn't, that's the point of the overloaded IArray/MArray interface! * laziness / array (again) always with array code, i was forced (maybe it's because i dont know enough) to use iouarray : if not, performance|memory consumption were low|high. You're putting unevaluated thunks into your data structure, probably accumulating them there. Bringing out the sledge hammer of IOUArray only obscures the problem. You should 'seq' data before writeArray'ing it. * randomIO but the threading of the randomIO argument is really not explicit for me : it just means that the underlying/threaded state in the IO monad can encapsulated a lot of things. Duh, don't use IO if you neither like nor need it. Most random functions are no IO actions for a reason. e.g. writing myfunction x1 .. xn | x1 `seq` ... False = undefined is not declarative But it isn't all that bad either... (and i still have to learn to identify where it helps and where it doesn't) ...while this is the real problem. You have to understand lazy evaluation to make beneficial use of 'seq'. It really helps to reproduce some reductions on paper. the c language take some more time to learn at the beginning but that's it! Oh come on, you cannot honestly believe that. If so, please send me some chunk of nontrivial C code, I send you back at least one location where it produces undefined behaviour. Yes, I'm confident that I'll find some. did you had the same feeling ? does it disappear ? how ? Never had that feeling, because C is just too ugly. It will disappear once you really understand lazy evaluation. Udo. signature.asc Description: Digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] do we have something like isDefined or isNullin Haskell?
On Thursday, June 15, 2006 8:07 PM Clifford Beshers wrote: On another note, who picked the word `Just' for this type and how did we end up with Some x | None in O'Caml and Just x | Nothing in Haskell? I've always thought this is one of the most charming things about Haskell, along with the use of the quaint word otherwise. It's so friendly and conversational compared to the cold logicality of OCaml or the shoutyness of SML's SOME and NONE eg a phone call to a relative: callee: Who's that? caller: Don't worry, it's Just me! at school: teacher: What did you just say? pupil: Nothing in a shop: Haskeller: I'll just buy some crisps OCamler: I'll buy some packet of crisps SMLer: I'll buy SOME packet of crisps Regards, Brian. -- Logic empowers us and Love gives us purpose. Yet still phantoms restless for eras long past, congealed in the present in unthought forms, strive mightily unseen to destroy us. http://www.metamilk.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Fibonacci numbers generator in Haskell
G'day all. Quoting Vladimir Portnykh [EMAIL PROTECTED]: I wrote my own Fibonacci numbers generator: fib :: Int - [Int] fib 0 = [0,0] fib 1 = [1,0] fib n = [sum prevFib, head prevFib] where a = fib (n - 1) To get the k-th number you do the following: result = head (fib k) [...] Can we do better? Sure we can. We can use a more efficient algorithm: fib :: Integer - Integer fib k | k 0 = error fib | otherwise = fst (fib' k) fib' :: Integer - (Integer,Integer) fib' 0 = (0,1) fib' k | k `mod` 2 == 0 = let (a,b) = fib' (k `div` 2 - 1) c = a + b c2 = c*c in (c2 - a*a, c2 + b*b) | otherwise = let (a,b) = fib' ((k-1) `div` 2) c = a+b a2 = a*a in (b*b + a2, c*c - a2) Cheers, Andrew Bromage ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Fibonacci numbers generator in Haskell
How about the closed form ;) -- fib x returns the x'th number in the fib sequence fib :: Integer - Integer fib x = let phi = ( 1 + sqrt 5 ) / 2 in truncate( ( 1 / sqrt 5 ) * ( phi ^ x - phi' ^ x ) ) Seems pretty quick to me, even with sqrt and arbitrarily large numbers. On 6/15/06 9:33 AM, Vladimir Portnykh [EMAIL PROTECTED] wrote: Fibonacci numbers implementations in Haskell one of the classical examples. An example I found is the following: fibs :: [Int] fibs = 0 : 1 : [ a + b | (a, b) - zip fibs (tail fibs)] To get the k-th number you do the following: Result = fibs !! k It is elegant but creates a list of all Fibonacci numbers less than k-th, and the code is not very readable :). I wrote my own Fibonacci numbers generator: fib :: Int - [Int] fib 0 = [0,0] fib 1 = [1,0] fib n = [sum prevFib, head prevFib] where a = fib (n - 1) To get the k-th number you do the following: result = head (fib k) It does not generate full list of Fibonacci numbers, but keeps only 2 previous numbers, and has only one recursive call. Because the list always has only 2 elements using the functions head and sum is a bit overkill. Can we do better? _ Are you using the latest version of MSN Messenger? Download MSN Messenger 7.5 today! http://join.msn.com/messenger/overview ___ 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] Fibonacci numbers generator in Haskell
Mathew Mills [EMAIL PROTECTED] writes: -- fib x returns the x'th number in the fib sequence fib :: Integer - Integer fib x = let phi = ( 1 + sqrt 5 ) / 2 phi' = ( 1 - sqrt 5 ) / 2 in truncate( ( 1 / sqrt 5 ) * ( phi ^ x - phi' ^ x ) ) -- Seems pretty quick to me, even with sqrt and arbitrarily large numbers. You don't actually need the part with phi'^x. Since |phi'| 1, phi'^x gets small fast as x increases. In fact |phi'^x| is always smaller than 1/2, so -phi'^x in the expression above can be replaced by +0.5. Unfortunately with arbitrarily large numbers it gets the answer wrong. Arbitrarily large in this case is smaller than 100. fib 100 354224848179261800448 The correct answer is 354224848179261915075 The relative error is very small, so it is a good approximation. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe