Re: [Haskell-cafe] haddock - 'could not find link destination
On Thu, Jan 21, 2010 at 3:06 PM, Daniel Fischer daniel.is.fisc...@web.de wrote: But I find it easier to let Cabal deal with haddock, make a Cabal package, runghc ./Setup.hs configure --user --prefix=$HOME runghc ./Setup.hs haddock --hyperlink-source If you use a Cabal package in conjunction with cabal-install it saves you even more typing: cabal configure cabal haddock --hyperlink-source ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Is Haskell capable of matching C in string processing performance?
Don Stewart wrote: jmillikin: Here's the fastest Haskell version I could come up with. It discards all error handling, validation, and correctness in the name of performance, but still can't get anywhere near C: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=16423 Thanks for posting the code. You're not using bytestrings?? They were invented to deal with the problem of [Char] being a poor structure for large scale string processing, and you should have no problem getting C-like string performance. http://www.cse.unsw.edu.au/~dons/papers/CSL06.html In my limited experience, ByteStrings are great for reading data, but not that good for writing data that is being generated on the fly. For writing, good old difference lists or the Builder monoid / Put monad from Data.Binary seem to be best. Regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] hsql won't install due to system.time
add old-time-1.0.0.2 to the _end_ of the build-depends line: cabal: haskelldb-hsql-sqlite3.cabal:7: Parse of field 'build-depends' failed. This is a cabal issue. Get a newer cabal and retry. Marc Weber ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] RE: ssh ports for monk and nun?
From: libraries-boun...@haskell.org [mailto:libraries-boun...@haskell.org] On Behalf Of Stefan Monnier Trying to get ssh working via putty from behind my company firewall. My recommendation is to get access to an outside machine where you run an OpenVPN server on port 80 or 443. This will solve it once and for all. But first, please complain loudly and repeatedly about the firewall being closed to port 22. Tried and failed. Our firewall will be closed to port 22 for the forseaable future. I'll give the OpenVPN thing a go, if I can find some time. I'm wondering about a couple of things: 1. how many people (in the haskell community) have the same problem? How have they solved or worked around the problem? 2. is it possible to run SSH daemons on monk and nun on ports 80 or 443? I'm wondering both from a technical feasability POV, and also an administrative POV i.e. if it were technically feasible, would the admins be open to the idea, if there was sufficient demand? Thanks, Alistair * Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. * ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] hsql won't install due to system.time
Hello, Could this be a global/user install issue? That is, if the old-time package is installed per-user, and you're trying to install a package globally, the user-installed packages all show up as hidden, because they can't be dependencies of a global install. This shows up frequently because global installs are the default when doing runghc Setup.hs install, but per-user installs are the default for cabal install. If you use both of these commands, you'll run into this sooner or later. You can run ghc-pkg list to get a listing of what's installed where. If old-time is only in the local database, you should reinstall it into the global database (or install everything globally). Cheers, John From: Brian Denheyer bri...@aracnet.com Database/HaskellDB/HSQL.hs:25:7: Could not find module `System.Time': it is a member of the hidden package `old-time-1.0.0.3' it is a member of the hidden package `old-time-1.0.0.2' Use -v to see a list of the files searched for. old-time-1.0.0.2 is installed (via cabal). Suggestions on how to fix this or which haskell db (for sqlite3) package will actually install greatly appreciated. I get a lot of failures in hackages which involve that dreaded hidden package message. Anybody care to enlighten us mere mortals as to why it seems to occur so frequently (at least for me). Brian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] RE: ssh ports for monk and nun?
On Fri, Jan 22, 2010 at 11:38 AM, Bayley, Alistair alistair.bay...@invesco.com wrote: ... Tried and failed. Our firewall will be closed to port 22 for the forseaable future. I'll give the OpenVPN thing a go, if I can find some time. Trying to ask how to pierce your company's firewall in a public mailing list, even from your company's email address, may not be advisable. Cristiano ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Non-termination due to context
Hello all! Consider the following program: {-# LANGUAGE FlexibleInstances, OverlappingInstances, UndecidableInstances #-} class B a = A a instance A Int class Eq a = B a instance (A a, Eq a) = B a eq :: B a = a - a - Bool eq = (==) test = 1 `eq` (2::Int) (This is a condensed version of a much larger program that I've been debugging.) It compiles just fine, but `test` doesn't terminate (GHCi 6.10.4). If I change the context `B a` to `Eq a` for the function `eq`, it terminates. Although I don't know all the details of the class system, it seems unintuitive that I can make a program non-terminating just by changing the context of a function (regardless of UndecidableInstances etc.). Is this a bug or a feature? / Emil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Existential Types (I guess)
Dear Cafe, I can write and use the following, data IntHolder = IntHolder Integer instance Show IntHolder where show (IntHolder n) = show n liftInt :: (Integer - Integer) - IntHolder - IntHolder liftInt f (IntHolder c) = IntHolder (f c) But I cannot generalise it to *Num:* data NumHolder = forall a. Num a = NumHolder a instance Show NumHolder where show (NumHolder n) = show n liftNum :: (Num a) = (a - a) - NumHolder - NumHolder liftNum f (NumHolder c) = NumHolder (f c) The error message I get is the following: Couldn't match expected type `a' against inferred type `a1' `a' is a rigid type variable bound by the type signature for `liftNum' at Lifts.hs:54:16 `a1' is a rigid type variable bound by the constructor `NumHolder' at Lifts.hs:55:11 In the first argument of `f', namely `c' In the first argument of `NumHolder', namely `(f c)' In the expression: NumHolder (f c) Regards, -- Ozgur Akgun ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Existential Types (I guess)
Ozgur Akgun wrote: data NumHolder = forall a. Num a = NumHolder a instance Show NumHolder where show (NumHolder n) = show n liftNum :: (Num a) = (a - a) - NumHolder - NumHolder liftNum f (NumHolder c) = NumHolder (f c) The problem here is that you declare that liftNum will work for any single type a, decided (effectively) by the caller of the function. But if the caller chooses Int for a, and your NumHolder has a Float inside it, that isn't going to work. You need to take a function that will work for any Num type a: liftNum :: (forall a. Num a = a - a) - NumHolder - NumHolder liftNum f (NumHolder c) = NumHolder (f c) This uses Rank2Types, but that's necessary for what you want. By moving the forall from being implicit at the start of the signature to inside the brackets, you declare that this is a function that works for all types a (that are a member of type-class Num). This should compile and work as you wanted. Neil. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Non-termination due to context
On Fri, Jan 22, 2010 at 12:24:37PM +0100, Emil Axelsson wrote: Consider the following program: {-# LANGUAGE FlexibleInstances, OverlappingInstances, UndecidableInstances #-} class B a = A a instance A Int class Eq a = B a instance (A a, Eq a) = B a [...] Although I don't know all the details of the class system, it seems unintuitive that I can make a program non-terminating just by changing the context of a function (regardless of UndecidableInstances etc.). Is this a bug or a feature? I'm afraid you voided the warranty when you used UndecidableInstances. You really do have a circularity between A and B here, so it's not surprising that you get a loop. By changing the context, you demanded more instances, undecidable ones in fact. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] RE: ssh ports for monk and nun?
From: cristiano.pa...@gmail.com [mailto:cristiano.pa...@gmail.com] On Behalf Of Cristiano Paris On Fri, Jan 22, 2010 at 11:38 AM, Bayley, Alistair alistair.bay...@invesco.com wrote: ... Tried and failed. Our firewall will be closed to port 22 for the forseaable future. I'll give the OpenVPN thing a go, if I can find some time. Trying to ask how to pierce your company's firewall in a public mailing list, even from your company's email address, may not be advisable. Well, I wasn't necessarily looking for that kind of advice, more along the lines of how to work with what I have (which is ports 80 and 443, via an http proxy server). I have been able to use CVS+SSH with sourceforge in the past, because they had cvs servers that listened for SSH connections on port 443. Alistair * Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. * ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Non-termination due to context
Ross Paterson r...@soi.city.ac.uk writes: I'm afraid you voided the warranty when you used UndecidableInstances. I like this term of phrase. Maybe it should be used in the actual documentation? ;-) -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Existential Types (I guess)
Aside from Neil's point about rank-2 polymorphism, you can of course just parameterise your NumHolder type... data Num a = NumHolder a = NumHolder a instance Show a = Show NumHolder a where show (NumHolder x) = show x instance Functor NumHolder where fmap f (NumHolder a) = NumHolder (f a) It depends what you want to do with your NumHolder though. What is the purpose of this type? Bob On Fri, Jan 22, 2010 at 11:31 AM, Ozgur Akgun ozgurak...@gmail.com wrote: Dear Cafe, I can write and use the following, data IntHolder = IntHolder Integer instance Show IntHolder where show (IntHolder n) = show n liftInt :: (Integer - Integer) - IntHolder - IntHolder liftInt f (IntHolder c) = IntHolder (f c) But I cannot generalise it to *Num:* data NumHolder = forall a. Num a = NumHolder a instance Show NumHolder where show (NumHolder n) = show n liftNum :: (Num a) = (a - a) - NumHolder - NumHolder liftNum f (NumHolder c) = NumHolder (f c) The error message I get is the following: Couldn't match expected type `a' against inferred type `a1' `a' is a rigid type variable bound by the type signature for `liftNum' at Lifts.hs:54:16 `a1' is a rigid type variable bound by the constructor `NumHolder' at Lifts.hs:55:11 In the first argument of `f', namely `c' In the first argument of `NumHolder', namely `(f c)' In the expression: NumHolder (f c) Regards, -- Ozgur Akgun ___ 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: Haskell XML Toolbox Version 8.5.0
Haskell XML Toolbox 8.5.0 I would like to announce a new version of the Haskell XML Toolbox. The main change in this release is the separation of the XPath module and the XSLT module into separate packages hxt-xpath and hxt-xslt. So the base package becomes a bit smaller. Installation shouldn't become more complex because of the easy install with cabal and hackage. A second major change concerns the XPath module. The internal data structures, especially the XPath node-sets, have been refactored for runtime efficiency. So even complex XPath expressions with ambiguous paths to single nodes run in acceptable time. The source repositories have been converted to the git version control system. There is a single git repository for all HXT packages at http://git.fh-wedel.de/repos/hxt.git; More information and also downloads can be found at http://www.fh-wedel.de/~si/HXmlToolbox/index.html There's also a copy of all packages on Hackage. Please email comments, bugs, etc. to hxmltool...@fh-wedel.de or s...@fh-wedel.de Uwe -- University of Applied Sciences, Wedel, Germany http://www.fh-wedel.de/~si/index.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is Haskell capable of matching C in string processing performance?
The following snippet of code ran ~ 33% faster than yours on my computer (GHC 6.10.4, OSX): import qualified Data.ByteString.Char8 as S import qualified Data.ByteString.Lazy as L import System.IO null_str = S.pack null main = withBinaryFile out2.json WriteMode $ \h - do hPutStr h [ L.hPutStr h . L.fromChunks . replicate 500 $ null_str hPutStr h ] The following snippet ran in roughly the same speed (which should not be surprising, as it is essentially the same code): import Control.Monad import qualified Data.ByteString.Char8 as S import System.IO null_str = S.pack null main = withBinaryFile out3.json WriteMode $ \h - do hPutStr h [ replicateM_ 500 (S.hPutStr h null_str) hPutStr h ] This C snippet ran ~ 6 times faster than the Haskell snippets: #include stdio.h int main() { int i; FILE* f = fopen(outc.json,w); fprintf(f,[); for (i = 0; i 500; ++i) fprintf(f,null); fprintf(f,]); } It seems to me this indicates that the big expense here is the call into the I/O system. Cheers, Greg On Jan 21, 2010, at 10:09 PM, John Millikin wrote: Recently I've been working on a library for generating large JSON[1] documents quickly. Originally I started writing it in Haskell, but quickly encountered performance problems. After exhausting my (meager) supply of optimization ideas, I rewrote some of it in C, with dramatic results. Namely, the C solution is * 7.5 times faster than the fastest Haskell I could write (both using raw pointer arrays) * 14 times faster than a somewhat functional version (uses monads, but no explicit IO) * 30 times faster than fancy functional solutions with iteratees, streams, etc I'm wondering if string processing is simply a Haskell weak point, performance-wise. The problem involves many millions of very small (10 character, usually) strings -- the C solution can copy directly from string literals into a fixed buffer and flush it occasionally, while even the fastest Haskell version has a lot of overhead from copying around arrays. Dons suggested I was doing it wrong, so I'm posting on -cafe in the hopes that somebody can tell me how to get better performance without resorting to C. Here's the fastest Haskell version I could come up with. It discards all error handling, validation, and correctness in the name of performance, but still can't get anywhere near C: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=16423 [1] http://json.org/ ___ 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] Non-termination due to context
Ross Paterson skrev: On Fri, Jan 22, 2010 at 12:24:37PM +0100, Emil Axelsson wrote: Consider the following program: {-# LANGUAGE FlexibleInstances, OverlappingInstances, UndecidableInstances #-} class B a = A a instance A Int class Eq a = B a instance (A a, Eq a) = B a [...] Although I don't know all the details of the class system, it seems unintuitive that I can make a program non-terminating just by changing the context of a function (regardless of UndecidableInstances etc.). Is this a bug or a feature? I'm afraid you voided the warranty when you used UndecidableInstances. You really do have a circularity between A and B here, so it's not surprising that you get a loop. By changing the context, you demanded more instances, undecidable ones in fact. But still, I've always heard that undecidable instances can cause the type checker to loop, but if the compiler terminates, you're fine. Here the loop happens at run time, so undecidable instances must be a little more evil than I thought... / Emil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Non-termination due to context
It's a feature! You have * B is a superclass of A * Eq is a superclass of B So every A dictionary has a B dictionary inside it, and every B dictionary has an Eq dictionary inside it. Now, your instance declaration instance (A a, Eq a) = B a says if you give me an A dictionary and an Eq dictionary, I'll make you a B dictionary. Now, 'test' needs a (B Int) dictionary. To get one, we need an (A Int) dictionary and an (Eq Int) dictionary. But when solving these sub-problems, GHC assumes that you have in hand a solution to the original problem, this case (B Int) Why? Read the SYB3 paper. OK so now you see the problem: we can solve the (A Int) and (Eq Int) sub-problems by selection from the (B Int) dictionary. Still, I confess that I have not fully grokked the relationship between the SYB3-style recursion stuff and the question of superclasses. So I will think about your example some more, thank you. Meanwhile, it's clear that you are on thin ice. Simon | -Original Message- | From: haskell-cafe-boun...@haskell.org [mailto:haskell-cafe-boun...@haskell.org] On | Behalf Of Emil Axelsson | Sent: 22 January 2010 11:25 | To: Haskell Cafe | Subject: [Haskell-cafe] Non-termination due to context | | Hello all! | | Consider the following program: | | {-# LANGUAGE FlexibleInstances, OverlappingInstances, UndecidableInstances #-} | | class B a = A a | | instance A Int | | class Eq a = B a | | instance (A a, Eq a) = B a | | eq :: B a = a - a - Bool | eq = (==) | | test = 1 `eq` (2::Int) | | (This is a condensed version of a much larger program that I've been | debugging.) | | It compiles just fine, but `test` doesn't terminate (GHCi 6.10.4). If I | change the context `B a` to `Eq a` for the function `eq`, it terminates. | | Although I don't know all the details of the class system, it seems | unintuitive that I can make a program non-terminating just by changing | the context of a function (regardless of UndecidableInstances etc.). | | Is this a bug or a feature? | | / Emil | | ___ | 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] Spelling checker exercise
Am Freitag 22 Januar 2010 07:51:27 schrieb Matthew Phillips: Hello all, sorry to bring up an old chestnut, but I’m trying to improve my Haskell-fu by writing a small program, and chose Peter Norvig’s spelling checker as my exercise material (http://norvig.com/spell-correct.html). While I’ve gotten it working, and found it quite illuminating, I also found it to to be very slow. And then I discovered that, of course, others have been here well before me ([1] and [2]). Those discussions were very interesting, but the code they refer to is mostly not available, so the most I’ve gotten out of it so far is that: (a) I should be using strict left folds and strict Map insertions for the word frequency map (this shaved off about a second: ~5s - ~4s for a single word on my 2.4GHz MacBook Pro, GHC 6.10.4) (b) I should probably be using ByteString’s That does help, but the worst part is building the map. That takes a couple of seconds in Python, too. Just building the map takes 1.95s for Python, 3.6s (including GC) with strict ByteStrings, 4.2s with lazy ByteStrings and 6s with plain Strings here. So I'd go with strict ByteStrings, although that takes a little more memory than lazy, but waay less than Strings. (c) Using Set’s for the edit permutations probably isn’t worth it (although I found using plain lists made it about a second slower) Might make a difference once you need to take two edit steps on a not very short word. (b) is difficult because I’ve used matching patterns plus list comprehensions to generate the potential edits, and I really like how elegantly it pans out that way. Because ByteString’s are not lists, I can’t see a way to keep the current structure and use them. Train with ByteStrings, then do the edits on Strings and pack for lookup. The code is at [3] (link to version at time of post). Profiling [4] shows: $ ./spelling becuase +RTS -p becuase - because $ cat spelling.prof total time = 4.02 secs (201 ticks @ 20 ms) total alloc = 1,544,257,792 bytes (excludes profiling overheads) COST CENTREMODULE %time %alloc train Main 52.7 19.7 readFile Main 28.98.6 wordsByMain 10.9 49.5 toLowerMain 7.0 21.8 ... So it appears that “train (building the freq map) and “readFile” in “nwords are the places to hone. readFile does not appear in my profile. If you insert an SCC for updateMap, where updateMap model word = {-# SCC updateMap #-} insertWith' (+) word 1 model , you'll see that the really bad citizen is updateMap (splitWords is rather bad, too, together they take some 95% of the time in that profile). But once you start needing two edits (try korrekt), correct and edits1 start to show up. That shows that Norvig's algorithm isn't really good. With two edit steps, you create a _lot_ of strings you need to look up, far more than there are in the map. That takes time. It'll be better to scan the map for entries with an edit distance ( 3) if you have a good method to check that (http://old.nabble.com/haskell-in-online-contests-td26546989.html contains pointers for that). Another thing is allWords = keysSet wordCounts Ouch. For each correction, you construct that set anew. Just use member from Data.Map instead of Data.Set.member and look up the words in the map. I will look at using Bloom Filters or Trie’s instead of Data.Map, but I wonder if readFile should be taking nearly %30 of the run time, even for a 6MB file? No way. But it doesn't seem to, from my GHC's point of view. Sorry to dump such a long post on the list — I’ll understand if no one can be bothered rehashing this. But, in summary I’d like to know: (a) how could I use ByteString’s for this to speed up I/O and reduce memory usage without losing the nice readability? A small rewrite of your code, I would have designed it slightly differently for using ByteStrings from the beginning, the packing in known and known_edits2 isn't too beautiful. -- {-# LANGUAGE BangPatterns #-} module Main (main) where import qualified Data.ByteString.Char8 as B import Data.Char (toLower) import Data.Map (Map, findWithDefault, insertWith', member) import qualified Data.Map as Map (empty) import Data.Set as Set (Set, fromList, toList, fold, null) import Data.List (inits, tails, foldl') import System.Environment (getArgs) dataFile = big.txt alphabet = abcdefghijklmnopqrstuvwxyz splitWords :: B.ByteString - [B.ByteString] splitWords = filter (not . B.null) . B.splitWith isNogud . B.map toLower isNogud :: Char - Bool isNogud c = c 'a' || 'z' c train :: [B.ByteString] - Map B.ByteString Int train = foldl' updateMap Map.empty where updateMap model word = insertWith' (+) word 1
Re: [Haskell-cafe] problems installing ghc-6.12.1-x86_64
On Thu, Jan 21, 2010 at 18:17, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: Andrew Polonsky andrew.polon...@gmail.com writes: Help!! I am trying to build 6.12 on a fresh 64-bit Ubuntu, with no GHC installed yet. The compiler itself builds happily, but when I try to make install the Haskell platform, I eventually get the error The Haskell Platform is currently for GHC 6.10.4, not 6.12.1. Assuch, there's no guarantees. Ah, that makes sense of course. But what about cabal? Is it possible to get cabal working without having the ghc package installed? Isn't there a way to set the whole thing up from the latest GHC, without dependence on distribution repositories? Thanks again, Andrew ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] hsql won't install due to system.time
On Fri, 22 Jan 2010 11:17:15 + John Lato jwl...@gmail.com wrote: Hello, Could this be a global/user install issue? That is, if the old-time package is installed per-user, and you're trying to install a package globally, the user-installed packages all show up as hidden, because they can't be dependencies of a global install. This shows up frequently because global installs are the default when doing runghc Setup.hs install, but per-user installs are the default for cabal install. If you use both of these commands, you'll run into this sooner or later. You can run ghc-pkg list to get a listing of what's installed where. If old-time is only in the local database, you should reinstall it into the global database (or install everything globally). I knew this looked familiar ! It's the dreaded Debian/Global Local conflict problem. Some packages which I can't install using cabal I install Debian packages for, which install globally. Then, naturally, there are Debian packages which won't install (running unstable :-) so I used cabal for those and they install locally. I thought it would be better to keep it local to avoid conflicts, so much for that theory. I basically use Debian for two reasons: to get ghc and to get cabal. After that it seems to me a better idea to stick with cabal rather than the debian packages. Well I know what I'm doing this weekend :-) Thanks very much (everyone) for the help. Brian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Is Haskell capable of matching C in string processing performance?
From: Heinrich Apfelmus apfel...@quantentunnel.de Don Stewart wrote: jmillikin: Here's the fastest Haskell version I could come up with. It discards all error handling, validation, and correctness in the name of performance, but still can't get anywhere near C: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=16423 Thanks for posting the code. You're not using bytestrings?? They were invented to deal with the problem of [Char] being a poor structure for large scale string processing, and you should have no problem getting C-like string performance. http://www.cse.unsw.edu.au/~dons/papers/CSL06.html In my limited experience, ByteStrings are great for reading data, but not that good for writing data that is being generated on the fly. For writing, good old difference lists or the Builder monoid / Put monad from Data.Binary seem to be best. If find that this is particularly true if you don't know the length of data to write in advance because it involves lots of new allocations and copying. Using Builder/Put is definitely a better approach. Out of curiousity, has anyone ever tried implementing a LinkedListString in C to check what its performance would be? I expect it would be pretty poor compared to standard strings. Cheers, John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is Haskell capable of matching C in string processing performance?
It seems to me this indicates that the big expense here is the call into the I/O system. So let's make fewer I/O calls: import Control.Monad import qualified Data.ByteString.Char8 as S import System.IO null_str1 = S.concat $ take 1000 $ repeat $ S.pack null n1 = 500 `div` 1000 main = withBinaryFile out3.json WriteMode $ \h - do hPutStr h [ replicateM_ n1 (S.hPutStr h null_str1) hPutStr h ] --- this is 10x faster. Whether this is cheating or not depends on what John actually wants to do. Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] haddock - error
the problem with me getting no haddock output whatsoever was that i had not reconfigured cabal after replacing haddock 2.4 by 2.5 (by installing it with cabal). it would be helpful if there were an error message - but i can clearly see that this is difficult to achieve in this case. thanks for the help! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Existential Types (I guess)
OK, I wasn't storing a simple (Num a) in my holder data structure, it was more of a thing implementing one of my type classes. So it knows how to quack, and I can use it now, thanks to Neil's suggestion. I have a (somewhat) heterogeneus list of values, belonging to the same type class, and I just wanted to map a function to that list. Now it works. BTW Tom, Thanks for your suggestion, but it simply doesn't fit my needs this time. But I'll keep your suggestion in mind. Cheers guys! 2010/1/22 Tom Davie tom.da...@gmail.com Aside from Neil's point about rank-2 polymorphism, you can of course just parameterise your NumHolder type... data Num a = NumHolder a = NumHolder a instance Show a = Show NumHolder a where show (NumHolder x) = show x instance Functor NumHolder where fmap f (NumHolder a) = NumHolder (f a) It depends what you want to do with your NumHolder though. What is the purpose of this type? Bob On Fri, Jan 22, 2010 at 11:31 AM, Ozgur Akgun ozgurak...@gmail.comwrote: Dear Cafe, I can write and use the following, data IntHolder = IntHolder Integer instance Show IntHolder where show (IntHolder n) = show n liftInt :: (Integer - Integer) - IntHolder - IntHolder liftInt f (IntHolder c) = IntHolder (f c) But I cannot generalise it to *Num:* data NumHolder = forall a. Num a = NumHolder a instance Show NumHolder where show (NumHolder n) = show n liftNum :: (Num a) = (a - a) - NumHolder - NumHolder liftNum f (NumHolder c) = NumHolder (f c) The error message I get is the following: Couldn't match expected type `a' against inferred type `a1' `a' is a rigid type variable bound by the type signature for `liftNum' at Lifts.hs:54:16 `a1' is a rigid type variable bound by the constructor `NumHolder' at Lifts.hs:55:11 In the first argument of `f', namely `c' In the first argument of `NumHolder', namely `(f c)' In the expression: NumHolder (f c) Regards, -- Ozgur Akgun ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Ozgur Akgun ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] classes with types which are wrapped in
i encounter often a problem when i have a class with some operations (say class X with push) applied to a type A b. I then wrap A in a type A_sup, with some more type parameters and i cannot write a instance of class A_sup because i have a kind mismatch. any suggestions? (reordering of the type parameters of A_sup is not a solution, because another class operates on this parameter) here a simplistic case (i know that A could be reduced to [], my real cases are more complicated). data A b = A b [b] data Asup x ab y = Asup x ab y class X a b where push :: b - a b - a b instance X A Int where push b' (A b bs) = A b' (b:bs) instance X Asup Char Int Float where push b' (Asup a b c) = Asup a (push b' b) c -- this does not compile because the number of type arguments for X is wrong. if i try with a type type A_2 b = Asup Char (A b) Float instance X A_2 Int where push b' (Asup a b c) = Asup a (push b' b) c (and --TypeSynonymInstances) i get: Type synonym `A_2' should have 1 argument, but has been given 0 In the instance declaration for `X A_2 Int' what is the solution? thank you! andrew ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] classes with types which are wrapped in
Wrap it in a newtype. That's the only way I know. Andrew U. Frank wrote: i encounter often a problem when i have a class with some operations (say class X with push) applied to a type A b. I then wrap A in a type A_sup, with some more type parameters and i cannot write a instance of class A_sup because i have a kind mismatch. any suggestions? (reordering of the type parameters of A_sup is not a solution, because another class operates on this parameter) here a simplistic case (i know that A could be reduced to [], my real cases are more complicated). data A b = A b [b] data Asup x ab y = Asup x ab y class X a b where push :: b - a b - a b instance X A Int where push b' (A b bs) = A b' (b:bs) instance X Asup Char Int Float where push b' (Asup a b c) = Asup a (push b' b) c -- this does not compile because the number of type arguments for X is wrong. if i try with a type type A_2 b = Asup Char (A b) Float instance X A_2 Int where push b' (Asup a b c) = Asup a (push b' b) c (and --TypeSynonymInstances) i get: Type synonym `A_2' should have 1 argument, but has been given 0 In the instance declaration for `X A_2 Int' what is the solution? thank you! andrew ___ 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] classes with types which are wrapped in
On Fri, Jan 22, 2010 at 05:08:15PM +0100, Andrew U. Frank wrote: i encounter often a problem when i have a class with some operations (say class X with push) applied to a type A b. I then wrap A in a type A_sup, with some more type parameters and i cannot write a instance of class A_sup because i have a kind mismatch. any suggestions? (reordering of the type parameters of A_sup is not a solution, because another class operates on this parameter) here a simplistic case (i know that A could be reduced to [], my real cases are more complicated). data A b = A b [b] data Asup x ab y = Asup x ab y class X a b where push :: b - a b - a b This is a little strange. Are you sure you don't want either class X a where push :: b - a b - a b or class X a b where push :: b - a - a ? The second one might help you with your subsequent problem (although I didn't understand quite what you were trying to do there). Regards, Reid Barton ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Web application interface
Hello, In happstack, there is a Writer monad which holds a list of filters which will be applied to the Response before sending it out. One of these filters is the gzip filter. The compression filters are defined here: http://patch-tag.com/r/mae/happstack/snapshot/current/content/pretty/happstack-server/src/Happstack/Server/Parts.hs The filters are apply when runWebT is called: http://patch-tag.com/r/mae/happstack/snapshot/current/content/pretty/happstack-server/src/Happstack/Server/SimpleHTTP.hs runWebT is called automatically by the top-level function, simpleHTTP, that people actually call in their programs. We do not do anything fancy to cache gzip results to the disk. We don't even assume you *have* a disk. I believe that functionality could be added as a 3rd party library with out modifying core happstack. That is how we would prefer to see it done so that the core is simple, and so that people can implement their own caching system if their needs are different. - jeremy On Jan 21, 2010, at 10:37 PM, Michael Snoyman wrote: Hey Jeremy, I was just wondering: how does Happstack deal with gzip encoding when it uses sendfile? I can think of a few ways (cache gziped versions to the disk), but was wondering if you'd already come up with a good solution. I'm trying to keep all these things in mind when designing WAI. Thanks, Michael On Thu, Jan 14, 2010 at 5:42 PM, Jeremy Shaw jer...@n-heptane.com wrote: Hello, Happstack is currently bundled with it's own lazy I/O based HTTP backend. Ideally, we would like to split that out, and allow happstack to be used with that backend, hyena, or other options. A primary using for using hyena would be for the benefits of predictability and constant space usage that iterators bring. People do actually running into the issues that come with lazy I/O, such as running out of file descriptors, etc. So, I feel like I would want to stick with using iterators the whole way when using hyena, and not convert back to a lazy ByteString? Happstack now includes support for sendfile(). This is done by adding another constructor to the Response type: (line 94): http://patch-tag.com/r/mae/happstack/snapshot/current/content/pretty/happstack-server/src/Happstack/Server/HTTP/Types.hs Then here on line 197, we match on that case and use sendfile to send the data: http://patch-tag.com/r/mae/happstack/snapshot/current/content/pretty/happstack-server/src/Happstack/Server/HTTP/Handler.hs This makes it difficult for use to be compatible with WAI. We can write a wrapper that converts the sendfile case to use lazy bytestrings instead, but then we lose the advantages of using sendfile. I wonder if the 'Response' portion of WAI should support all three currently used methods: - lazy I/O - Enumerator - sendFile I haven't really thought about how that would work.. hyena currently includes a Network.WAI which uses ByteString: http://hackage.haskell.org/packages/archive/hyena/0.1/doc/html/Network-Wai.html gotta run, sorry about any typos! - jeremy On Jan 13, 2010, at 8:46 AM, Michael Snoyman wrote: Hi, I recently read (again) the wiki page on a web application interface[1] for Haskell. It seems like this basically works out to Hack[2], but using an enumerator instead of lazy bytestring in the response type. Is anyone working on implementing this? If not, I would like to create the package, though I wouldn't mind some community input on some design decisions: * Hack has been fairly well-tested in the past year and I think it provides the features that people want. Therefore, I would want to model the Environment variable for WAI from Hack. I *could* just import Hack in WAI and use the exact same Environment data type. Thoughts? * If using a different data type for Environment, should I replace the String parts with ByteStrings? On the one hand, ByteStrings are the correct data type since the HTTP protocol does not specify a character encoding; on the other hand, Strings are easier to deal with. * It's simple to write a function to convert between a lazy bytestring and an enumerator, meaning it would be very easy to write conversion functions between Hack and WAI applications. This would make it simpler for people to use either backend. If someone else is already working on WAI, please let me know, I don't want to have duplicate implementations. The idea here is to consolidate, not split the community. I have a few Hack handlers (simpleserver, cgi, fastcgi) that I would happily convert to WAI handlers as well. Michael [1] http://www.haskell.org/haskellwiki/WebApplicationInterface [2] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hack ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___
Re: [Haskell-cafe] Is Haskell capable of matching C in string processing performance?
Correct me if I'm wrong, but ByteStrings can't contain non-ASCII values, right? I'm looking for something like this pseudo-C: typedef void (*Callback)(const uint32_t *chars, size_t n_chars, void *); WriterState *new_state (Callback, void *); I tried using the Text type, but its conversions to Ptr Word16 are all O(n) -- not much better than String. On Thu, Jan 21, 2010 at 22:28, Don Stewart d...@galois.com wrote: jmillikin: Here's the fastest Haskell version I could come up with. It discards all error handling, validation, and correctness in the name of performance, but still can't get anywhere near C: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=16423 Thanks for posting the code. You're not using bytestrings?? They were invented to deal with the problem of [Char] being a poor structure for large scale string processing, and you should have no problem getting C-like string performance. http://www.cse.unsw.edu.au/~dons/papers/CSL06.html -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] classes with types which are wrapped in
Hi Andrew, Andrew U. Frank wrote: here a simplistic case (i know that A could be reduced to [], my real cases are more complicated). data A b = A b [b] data Asup x ab y = Asup x ab y class X a b where push :: b - a b - a b instance X A Int where push b' (A b bs) = A b' (b:bs) instance X Asup Char Int Float where push b' (Asup a b c) = Asup a (push b' b) c If I understand you correctly, what you want here are type level lambdas. Abusing notation: instance X (\t - Asup Char t Float) Int where push b' (Asup a b c) = Asup a (push b' b) c However, type level lambdas introduce lots of ambiguities and are therefore AFAIK not supported in haskell[1]. if i try with a type type A_2 b = Asup Char (A b) Float instance X A_2 Int where push b' (Asup a b c) = Asup a (push b' b) c (and --TypeSynonymInstances) i get: Type synonym `A_2' should have 1 argument, but has been given 0 In the instance declaration for `X A_2 Int' However, this error message looks strange. I tried to reduce this to a simpler case[1] and got the same message. Does anyone know why it complains just about the number of type arguments (which is correct) ? -- Steffen [1] http://www.mail-archive.com/haskell-cafe@haskell.org/msg69579.html [2] http://ideone.com/9BAj7MG7 (note that ideone is using ghc-6.8) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is Haskell capable of matching C in string processing performance?
There's no such thing as cheating, though that particular code won't work for my purposes because it assumes the output is merely a stream of null. Fine for the benchmark, but not extractable to the full problem. I wonder: is Handle known to be particularly slow? This code only has to work on Linux and BSD, so if using (for example) a POSIX fd would be much faster, it could bring the Haskell version much closer to C. On Fri, Jan 22, 2010 at 07:30, Tom Nielsen taniel...@gmail.com wrote: It seems to me this indicates that the big expense here is the call into the I/O system. So let's make fewer I/O calls: import Control.Monad import qualified Data.ByteString.Char8 as S import System.IO null_str1 = S.concat $ take 1000 $ repeat $ S.pack null n1 = 500 `div` 1000 main = withBinaryFile out3.json WriteMode $ \h - do hPutStr h [ replicateM_ n1 (S.hPutStr h null_str1) hPutStr h ] --- this is 10x faster. Whether this is cheating or not depends on what John actually wants to do. Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is Haskell capable of matching C in string processing performance?
jmillikin: There's no such thing as cheating, though that particular code won't work for my purposes because it assumes the output is merely a stream of null. Fine for the benchmark, but not extractable to the full problem. I wonder: is Handle known to be particularly slow? This code only has to work on Linux and BSD, so if using (for example) a POSIX fd would be much faster, it could bring the Haskell version much closer to C. Just make sure you're using the same data types and IO methods as in C, and you'll get the same performance. For serializing/writing to packed data, Data.Binary or cereal are a good choice for building bytestrings efficiently, which in turn can be output quickly via bytestring IO. -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Why no merge and listDiff?
Will Ness schrieb: Christian Maeder Christian.Maeder at dfki.de writes: Will Ness schrieb: I meant strictly increasing ordered lists, without multiples, for which the two operations, 'merge' and 'minus', would also have to produce like lists, i.e strictly increasing, without multiples. Why don't you use directly Data.Set? It says it's based on size balanced Trees? I initially wondered why no such fundamental operations as merge and minus for _lists_, in the stadard libraries? Yes, balanced trees, which makes insertion and member testing O(log n). Also, its to/from list conversions are O(n), so probably won't work for infinite lists. One should not convert much from and to list, but always use operations on sets directly. Sets are finite. I wonder what fundamental advantage there is for infinite strictly increasing lists. I was told the trend is to move specifics to hackage packages, but I wonder why shouldn't such fundamental operations be just included in standard Data.List? Both the current Set operations of Data.List and the (so many) functions from Data.Ordlist are only useful for short lists (or other special purposes) because of efficiency. Furthermore, there is some risk that the invariant of lists being (strictly) sorted is violated by accident (programming-error). The ...By-functions allow to further confuse orders. There are also bags aka multisets: http://hackage.haskell.org/package/multiset it's too seems to be based on trees. Yes. Data.Ordlist seems to be a good match, except for its conflation of ascending/non-decreasing lists under one ordered category (i.e. sets/bags distinction). If you say, these should be two separate module, I would agree. Cheers Christian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] classes with types which are wrapped in
Am Freitag 22 Januar 2010 17:08:15 schrieb Andrew U. Frank: i encounter often a problem when i have a class with some operations (say class X with push) applied to a type A b. I then wrap A in a type A_sup, with some more type parameters and i cannot write a instance of class A_sup because i have a kind mismatch. any suggestions? (reordering of the type parameters of A_sup is not a solution, because another class operates on this parameter) here a simplistic case (i know that A could be reduced to [], my real cases are more complicated). data A b = A b [b] data Asup x ab y = Asup x ab y That doesn't match its use below, perhaps data Asup x ab y = Asup x (A ab) y (matches better with A_2) or use Asup Char (A Int) Float below? class X a b where push :: b - a b - a b How about type families? class Y a where type Pushy a :: * push :: Pushy a - a - a instance Y (A Int) where type Pushy (A Int) = Int push b' (A b bs) = A b' (b:bs) instance Y (Asup Char (A Int) Float) where type Pushy (Asup Char (A Int) Float) = Int push b' (Asup a b c) = Asup a (push b' b) c instance X A Int where push b' (A b bs) = A b' (b:bs) instance X Asup Char Int Float where push b' (Asup a b c) = Asup a (push b' b) c Missing instance X Int Int, but Int has wrong kind for that :) -- this does not compile because the number of type arguments for X is wrong. if i try with a type type A_2 b = Asup Char (A b) Float instance X A_2 Int where push b' (Asup a b c) = Asup a (push b' b) c (and --TypeSynonymInstances) i get: Type synonym `A_2' should have 1 argument, but has been given 0 In the instance declaration for `X A_2 Int' what is the solution? thank you! andrew ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Non-termination due to context
Here's the relevant core for this file (GHC 6.10.4, so I'm a bit out of date): Rec { $dB_rh6 :: Undec.B GHC.Types.Int [GlobalId] [] $dB_rh6 = $dB_rh6 end Rec } Undec.test :: GHC.Bool.Bool [GlobalId] [] Undec.test = GHC.Classes.== @ GHC.Types.Int ($dB_rh6 `cast` ((Undec.:Co:TB) GHC.Types.Int :: (Undec.:TB) GHC.Types.Int ~ (GHC.Classes.:TEq) GHC.Types.Int)) (GHC.Types.I# 1) (GHC.Types.I# 2) The cast is saying that the dictionary for B is equivalent to the dictionary for Eq (an optimization for empty classes with one superclass, I guess). $dB_rh6 is the dictionary for B Int. GHC 'solves' this into a classic looping program. I'm not sure how the derivation for this dictionary goes. -- ryan so, given an A we can just pull the dictionary out of it On Fri, Jan 22, 2010 at 3:24 AM, Emil Axelsson e...@chalmers.se wrote: Hello all! Consider the following program: {-# LANGUAGE FlexibleInstances, OverlappingInstances, UndecidableInstances #-} class B a = A a instance A Int class Eq a = B a instance (A a, Eq a) = B a eq :: B a = a - a - Bool eq = (==) test = 1 `eq` (2::Int) (This is a condensed version of a much larger program that I've been debugging.) It compiles just fine, but `test` doesn't terminate (GHCi 6.10.4). If I change the context `B a` to `Eq a` for the function `eq`, it terminates. Although I don't know all the details of the class system, it seems unintuitive that I can make a program non-terminating just by changing the context of a function (regardless of UndecidableInstances etc.). Is this a bug or a feature? / Emil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe undec.core Description: Binary data ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] http://trac.haskell.org down?
Been trying to reach http://trac.haskell.org for most of the morning, but nothing comes up. Seems I'm not alone: http://downforeveryoneorjustme.com/http://trac.haskell.org James -- Neurogami - Smart application development http://www.neurogami.com ja...@neurogami.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] http://trac.haskell.org down?
Hi community.haskell.org is down as well :-( Thanks, Neil On Fri, Jan 22, 2010 at 8:41 PM, James Britt ja...@neurogami.com wrote: Been trying to reach http://trac.haskell.org for most of the morning, but nothing comes up. Seems I'm not alone: http://downforeveryoneorjustme.com/http://trac.haskell.org James -- Neurogami - Smart application development http://www.neurogami.com ja...@neurogami.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
Re: [Haskell-cafe] http://trac.haskell.org down?
Am Freitag 22 Januar 2010 23:06:03 schrieb Neil Mitchell: Hi community.haskell.org is down as well :-( $ host trac.haskell.org trac.haskell.org is an alias for community.haskell.org. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] could we get a Data instance for Data.Text.Text?
Hello, Would it be possible to get a Data instance for Data.Text.Text? This would allow us to create a Serialize instance of Text for use with happstack -- which would be extremely useful. We (at seereason) are currently using this patch: http://src.seereason.com/haskell-text-debian/debian/patches/add_Data_instance.patch which basically adds: +textType = mkStringType Data.Text + +instance Data Text where + toConstr x = mkStringConstr textType (unpack x) + gunfold _k z c = case constrRep c of + (CharConstr x) - z (pack [x]) + _ - error gunfold for Data.Text + dataTypeOf _ = textType + This particular implementation avoids exposing the internals of the Data.Text type by casting it to a String in toConstr and gunfold. That is similar to how Data is implemented for some numeric types. However, the space usage of casting in Float to a Double is far less than casting a Text to a String, so maybe that is not a good idea? Alternatively, Data.ByteString just does 'deriving Data'. However, bytestring also exports Data.ByteString.Internal, wheres Data.Text.Internal is not exported. Any thoughts? I would like to get this handled upstream so that all happstack users can benefit from it. - jeremy ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC bug? Cabal bug? Haddock bug?
2010/1/17 Mark Lentczner ma...@glyphic.com: AHA! Note that after running cabal haddock we re-build all of our .hi and .o files EXCEPT ./dist/build/HSsyb-with-class-0.6.1.o And now, since TH generates random symbols, we have symbols in the new .hi files that aren't in the old (and only) HSsyb-with-class-0.6.1.o. So, this leaves us with two questions: 1) Why does cabal haddock rebuild the .hi and .o files? On the face of it, this seems odd: Build documentation and your library gets rebuilt? Maybe this has already been answered elsewhere: when TH is involved Haddock may rebuild your library. In this case Cabal is directing Haddock's output to the same place that is used for normal builds. This bug has been fixed in Cabal. 2) Why doesn't Instances.o get rebuilt? Surely this has something to do with the fact that Instances.hs contains only orphan instances. But any answer here just leads to a raft of other questions: Surely this problem would plague other modules have have similar source files? What is Haddock doing? If Haddock needs the .hi files, why not just use them? If it just builds them to be sure, why in the dist tree and not some place temporary? If is going to build .o files, why not all? Not sure why Instances.o isn't rebuilt. David ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is Haskell capable of matching C in string processing performance?
I would say that counts as cheating because it assumes that knowledge of the input in advance. However, I wonder how it would perform if there were a reChunk function that lazily built a new lazy ByteString by merging smaller chunks together --- i.e., it would keep pullings chunks from the ByteString until it reached some threshold size, merge them into a single strict ByteString chunk, and then recursively continue processing the rest of the lazy ByteString in this manner. Cheers, Greg On Jan 22, 2010, at 7:30 AM, Tom Nielsen wrote: It seems to me this indicates that the big expense here is the call into the I/O system. So let's make fewer I/O calls: import Control.Monad import qualified Data.ByteString.Char8 as S import System.IO null_str1 = S.concat $ take 1000 $ repeat $ S.pack null n1 = 500 `div` 1000 main = withBinaryFile out3.json WriteMode $ \h - do hPutStr h [ replicateM_ n1 (S.hPutStr h null_str1) hPutStr h ] --- this is 10x faster. Whether this is cheating or not depends on what John actually wants to do. Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Why no merge and listDiff?
On Wed, Jan 20, 2010 at 9:42 AM, Will Ness will_...@yahoo.com wrote: Derek Elkins derek.a.elkins at gmail.com writes: On Sun, Jan 17, 2010 at 2:22 PM, Will Ness will_n48 at yahoo.com wrote: Hello cafe, I wonder, if we have List.insert and List.union, why no List.merge (:: Ord a = [a] - [a] - [a]) and no List.minus ? These seem to be pretty general operations. Presumably by List.minus you mean the (\\) function in Data.List. No, it has to search its second list over and over from the start, to be able to deal with unordered lists, so its performance can't be good. Then use the ordlist one. You probably also want to look at the package data-ordlist on hackage (http://hackage.haskell.org/packages/archive/data-ordlist/0.0.1/doc/html/Data- OrdList.html) which represents sets and bags as ordered lists and has all of the operations you mention. I did, thanks again! Although, that package deals with non-decreasing lists, i.e. lists with multiples possibly. As such, its operations produce non- decreasing lists, i.e. possibly having multiples too. It is clear that some of the operations are guaranteed to produce sets given sets. The documentation could be better in this regard though. I meant strictly increasing ordered lists, without multiples, for which the two operations, 'merge' and 'minus', would also have to produce like lists, i.e strictly increasing, without multiples. The 'union' and 'minus' functions of ordlist meet this requirement if you satisfy the preconditions. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] http://trac.haskell.org down?
We've contacted the hosting company, who had an upgrade last night. Hopefully back up in the next hour. ndmitchell: Hi community.haskell.org is down as well :-( Thanks, Neil On Fri, Jan 22, 2010 at 8:41 PM, James Britt ja...@neurogami.com wrote: Been trying to reach http://trac.haskell.org for most of the morning, but nothing comes up. Seems I'm not alone: http://downforeveryoneorjustme.com/http://trac.haskell.org James -- Neurogami - Smart application development http://www.neurogami.com ja...@neurogami.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 mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: could we get a Data instance for Data.Text.Text?
On Fri, Jan 22, 2010 at 2:24 PM, Jeremy Shaw jer...@n-heptane.com wrote: Would it be possible to get a Data instance for Data.Text.Text? From the last time this came up, I gather that the correctish thing to do (for reasons too obscure to me) is to teach SYB and its many cousins about Text, or else there'll be some sort of disturbance in the Force. If that feels too arduous, I'd consider adding your suggested instance of Data until such time as the One True Generics Package emerges to walk the earth. But please give it a think first. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANN: bindings-DSL 1.0.4 (Category: FFI)
Hi, bindings-DSL is a mature and well documented preprocessor domain specific language you can use to generate bindings to a C API. It's based on functionality provided by hsc2hs. These are links to Hackage page and documentation: http://hackage.haskell.org/package/bindings-DSL http://bitbucket.org/mauricio/bindings-dsl New in this version: * Support for C unions. * Use of inttypes.h macros for wider portability. An example on the use of unions follow. Suppose you have: union example { int k; char c[4]; }; Then, using bindings-DSL, you'll write: #starttype union example #union_field k , CInt #union_array_field c , CChar #stoptype Here is a ghci session showing the resulting code: let value = C'example 1 [] u'example'k value (2^10) C'example {c'example'k = 1024, c'example'c = [0,4,0,0]} u'example'c value [1,0,0,0] C'example {c'example'k = 1, c'example'c = [1,0,0,0]} u'example'c value [0,0,0,1] C'example {c'example'k = 16777216, c'example'c = [0,0,0,1]} Peeking an uninitialized memory address: v - alloca $ \p - peek p :: IO C'example v C'example {c'example'k = 81842189, c'example'c = [13,-48,-32,4]} Hope it's useful to you. Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe