Matlab/BLAS/LAPack and Re: [Haskell-cafe] Mathematics in Haskell Re: Why the Prelude must Die
Since I brought this up (search haskell' list) I should probably volunteer to help. If people agree I can coordinate an effort to build a mathematically sound hierarchy. Unfortunately my mathematical knowledge is less than ideal for this purpose (I am actively remedying this at university). However, if there is an administrative burden I volunteer to shoulder it. On a related note I have written a binding to Matlab data files and arrays if anyone is interested, and I am embarking on a project to bind to CBLAS and CLAPack. Vivian Jacques Carette wrote: > >> perhaps i was mistaken in thinking that there is a group of >> math-interested haskellers out there discussing, developing, and >> documenting the area? or perhaps that group needs introductory >> tutorials presenting its work? > My guess is that there are a number of people "waiting in the wings", > waiting for a critical mass of features to show up before really > diving in. See http://www.cas.mcmaster.ca/plmms07/ > for my reasons for being both interested and wary). > > Probably the simplest test case is the difficulties that people are > (still) encountering doing matrix/vector algebra in Haskell. One > either quickly encounters efficiency issues (although PArr might > help), or typing issues (though many tricks are known, but not > necessarily simple). Blitz++ and the STL contributed heavily to C++ > being taken seriously by people in the scientific computation > community. Haskell has even more _potential_, but it is definitely unrealised potential. > I am one of those mathematicians "waiting in the wings." Haskell looked very appealing at first, and the type system seems perfect, especially for things like multilinear algebra where currying and duality is fundamental. I too was put off by the Num issues though--strange mixture of sophisticated category theory and lack of a sensible hierarchy of algebraic objects. However, I've decided I'm more interested in helping to fix it than wait; so count me in on an effort to make Haskell more mathematical. For me that probably starts with the semigroup/group/ring setup, and good arbitrary-precision as well as approximate linear algebra support. -- I've been watching this thread for quite a while now, and it seems to me that there is quite a bit of interest in at least working on a new Prelude. I've also noticed a 'The Other Prelude' page on the wiki [http://haskell.org/haskellwiki/The_Other_Prelude] and they seem to have a start on this. So it seems that we should actually start this, because people will contribute. Can somebody with good Cabal skills and maybe access to darcs.haskell.org start a new library for people to start patching? Bryan Burgers On Apr 2, 2007, at 3:24 PM, Andrzej Jaworski wrote: >> I too was put off by the Num issues though--strange mixture of >> sophisticated >> category theory and lack of a sensible hierarchy of algebraic >> objects. > > Perhaps we should replace CT with lattice theoretic thinking (e.g. > functor = monotonic > function) before cleaning up the type-related mess? > See: http://citeseer.ist.psu.edu/269479.html > >> so count me in on an effort to make Haskell more mathematical. >> For me that >> probably starts with the semigroup/group/ring setup, and good >> arbitrary-precision as well as approximate linear algebra support. > > I agree: semigoups like lattices are everywhere. > Then there could be a uniform treatment of linear algebra, > polynomial equations, operator > algebra, etc. So, perhaps haste is not a good advice here? > > -Andrzej > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Mathematics in Haskell
Wouldn't this be a good discussion for the Haskell Prime List? Reilly Hayes +1 415 388 3903 (office) +1 415 846 1827 (mobile) [EMAIL PROTECTED] On Apr 2, 2007, at 3:24 PM, Andrzej Jaworski wrote: I too was put off by the Num issues though--strange mixture of sophisticated category theory and lack of a sensible hierarchy of algebraic objects. Perhaps we should replace CT with lattice theoretic thinking (e.g. functor = monotonic function) before cleaning up the type-related mess? See: http://citeseer.ist.psu.edu/269479.html so count me in on an effort to make Haskell more mathematical. For me that probably starts with the semigroup/group/ring setup, and good arbitrary-precision as well as approximate linear algebra support. I agree: semigoups like lattices are everywhere. Then there could be a uniform treatment of linear algebra, polynomial equations, operator algebra, etc. So, perhaps haste is not a good advice here? -Andrzej ___ 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] Keeping a symbol table with Parsec
Joel Reymont wrote: Meaning that if a keyword Output is followed by ":" and an identifier and then "(NumericSimple)" then add identifier to the symbol table as a Number and box it in a constructor. Then in my lexer I do a lookup to check if I have seen this identifier and if I have seen one of type TypeNumOut I return the token NUM instead of ID. This ensures that I can have rules with the token NUM as opposed to ID everywhere. I use a set of strings for the symbol table (I don't record the types of the identifiers, but you can add it back). I don't allow for whitespace, but you can add it back. The parser returns a string rather than a constructor with a string, but you can add it back. It is necessary to fuse the lexer and the parser together, so that they share state; but we can fuse them in a way that still leaves recognizable boundary, e.g., in the below, string "blah", ident, num, name, and numeric_simple are lexers (thus when you add back whitespace you know who are the suspects), and p0 is a parser that calls the lexers and do extra. The name lexer returns a sum type, so you can use its two cases to signify whether a name is in the table or not; then ident and num can fail on the wrong cases. (Alternatively, you can eliminate the sum type by copying the name code into the ident code and the num code.) import Text.ParserCombinators.Parsec import Monad(mzero) import Data.Set as Set main = do { input <- getLine ; print (runParser p0 Set.empty "stdin" input) } p0 = do { string "Output" ; string ":" ; i <- ident ; string "(" ; numeric_simple ; string ")" ; updateState (Set.insert i) ; return i } numeric_simple = many digit ident = do { n <- name ; case n of { ID i -> return i ; _ -> mzero } } name = do { c0 <- letter ; cs <- many alphaNum ; let n = c0 : cs ; table <- getState ; return (if n `Set.member` table then NUM n else ID n) } data Name = NUM String | ID String num = do { n <- name ; case n of { NUM i -> return i ; _ -> mzero } } ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Mathematics in Haskell Re: Why the Prelude must die
> I too was put off by the Num issues though--strange mixture of sophisticated > category theory and lack of a sensible hierarchy of algebraic objects. Perhaps we should replace CT with lattice theoretic thinking (e.g. functor = monotonic function) before cleaning up the type-related mess? See: http://citeseer.ist.psu.edu/269479.html > so count me in on an effort to make Haskell more mathematical. For me that > probably starts with the semigroup/group/ring setup, and good > arbitrary-precision as well as approximate linear algebra support. I agree: semigoups like lattices are everywhere. Then there could be a uniform treatment of linear algebra, polynomial equations, operator algebra, etc. So, perhaps haste is not a good advice here? -Andrzej ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Keeping a symbol table with Parsec
On Apr 2, 2007, at 11:17 PM, Nicolas Frisby wrote: Section 2.12 of the Parsec manual[1] discusses "user state." It sounds like that is what you are after. Yes, thanks. My question is mostly about how to "return a different token" when the lexer finds an identifier that's already in the symbol table. -- http://wagerlabs.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Keeping a symbol table with Parsec
Section 2.12 of the Parsec manual[1] discusses "user state." It sounds like that is what you are after. Hope that helps, Nick [1] - http://www.cs.uu.nl/~daan/download/parsec/parsec.pdf On 4/2/07, Joel Reymont <[EMAIL PROTECTED]> wrote: Folks, Are there any examples of keeping a symbol table with Parsec? I'm translating a parser from OCaml and I do this OUTPUT COLON ID LP NUMERIC_SIMPLE RP { add $3 TypNumOut; SimpleOutputDec ($3, Number) } Meaning that if a keyword Output is followed by ":" and an identifier and then "(NumericSimple)" then add identifier to the symbol table as a Number and box it in a constructor. Then in my lexer I do a lookup to check if I have seen this identifier and if I have seen one of type TypeNumOut I return the token NUM instead of ID. This ensures that I can have rules with the token NUM as opposed to ID everywhere. How would I accomplish the same with Parsec, that is 1) update a symbol table and 2) check identifiers and "return a different token"? Thanks, Joel -- http://wagerlabs.com/ ___ 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] Keeping a symbol table with Parsec
Folks, Are there any examples of keeping a symbol table with Parsec? I'm translating a parser from OCaml and I do this OUTPUT COLON ID LP NUMERIC_SIMPLE RP { add $3 TypNumOut; SimpleOutputDec ($3, Number) } Meaning that if a keyword Output is followed by ":" and an identifier and then "(NumericSimple)" then add identifier to the symbol table as a Number and box it in a constructor. Then in my lexer I do a lookup to check if I have seen this identifier and if I have seen one of type TypeNumOut I return the token NUM instead of ID. This ensures that I can have rules with the token NUM as opposed to ID everywhere. How would I accomplish the same with Parsec, that is 1) update a symbol table and 2) check identifiers and "return a different token"? Thanks, Joel -- http://wagerlabs.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Mathematics in Haskell Re: Why the Prelude must die
Jacques Carette wrote: > >> perhaps i was mistaken in thinking that there is a group of >> math-interested >> haskellers out there discussing, developing, and documenting the area? or >> perhaps that group needs introductory tutorials presenting its work? > My guess is that there are a number of people "waiting in the wings", > waiting for a critical mass of features to show up before really diving > in. See > http://www.cas.mcmaster.ca/plmms07/ > for my reasons for being both interested and wary). > > Probably the simplest test case is the difficulties that people are > (still) encountering doing matrix/vector algebra in Haskell. One either > quickly encounters efficiency issues (although PArr might help), or > typing issues (though many tricks are known, but not necessarily > simple). Blitz++ and the STL contributed heavily to C++ being taken > seriously by people in the scientific computation community. Haskell > has even more _potential_, but it is definitely unrealised potential. > I am one of those mathematicians "waiting in the wings." Haskell looked very appealing at first, and the type system seems perfect, especially for things like multilinear algebra where currying and duality is fundamental. I too was put off by the Num issues though--strange mixture of sophisticated category theory and lack of a sensible hierarchy of algebraic objects. However, I've decided I'm more interested in helping to fix it than wait; so count me in on an effort to make Haskell more mathematical. For me that probably starts with the semigroup/group/ring setup, and good arbitrary-precision as well as approximate linear algebra support. I've been watching this thread for quite a while now, and it seems to me that there is quite a bit of interest in at least working on a new Prelude. I've also noticed a 'The Other Prelude' page on the wiki [http://haskell.org/haskellwiki/The_Other_Prelude] and they seem to have a start on this. So it seems that we should actually start this, because people will contribute. Can somebody with good Cabal skills and maybe access to darcs.haskell.org start a new library for people to start patching? Bryan Burgers ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Mathematics in Haskell Re: Why the Prelude must die
Jacques Carette wrote: > >> perhaps i was mistaken in thinking that there is a group of >> math-interested >> haskellers out there discussing, developing, and documenting the area? or >> perhaps that group needs introductory tutorials presenting its work? > My guess is that there are a number of people "waiting in the wings", > waiting for a critical mass of features to show up before really diving > in. See > http://www.cas.mcmaster.ca/plmms07/ > for my reasons for being both interested and wary). > > Probably the simplest test case is the difficulties that people are > (still) encountering doing matrix/vector algebra in Haskell. One either > quickly encounters efficiency issues (although PArr might help), or > typing issues (though many tricks are known, but not necessarily > simple). Blitz++ and the STL contributed heavily to C++ being taken > seriously by people in the scientific computation community. Haskell > has even more _potential_, but it is definitely unrealised potential. > I am one of those mathematicians "waiting in the wings." Haskell looked very appealing at first, and the type system seems perfect, especially for things like multilinear algebra where currying and duality is fundamental. I too was put off by the Num issues though--strange mixture of sophisticated category theory and lack of a sensible hierarchy of algebraic objects. However, I've decided I'm more interested in helping to fix it than wait; so count me in on an effort to make Haskell more mathematical. For me that probably starts with the semigroup/group/ring setup, and good arbitrary-precision as well as approximate linear algebra support. -- View this message in context: http://www.nabble.com/Why-the-Prelude-must-die-tf3457368.html#a9795282 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] String to Word64 Conversion
> [Haskell-cafe] String to Word64 Conversion > Ian Sefferman iseff at iseff.com > Sun Apr 1 15:42:07 EDT 2007 > Previous message: [Haskell-cafe] Josephus problem and style > Next message: [Haskell-cafe] Data.ByteStream.Char8.words performance > Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] > I've been spending a lot of time trying to find a clean way to convert > from a String to a Word64 for the Crypto library. > > Specifically, we're trying to encrypt the strings with Blowfish. The > type for the encrypt function is: > > encrypt :: (Integral a) => a -> Word64 -> Word64 > > I assume I would want something like: > toWord64s :: String -> [Word64] > toWord64s = > > myEncrypt string = map (Blowfish.encrypt myKey) (toWord64s string) > > I would have to imagine that encrypting strings is a fairly common > thing to do, so a conversion should be trivial, but I can't seem to > find anything on it. I feel like I must be missing something rather > obvious here. Am I? > > Thanks, > Ian Ian, Maybe something like this. I've pretty much taken it from http://darcs.haskell.org/crypto/Data/Digest/SHA1.hs. fromBytes :: (Bits a) => [a] -> a fromBytes input = let dofb accum [] = accum dofb accum (x:xs) = dofb ((shiftL accum 8) .|. x) xs in dofb 0 input blockWord8sIn64 :: [Word8] -> [[Word8]] blockWord8sIn64 = unfoldr g where g [] = Nothing g xs = Just (splitAt 8 xs) getWord64s :: [Word8] -> [Word64] getWord64s = map fromBytes . map (map fromIntegral) . blockWord8sIn64 Don't forget you will need to pad http://www.haskell.org/crypto/doc/html/Codec.Encryption.Padding.html. I don't know what your application is but I suggest NOT using ECB mode which your code suggests you are thinking of doing. The only mode currently supported in the crypto library is CBC but other modes should be trivial to add. Dominic. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Binary I/O
Hello Daniel, Monday, April 2, 2007, 6:26:05 PM, you wrote: > however it strikes me that it would be much nicer to the I/O using raw > binary. I don't seem to be able to find much documentation on this. it's our secret weapon ;) http://haskell.org/haskellwiki/Library/Streams http://haskell.org/haskellwiki/Library/AltBinary i'm biased, though, because it's my creation ;) Binary library and hGetArray/hPutArray/hGetBuf/hPutBuf available, too -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Binary I/O
On 02/04/2007, at 16:26, Daniel Brownridge wrote: Hello. I am a Computer Science student attempting to write an emulator using Haskell. One of my main design choices is how to deal with machine code. Clearly it is possible to represent 0's and 1's as ASCII characters, however it strikes me that it would be much nicer to the I/O using raw binary. I don't seem to be able to find much documentation on this. Does anybody know how it's done, or can point me in the direction of some resources. Imho, just read directly to an Array and work with that. Probably you want to look at the OmegaGB Gameboy Emulator project for examples. http://www.mutantlemon.com/omegagb The code for loading ROM images to an Array of Words: http://darcs.mutantlemon.com/omegagb/src/RomImage.hs After that, opcodes are easily parsed by pattern matching on the hexadecimal values, e.g. see the mcti function in the Cpu module: http://darcs.mutantlemon.com/omegagb/src/Cpu.hs It would be nicer to write a Data.Binary instance for the Instruction datatype and use that to do the parsing, but I don't think that loading ROM files is a major speed concern here. Another interesting resource you may want to look at for your emulator code can be ICFPC'06 Universal Machine implementations. Don Stewart has a page with a few highly performant implementations (and there are benchmarks too, yay!): http://www.cse.unsw.edu.au/~dons/um.html Cheers pepe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Binary I/O
On Mon, Apr 02, 2007 at 03:26:05PM +0100, Daniel Brownridge wrote: > Hello. > > I am a Computer Science student attempting to write an emulator using > Haskell. > One of my main design choices is how to deal with machine code. > Clearly it is possible to represent 0's and 1's as ASCII characters, > however it strikes me that it would be much nicer to the I/O using raw > binary. I don't seem to be able to find much documentation on this. > Does anybody know how it's done, or can point me in the direction of > some resources. The current Big Name in Haskell's binary support is the aptly named 'binary' library, available from hackagedb (http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary-0.3). binary works using two sets of functions, one for very efficiently building binary bytestrings (like [Char] -> [Char]): data Builder --abstract empty, append -- monoid ops singleton :: Word8 -> Builder putWord16be :: Word8 -> Builder ... toLazyByteString :: Builder -> ByteString and a monad for parsing binary data: data Get a -- abstract getWord8 :: Get Word8 getWord16be :: Get Word16 ... runGet :: Get a -> ByteString -> a (there's also a higher level interface paterned on Read/Show, but I don't think that's applicable here). Stefan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: ANN: HSH 1.2.0
Well, I guess I spoke to soon. After building ghc6 from feisty as described above, I tried building missingh and have basically what I started with. Is there something I can tweak to get the above straightened out using those nice deb packages, or do I have to do all the dependency chasing involved with building from source? Or is there another way? If this is too debian oriented please yell at me and I will ask about this on a deb/ubuntu forum. thanks... Note, should have mentioned, after doing as my above post describes, I installed all the newly generated deb packages with dpkg -i *.deb [EMAIL PROTECTED]:~/haskellInstalls/missingh>runghc Setup.hs configure Configuring MissingH-0.18.3... configure: /usr/lib/ghc-6.6/bin/ghc-pkg configure: Dependency unix-any: using unix-1.0 Setup.hs: cannot satisfy dependency network-any [EMAIL PROTECTED]:~/haskellInstalls/missingh>which runghc /usr/lib/ghc-6.6/bin/runghc # note, definitely the thing I installed today: [EMAIL PROTECTED]:~/haskellInstalls/missingh>ls -l `which runghc` -rwxr-xr-x 1 root root 300716 Apr 2 09:17 /usr/lib/ghc-6.6/bin/runghc [EMAIL PROTECTED]:~/haskellInstalls/missingh> # and I installed it from deb ghc6, dpkg recognizes it [EMAIL PROTECTED]:~/haskellInstalls/missingh>dpkg -S /usr/lib/ghc-6.6/bin/runghc ghc6: /usr/lib/ghc-6.6/bin/runghc # it does seem like ghc6 comes with a network package [EMAIL PROTECTED]:~/learning/haskell>apt-cache showpkg ghc6 | grep -i network 6.4.1-2ubuntu2 - libghc6-readline-dev libghc6-stm-dev libghc6-hgl-dev libghc6-x11-dev libghc6-fgl-dev libghc6-mtl-dev libghc6-hunit-dev libghc6-quickcheck-dev libghc6-network-dev libghc6-haskell-src-dev libghc6-parsec-dev libghc6-cabal-dev libghc6-unix-dev libghc6-template-haskell-dev libghc6-haskell98-dev libghc6-base-dev libghc6-rts-dev ghc haskell-compiler # I get lost here. Do I have libghc6-network-dev, or don't I? [EMAIL PROTECTED]:~/haskellInstalls/missingh>sudo apt-get install libghc6-network-dev Reading package lists... Done Building dependency tree... Done Note, selecting ghc6 instead of libghc6-network-dev ghc6 is already the newest version. You might want to run `apt-get -f install' to correct these: The following packages have unmet dependencies: hat-ghc6: Depends: ghc6 (< 6.4.1+) but 6.6-3 is to be installed libghc6-cabal-dev: Depends: ghc6 (< 6.4.2) but 6.6-3 is to be installed E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution). 2007/4/2, Thomas Hartman <[EMAIL PROTECTED]>: > As you have built ghc6.6 from sources I think that you also need to build > all haskell libs from sources. So, do I did this, and got the feeling this would probably work, but is a real sad world of dependency chasing with no (clear) end in sight. So I investigated your second suggestion > Another way is to take ghc6 and all haskell libs from fiesty. which to me seems much preferrable. http://old.pupeno.com/blog/unstable-packages-on-ubuntu/ Was indispensible in helping me figure out how to do this. To give some details on this (which is really more apt packaging know how than haskell but whatever), I did something like 1) change /etc/apt/sources.list to add deb-src http://archive.ubuntu.com/ubuntu/ feisty main restricted universe multiverse note, only add deb-src line here, not deb line, see article above for why. sudo aptitude install fakeroot (needed utility) fakeroot apt-get source --build ghc6 -- complains, some dependencies are missing sudo aptitude install . install packages with above command, not from source. it's my first time using the aptitude command, I wonder if this does the same thing as apt-get install, which is what I usually do. Whatever the case... fakeroot apt-get source --build ghc6 works :) 2007/3/21, Max Vasin <[EMAIL PROTECTED]>: > > "Thomas" == Thomas Hartman <[EMAIL PROTECTED]> writes: > > Thomas> Furthermore (as the above messages suggest and locate confirms), I > Thomas> seem to have mtl already > > Thomas> I took a wild guess and tried specifying this with ghc -i > > Thomas> like > > Thomas> sudo runghc -i/usr/lib/ghc6-mtl-dev Setup.lhs configure > Thomas> and sudo runghc -i/usr/lib/ Setup.lhs configure > > Thomas> but no dice. > > Thomas> *** > > Thomas> [EMAIL PROTECTED]:~/haskellInstalls/hsh$ locate libghc6-mtl-dev > Thomas> /home/thartman/libghc6-mtl-dev_1.0-3_i386.deb > Thomas> /usr/lib/libghc6-mtl-dev > Thomas> /usr/lib/libghc6-mtl-dev/register.sh > Thomas> /usr/lib/libghc6-mtl-dev/unregister.sh > Thomas> /usr/share/doc/libghc6-mtl-dev > Thomas> /usr/share/doc/libghc6-mtl-dev/changelog.Debian.gz > Thomas> /usr/share/doc/libghc6-mtl-dev/copyright > Thomas> /var/lib/dpkg/info/libghc6-mtl-dev.list > Thomas> /var/lib/dpkg/info/libghc6-mtl-dev.md5sums > Thomas> /var/lib/dpkg/info/libghc6-mtl-dev.postinst > Thomas> /var/lib/dpkg/info/libghc6-mtl-dev.prerm > > As you have built ghc6.6 from sources I think that you also need to build > all haskell libs f
[Haskell-cafe] Binary I/O
Hello. I am a Computer Science student attempting to write an emulator using Haskell. One of my main design choices is how to deal with machine code. Clearly it is possible to represent 0's and 1's as ASCII characters, however it strikes me that it would be much nicer to the I/O using raw binary. I don't seem to be able to find much documentation on this. Does anybody know how it's done, or can point me in the direction of some resources. Many thanks Daniel ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Memory leak in streaming parser
On Mon, 2007-04-02 at 13:54 +0100, Malcolm Wallace wrote: An observation about your state setter functions, ... You can shorten your code considerably by using the standard named-field update syntax for exactly this task: setDecision :: String -> State -> State setDecision decision state = state { sDecision = decision } If I do that, the run time insists on the state being "more" evaluated before it changes that specific field. This kills streaming, enforcing each production (including the top one) to be fully parsed before I can access its generated tokens. So the GC won't be hanging on to State objects, but memory still explodes - with unconsumed Token objects. And there's no output from the program until it dies :-( Not only is it shorter, but it will often be much more efficient, since the entire structured value is copied once once, then a single field updated, rather than being re-built piece-by-piece in 15 steps. I know! Is there an efficient way to lazily modify just one field record? You probably want to be strict in the state component, but not in the output values of your monad. So as well as replacing let ... in (finalState, rightResult) with let ... in finalState `seq` (finalState, rightResult) in the (>>=) method in your Monad instance (and in the separate defn of For some strange reason, adding this didn't solve the problem - the GC still refuses to collect the state objects. BTW, forcing the evaluation of the intermediate states (originalState, leftState, rightState etc.) doesn't help either. I have tried to ensure that when '>>=' and '/' will allow the GC to discard old states "as soon as possible", but I'm obviously missing something. Is there a way to get more detailed retainer information than what's available with '-hr'? you might also need to make all the named fields of your State datatype strict. If I make any of them strict, streaming goes away :-( Writing a streaming parser in Haskell is turning out to be much harder than I originally expected. Every fix I tried so far either broke streaming (memory blows up due to tokens) or had no effect (memory blows up due to states). I am assuming that there's a magic point in the middle where tokens are consumed and states are GC-ed... but it has eluded me so far. Thanks, Oren Ben-Kiki P.S. I uploaded the package to Hackage. I added a debug-leak production to make it easier to profile this with even less productions involved. ``yes '#' | yaml2yeast -p debug-leak''. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: ANN: HSH 1.2.0
As you have built ghc6.6 from sources I think that you also need to build all haskell libs from sources. So, do I did this, and got the feeling this would probably work, but is a real sad world of dependency chasing with no (clear) end in sight. So I investigated your second suggestion Another way is to take ghc6 and all haskell libs from fiesty. which to me seems much preferrable. http://old.pupeno.com/blog/unstable-packages-on-ubuntu/ Was indispensible in helping me figure out how to do this. To give some details on this (which is really more apt packaging know how than haskell but whatever), I did something like 1) change /etc/apt/sources.list to add deb-src http://archive.ubuntu.com/ubuntu/ feisty main restricted universe multiverse note, only add deb-src line here, not deb line, see article above for why. sudo aptitude install fakeroot (needed utility) fakeroot apt-get source --build ghc6 -- complains, some dependencies are missing sudo aptitude install . install packages with above command, not from source. it's my first time using the aptitude command, I wonder if this does the same thing as apt-get install, which is what I usually do. Whatever the case... fakeroot apt-get source --build ghc6 works :) 2007/3/21, Max Vasin <[EMAIL PROTECTED]>: > "Thomas" == Thomas Hartman <[EMAIL PROTECTED]> writes: Thomas> Furthermore (as the above messages suggest and locate confirms), I Thomas> seem to have mtl already Thomas> I took a wild guess and tried specifying this with ghc -i Thomas> like Thomas> sudo runghc -i/usr/lib/ghc6-mtl-dev Setup.lhs configure Thomas> and sudo runghc -i/usr/lib/ Setup.lhs configure Thomas> but no dice. Thomas> *** Thomas> [EMAIL PROTECTED]:~/haskellInstalls/hsh$ locate libghc6-mtl-dev Thomas> /home/thartman/libghc6-mtl-dev_1.0-3_i386.deb Thomas> /usr/lib/libghc6-mtl-dev Thomas> /usr/lib/libghc6-mtl-dev/register.sh Thomas> /usr/lib/libghc6-mtl-dev/unregister.sh Thomas> /usr/share/doc/libghc6-mtl-dev Thomas> /usr/share/doc/libghc6-mtl-dev/changelog.Debian.gz Thomas> /usr/share/doc/libghc6-mtl-dev/copyright Thomas> /var/lib/dpkg/info/libghc6-mtl-dev.list Thomas> /var/lib/dpkg/info/libghc6-mtl-dev.md5sums Thomas> /var/lib/dpkg/info/libghc6-mtl-dev.postinst Thomas> /var/lib/dpkg/info/libghc6-mtl-dev.prerm As you have built ghc6.6 from sources I think that you also need to build all haskell libs from sources. So, do $ apt-get source libghc6-mtl-dev $ cd $ runhaskell Setup.lhs configure $ runhaskell Setup.lhs build $ sudo runhaskell Setup.lhs install Another way is to take ghc6 and all haskell libs from fiesty. -- WBR, Max Vasin. ___ 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] Memory leak in streaming parser
"Oren Ben-Kiki" <[EMAIL PROTECTED]> wrote: > I just created an initial version of a "streaming" parser. This parser > is intended to serve as a reference parser for the YAML spec. An observation about your state setter functions, e.g. setDecision :: String -> State -> State setDecision decision state = State { sName = state|>sName, sEncoding = state|>sEncoding, sDecision = decision, sLimit= state|>sLimit, sForbidden= state|>sForbidden, sIsPeek = state|>sIsPeek, sTokens = state|>sTokens, sCommits = state|>sCommits, sConsumed = state|>sConsumed, sChars= state|>sChars, sMessage = state|>sMessage, sLine = state|>sLine, sColumn = state|>sColumn, sCode = state|>sCode, sLast = state|>sLast, sInput= state|>sInput } You can shorten your code considerably by using the standard named-field update syntax for exactly this task: setDecision :: String -> State -> State setDecision decision state = state { sDecision = decision } Not only is it shorter, but it will often be much more efficient, since the entire structured value is copied once once, then a single field updated, rather than being re-built piece-by-piece in 15 steps. > I must have done "too good a job" converting things to lazy form > because, while the parser is streaming, it also hangs on to old state > objects for no "obvious" reason. At least it isn't obvious to me after > profiling it in any way I could think of and trying to `seq` the > "obvious" suspects. Adding a `seq` in the wrong place will of course > stop it from being a streaming parser... You probably want to be strict in the state component, but not in the output values of your monad. So as well as replacing let ... in (finalState, rightResult) with let ... in finalState `seq` (finalState, rightResult) in the (>>=) method in your Monad instance (and in the separate defn of /), you might also need to make all the named fields of your State datatype strict. Regards, Malcolm ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Mutable variables eliminated from .NET | Lambda theUltimate
> To ensure wide penetration of this significant update, Microsoft will be > issuing updated Windows CDs to all licensed customers, free of charge. > The new CDs can be identified by the distinctive holographic "Haskell > Inside" logo, featuring a holographic version of this[1] portrait of Simon > Peyton-Jones, grinning from ear to ear. >From the operating theater point of view Haskell is a donor! In this scenario usually the recipients grin;-) -Andrzej ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe