[Haskell-cafe] Dealing with CStringLen
Hi, How is CStringLen supposed to be used? The only usual C string I'm familiar with is the null terminated sequence of chars. I remember some Pascal version where the first 2 bytes were used as an integer counting the following characters. What is the convention used in Foreign.C.String? I have a C function signature like this: void function (int,const void*,int,const void*) where each (int,const void*) pair is a string. Can (should) I use CStringLen here? How? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell Quick Reference (1-page PDF)
Malcolm.Wallace: > Some time ago, there was a thread about a "CheatSheet" for Haskell > beginners. As I recall, the CheatSheet was more than 12 pages long. > > For a Haskell tutorial I was running at a conference recently, I needed > a "Quick Reference Guide" that would fit onto a single side of A4. So I > knocked one together quickly, and it is attached as a PDF. I send it to > this list, with permission for anyone to distribute it more widely as > they wish, in the hope that it might be useful. > wonderful. recorded on the wiki, http://haskell.org/haskellwiki/Image:QuickReference.pdf ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell Weekly News: Issue 92 - November 8, 2008
--- Haskell Weekly News http://sequence.complete.org/hwn/20081108 Issue 92 - November 08, 2008 --- Welcome to issue 92 of HWN, a newsletter covering developments in the [1]Haskell community. GHC 6.10 is released!! Go forth and drool over its new features. Be sure to have the editline libraries (libedit-dev on Debian/Ubuntu, for example) installed before you try building it. Announcements GHC version 6.10.1. Ian Lynagh [2]announced the release of [3]GHC version 6.10.1! This new major release features a number of significant changes, including wild-card patterns, punning, and field disambiguation in record syntax; generalised quasi-quotes; generalised SQL-like list comprehensions; view patterns; a complete reimplementation of type families; parallel garbage collection; a new extensible exception framework; a more user-friendly API; included Data Parallel Haskell (DPH); and more! See [4]the full release notes for more information. new community.haskell.org features: webspace, mailing lists. Ian Lynagh [5]announced that the community server, http://community.haskell.org/, has two new features for hosted projects: project webspace, and project mailing lists. GHC blog. Simon Marlow [6]has set up a [7]GHC blog. This is for all things related to GHC, particularly people working on GHC to blog about what they're up to. If you want a write-bit, sign up for a [8]wordpress account, let Simon know your account name, and blog away! The GHC blog should be syndicated on [9]Planet Haskell soon. Haddock 2.4.0. David Waern [10]announced a [11]new release of [12]Haddock, the Haskell documentation tool. This is a later version than the one shipped with GHC 6.10.1, which is version 2.3.0. That version will not be released on Hackage since it only builds with GHC 6.10.1 (by accident, actually). Besides adding back support for earlier GHC versions, this release contains some more fixes and support for HTML frames. htags-1.0. David Sankel [13]announced the [14]htags package, a tag file generator to enable extra functionality in editors like vim. It expands upon hasktags by using a full Haskell 98 parser and options for recursion. Haskell Quick Reference (1-page PDF). Malcolm Wallace [15]sent a 1-page Haskell quick reference prepared for a recent Haskell tutorial. Permission is granted for anyone to distribute it more widely as they wish, in the hope that it might be useful. Editable sources can be passed along if anyone would like to extend it. Proposal for associated type synonyms in Template Haskell. Thomas van Noort [16]submitted a proposal for adding associated type synonyms to Template Haskell. Comments are welcomed. announce [("InfixApplicative", 1.0), ("OpenGLCheck", 1.0), ("obj", 0.1)]. Thomas Davie [17]announced the upload of a few packages to Hackage which he has produced while working at Anygma. [18]obj-0.1 is a library for loading and writing obj 3D models; [19]OpenGLCheck-1.0 is a micro-package containing instances of Arbitrary for the data structures provided in Graphics.Rendering.OpenGL; and [20]InfixApplicative-1.0 is a second micro-package containing a pair of functions (<^) and (^>) which can be used to provide an infix version of liftA2 applied to an operator. Graphalyze-0.5 and SourceGraph-0.3. Ivan Lazar Miljenovic [21]announced the latest versions of [22]Graphalyze and [23]SourceGraph, which fix a couple of bugs in the previous versions. zlib and bzlib 0.5 releases. Duncan Coutts [24]announced updates to the [25]zlib and [26]bzlib packages, featuring a slightly nicer extended API. The simple API that most packages use is unchanged. There is also a new parameter to control the size of the first output buffer; this lets applications save memory when they happen to have a good estimate of the output size. Discussion Efficient parallel regular expressions. Martijn van Steenbergen [27]asked about efficiently running multiple regular expressions in parallel, leading to an interesting discussion of regular expressions and various parsing methods and libraries. Problems with strictness analysis?. Patai Gergely started an informative [28]discussion about strictness, laziness, strictness analysis, and compiler optimization. If you don't know a lot about these topics but would like to learn, this thread is a good starting point! Jobs 1-year postdoc position in Chalmers Functional Programming group. John Hughes [29]announced a position for a post-doctoral researcher with the Chalmers Functional Programming Group, with a one-year tax-free stipend funded by Intel. The funded project will develop a Do
Re: [Haskell-cafe] view patterns
Hi everyone, Yes, the current overlap checker thinks all view patterns are overlapped. The pattern overlap/exhaustiveness checker needs to be rewritten to account for GADTs and view patterns. You can use -fno-warn-overlapping-patterns to suppress these warning (along with any actual overlaps, though, unfortunately). -Dan On Nov05, Cale Gibbard wrote: > 2008/11/5 Cetin Sert <[EMAIL PROTECTED]>: > > :1:4: > > Warning: Pattern match(es) are overlapped > > In the definition of `emp': > > emp ((has -> True)) = ... > > emp ((has -> False)) = ... > > > > Why do I get this error in ghc or when I try to compile a file with view > > patterns? > > (using -fglasgow-exts and -XViewPatterns, ghc 6.10.1) > > This is a bug which appears to be known about: > http://hackage.haskell.org/trac/ghc/ticket/2395 > > - Cale > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANNOUNCE: gitit 0.2 release - wiki using HAppS, git, pandoc
I've uploaded an early version of gitit, a Haskell wiki program, to HackageDB. Gitit uses HAppS as a webserver, git for file storage, pandoc for rendering the (markdown) pages, and highlighting-kate for highlighted source code. Some nice features of gitit: - Pages and uploaded files are stored in a git repository and may be added, deleted, and modified directly using git. - Pages may be organized into subdirectories. - Pandoc's extended version of markdown is used, so you can do tables, footnotes, syntax-highlighted code blocks, and LaTeX math. (And you can you pandoc to convert pages into many other formats.) - Math is rendered using jsMath (which must be installed separately). - Source code files in the repository are automatically rendered with syntax highlighting (plain/text version is also available). You can check it out on my webserver: http://johnmacfarlane.net:5001/ Or try it locally: cabal update cabal install pandoc -fhighlighting cabal install gitit gitit # note: this will create two subdirectories in the working directory # then browse to http://localhost:5001. There's a git repository at http://github.com/jgm/gitit/tree/master. Comments and patches are welcome. John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] generalized list comprehensions
Looking at this funny new feature http://haskell.org/ghc/docs/6.10.1/html/users_guide/syntax-extns.html#generalised-list-comprehensions I have just one question - why doesn't this work with the do-notation? I avoid list comprehensions because I feel that "return" belongs at the end, not in front. If I recall correctly, "putting the SQL-select where it belongs" is a slogan used by Hijlsberg to justify the LINQ syntax for C#, and of course he is right. Now ghc copies LINQ (syntactically), but stops halfway? Just wondering - J.W. signature.asc Description: OpenPGP digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
re: [Haskell-cafe] ANNOUNCE: rewriting-0.1
Thomas, Did you explore nominal rewrite at all? Do you know if it might be possible to use the scrap-your-nameplate package to implement some useful subset of the nominal rewrite machinery? Best wishes, --greg -- L.G. Meredith Managing Partner Biosimilarity LLC 806 55th St NE Seattle, WA 98105 +1 206.650.3740 http://biosimilarity.blogspot.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] generalized list comprehensions
2008/11/8 Johannes Waldmann <[EMAIL PROTECTED]>: > Looking at this funny new feature > http://haskell.org/ghc/docs/6.10.1/html/users_guide/syntax-extns.html#generalised-list-comprehensions > I have just one question - why doesn't this work with the do-notation? > > I avoid list comprehensions because I feel that > "return" belongs at the end, not in front. > > If I recall correctly, "putting the SQL-select where it belongs" > is a slogan used by Hijlsberg to justify the LINQ syntax for C#, > and of course he is right. > > Now ghc copies LINQ (syntactically), but stops halfway? Hi Johannes, There is no technical reason the syntax could not be extended to do notation - see the discussion by Michael Adams on the http://haskell.org/haskellwiki/Simonpj/Talk:ListComp page for a taste of how that would work (note that his translation is however not totally correct, IIRC). The only reason that I didn't actually implement this feature is that neither I nor SPJ could think of a use case for this syntax outside the list monad. I don't think we considered the possibility you might use do notation for the list monad, as it's not an idiom that seems to occur often. If you can come up with such a use case I could probably find the time to implement the extra translation steps! On reflection, it does seem a bit like an annoying irregularity to the implementation. Cheers, Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Dealing with CStringLen
Maurício wrote: Hi, How is CStringLen supposed to be used? The only usual C string I'm familiar with is the null terminated sequence of chars. I remember some Pascal version where the first 2 bytes were used as an integer counting the following characters. What is the convention used in Foreign.C.String? the docs (via Hoogle) tell me: withCStringLen :: String -> (CStringLen -> IO a) -> IO a type CStringLen = (Ptr CChar, Int) I have a C function signature like this: void function (int,const void*,int,const void*) where each (int,const void*) pair is a string. Can (should) I use CStringLen here? How? seems an approprate use case for withCStringLen, yes, as long as you take care with character encodings: " The translation between Unicode and the encoding of the current locale may be lossy. " So for a "quick hack" withCStringLen is probably the quickest solution, otherwise something that takes into account Unicode and locales etc would be preferable (I think there are some UTF string packages around, maybe on hackage?). for withCStringLen something like this might work (completely untested!): foreign import ccall "function.h function" function_c :: CInt -> Ptr CChar -> CInt -> Ptr CChar -> IO () function :: String -> String -> IO () function s t = withCStringLen s (\(sp,sl) -> withCStringLen t (\(tp,tl) -> function_c (toEnum sl) sp (toEnum tl) tp ) ) -- where toEnum :: Int -> CInt -- perhaps castPtr is useful depending on import declaration too... Hopefully this is in the right direction, Thanks, Maurício Claude ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] generalized list comprehensions
I don't think we considered the possibility you might use do notation for the list monad, as it's not an idiom that seems to occur often. depends where you look, I guess. (Such questions could in principle be answered automatically by browsing the code on hackage?) As I said, I am avoiding list comprehensions for purely optical reasons (putting the cart before the horse), so I write "do" in the list monad. Of course I prefer "let" to "where" for the same reasons, so for me you could indeed replace "guard" by "where", and "return" by "select", and "x <- foo" by "from x in foo" and it'd look like the real (linq) thing. - Oh, and replace "Monad" by "Workflow". - Not! NB: Wasn't there a time (before "do") when "list" notation (brackets) would work in any monad? And "map" was a method in "Functor", and we had "class Functor m => Monad m", etc. Well well well times have changed. signature.asc Description: OpenPGP digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: gitit 0.2 release - wiki using HAppS, git, pandoc
jgm: > I've uploaded an early version of gitit, a Haskell wiki program, to > HackageDB. Gitit uses HAppS as a webserver, git for file storage, > pandoc for rendering the (markdown) pages, and highlighting-kate for > highlighted source code. Awesome. Well done, as always, John! -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Physics engines purely in Haskell?
mwassell: > Has anyone thought about or embarked on the task of developing a 2D or > 3D physics engine purely in Haskell? > > There is Hipmunk but I'm wondering about a purely Haskell > implementation; possibly a port of Chipmunk to Haskell. http://haskell.org/haskellwiki/Hpysics "Hpysics is a physics engine to be written using Data Parallel Haskell during Google Summer of Code 2008. " ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Physics engines purely in Haskell?
Has anyone thought about or embarked on the task of developing a 2D or 3D physics engine purely in Haskell? There is Hipmunk but I'm wondering about a purely Haskell implementation; possibly a port of Chipmunk to Haskell. Mark ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] FFI documentation?
Where do I find the documentation for the FFI for GHC? I've read the FFI report, the GHC user guide and scoured haskell.org but they all gloss over what commands you actually need to give GHC and how to give them. "foreign import blah blah" just gives me undefined references. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] FFI documentation?
2008/11/8 Nun Aurbiz <[EMAIL PROTECTED]>: > Where do I find the documentation for the FFI for GHC? I've read the FFI > report, the GHC user guide and scoured haskell.org but they all gloss over > what commands you actually need to give GHC and how to give them. "foreign > import blah blah" just gives me undefined references. You need to give the libraries you are using on the command line just like gcc. ghc --make Foo -lbar Luke ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe