Re: [Haskell-cafe] Expression problem in the database?
On Mon, Jul 22, 2013 at 4:00 PM, Manuel Gómez tar...@gmail.com wrote: * I could sacrifice relational integrity and store the expression serialized, perhaps as an AST represented in JSON or somesuch — although the rest of the data model is a rather traditional, normalized relational schema, so this is undesirable in my situation if only for consistency. A hybrid solution could be storing the expression as a string on an entity's field *and* creating a new entity for each foreign reference. In order words, instead of storing the whole AST in the database, store it as a list on the database and the whole thing again in a field. -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] getting haddock to cooperate with cpp
Are you using `cabal haddock` or calling haddock manually? Cheers, On Fri, Jul 12, 2013 at 3:25 PM, Evan Laforge qdun...@gmail.com wrote: So haddock ignores {-# LANGUAGE CPP #-}, which makes it crash on any file that uses it. But if you pass --optghc=-cpp, it runs CPP on everything, which makes it crash on any file that uses string gaps, or happens to contain a /*. /* is rare and easily fixed, but not string gaps. It looks like a workaround would be to manually inspect the files for LANGUAGE CPP and run two haddock passes, but then I would have to get the two passes to cooperate creating a single TOC and index. Isn't there some way to run haddock on files that use CPP? In the broader scheme, it seems perverse to be using CPP in the first place. I use it to configure imports and exports, e.g. to swap out a driver backend on different OSes, and to export more symbols when testing. Would it make sense to have a haskell version of CPP that provides only these features (e.g. just #ifdef, #else, #endif, and #define) and leaves out the problematic C comments and backslash expectations? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] getting haddock to cooperate with cpp
I guess that cabal preprocesses the files before calling Haddock then. Perhaps that's why it asks me to `cabal configure` before `cabal haddock`ing =). If you're able to switch over to cabal, that may be the easiest solution. Cheers, On Fri, Jul 12, 2013 at 6:31 PM, Evan Laforge qdun...@gmail.com wrote: I'm calling haddock myself. Cabal might have some special magic for CPP, when I searched for haddock CPP I got some old bugs about adding cabal support. So presumably it's possible. On Jul 12, 2013 1:15 PM, Felipe Almeida Lessa felipe.le...@gmail.com wrote: Are you using `cabal haddock` or calling haddock manually? Cheers, On Fri, Jul 12, 2013 at 3:25 PM, Evan Laforge qdun...@gmail.com wrote: So haddock ignores {-# LANGUAGE CPP #-}, which makes it crash on any file that uses it. But if you pass --optghc=-cpp, it runs CPP on everything, which makes it crash on any file that uses string gaps, or happens to contain a /*. /* is rare and easily fixed, but not string gaps. It looks like a workaround would be to manually inspect the files for LANGUAGE CPP and run two haddock passes, but then I would have to get the two passes to cooperate creating a single TOC and index. Isn't there some way to run haddock on files that use CPP? In the broader scheme, it seems perverse to be using CPP in the first place. I use it to configure imports and exports, e.g. to swap out a driver backend on different OSes, and to export more symbols when testing. Would it make sense to have a haskell version of CPP that provides only these features (e.g. just #ifdef, #else, #endif, and #define) and leaves out the problematic C comments and backslash expectations? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Correct way to catch all exceptions
On Thu, Jul 11, 2013 at 10:56 AM, Michael Snoyman mich...@snoyman.com wrote: The only approach that handles the situation correctly is John's separate thread approach (tryAll3). I think you meant tryAll2 here. Got me confused for some time =). Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC bug? Let with guards loops
Well, you could use p's type for something. let x | foo (undefined `asTypeOf` x) = 3 foo _ = True in x Arguably not very useful. It seems to me that the most compelling rationale is being consistent with the cases where, instead of being a data type, p is a function. Even so most of the time you won't be recursing on the guard. But, since you could use something from the where clause on the guard, and we certainly won't be restricting recursing on the where clause, it also seems compelling to allow recursion on the guard. My 2 centavos, =) On Tue, Jul 9, 2013 at 2:12 PM, Andreas Abel andreas.a...@ifi.lmu.de wrote: Thanks, Dan and Roman, for the explanation. So I have to delete the explanation non-recursive let = single-branch case from my brain. I thought the guards in a let are assertations, but in fact it is more like an if. Ok. But then I do not see why the pattern variables are in scope in the guards in let p | g = e The variables in p are only bound to their values (given by e) if the guard g evaluates to True. But how can g evaluate if it has yet unbound variables? How can ever a pattern variable of p be *needed* to compute the value of the guard? My conjecture is that it cannot, so it does not make sense to consider variables of g bound by p. Maybe you can cook up some counterexample. I think the pattern variables of p should not be in scope in g, and shadowing free variables of g by pattern variables of p should be forbidden. Cheers, Andreas On 09.07.2013 17:05, Dan Doel wrote: The definition Just x | x 0 = Just 1 is recursive. It conditionally defines Just x as Just 1 when x 0 (and as bottom otherwise). So it must know the result before it can test the guard, but it cannot know the result until the guard is tested. Consider an augmented definition: Just x | x 0 = Just 1 | x = 0 = Just 0 What is x? On 09.07.2013 17:49, Roman Cheplyaka wrote: As Dan said, this behaviour is correct. The confusing thing here is that in case expressions guards are attached to the patterns (i.e. to the lhs), while in let expressions they are attached to the rhs. So, despite the common Just x | x 0 part, your examples mean rather different things. Here's the translation of 'loops' according to the Report: loops = let Just x = case () of () | x 0 - Just 1 in x Here it's obvious that 'x' is used in the rhs of its own definition. Roman * Andreas Abel andreas.a...@ifi.lmu.de [2013-07-09 16:42:00+0200] Hi, is this a known bug or feature of GHC (7.4.1, 7.6.3)?: I got a looping behavior in one of my programs and could not explain why. When I rewrote an irrefutable let with guards to use a case instead, the loop disappeared. Cut-down: works = case Just 1 of { Just x | x 0 - x } loops = let Just x | x 0 = Just 1 in x works returns 1, loops loops. If x is unused on the rhs, the non-termination disappears. works' = let Just x | x 0 = Just 1 in 42 Is this intended by the Haskell semantics or is this a bug? I would have assumed that non-recursive let and single-branch case are interchangeable, but apparently, not... Cheers, Andreas -- Andreas AbelDu bist der geliebte Mensch. Theoretical Computer Science, University of Munich Oettingenstr. 67, D-80538 Munich, GERMANY andreas.a...@ifi.lmu.de http://www2.tcs.ifi.lmu.de/~abel/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Andreas AbelDu bist der geliebte Mensch. Theoretical Computer Science, University of Munich Oettingenstr. 67, D-80538 Munich, GERMANY andreas.a...@ifi.lmu.de http://www2.tcs.ifi.lmu.de/~abel/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: module-management-0.9.3 - clean import lists, split and merge modules
On Thu, Jun 27, 2013 at 11:18 PM, Marc Weber marco-owe...@gmx.de wrote: Excerpts from David Fox's message of Fri Jun 28 04:04:59 +0200 2013: So you will get modules Start.A, Start.B and Start.C. If there are But that's very unlikly what the programmer wants. I mean I might want Types and Funs as module names, move A,B to Types, C to Funs. I agree that I could reach my goal using a merge afterwards ? From what I'm reading, I don't actually agree that the goal may be reached by using a merge afterwards. I assume that split-then-merge isn't the same as identity since at very least the order of the symbols is lost. -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] tangential request...
On Mon, Jun 24, 2013 at 11:32 PM, Mark Lentczner mark.lentcz...@gmail.com wrote: (apologies for keeping this tangential topic alive for so long... but it is the cafe... and it is all for a good Haskell related cause...) ... Ah, the indomitable Mr. Parker, we meet again! While the other console fonts were nothing so much as an indiscriminate pile of plundered pixels from the trash can of crufty CRTs Your font was of such refined line and design that it clearly marked you as a man of distinction, wealth, fame, power, and fine scotch! A straight sided capital A, sporting a peaked top that actually comes to a point?!?!!! Well played! Game of Baccarat over martinis? Now you both owe us an screenshot =). -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] tangential request...
I leave my terminal with the default font that comes with Ubuntu, mainly because sometimes I like to enlarge its size effortlessly. OTOH, on emacs I use GohuFont-10, which is quite nice. I'm not on a retina display though. Cheers, On Mon, Jun 24, 2013 at 12:18 PM, Tobias Dammers tdamm...@gmail.com wrote: On Mon, Jun 24, 2013 at 04:09:22PM +0100, Tom Ellis wrote: On Mon, Jun 24, 2013 at 08:02:17AM -0700, Mark Lentczner wrote: And yet, just four fonts make up over 75% of the sample - and two of those are essentially identical! Inconsolata and Consolas? My bet: - Bitstream Vera Sans Mono - DejaVu Sans Mono - Inconsolata - Whatever the default terminal font is on OS X ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GADTs and pattern matching
Brent, maybe I'm misunderstanding what you're saying, but I don't think that the order of the arguments is playing any role here besides defining the order in which the pattern matches are desugared. To illustrate, -- This does work foo1' :: a - Foo a - Int foo1' m Foo = case m of Nothing - undefined Just _ - undefined Despite having the same type as foo1, foo1' does work because now I've pattern matched on the GADT first. As soon as I do that, its equality constraint of (a ~ Maybe v) enters into scope of the case branches. Cheers, On Wed, Jun 19, 2013 at 7:59 AM, Brent Yorgey byor...@seas.upenn.edu wrote: On Wed, Jun 19, 2013 at 11:11:16AM +0100, Francesco Mazzoli wrote: At Wed, 19 Jun 2013 10:03:27 + (UTC), AntC wrote: Hi Francesco, I think you'll find that the 'annoyance' is nothing to do with GADTs. I suggest you take the type signature off of foo1, and see what type ghc infers for it. It isn't :: a - Foo a - Int. [...] Yep, that message explains what's going on well enough for me. Did you read the rest of the code? That ought to work, because GHC infers and uses the type equality (something like ‘v ~ Var v1’) and uses it to coerce the ‘x’. And, surprise surprise, if the argument order is switched, it works! data Foo v where Foo :: forall v. Foo (Maybe v) foo1 :: Foo a - a - Int foo1 Foo Nothing = undefined foo1 Foo (Just x) = undefined Yes, I was going to suggest switching the argument order before reading your message. This is an interesting way in which you can observe that Haskell does not really have multi-argument functions. All multi-argument functions are really one-argument functions which return functions. So a function of type foo1 :: a - (Foo a - Int) must take something of type a (for *any* choice of a, which the caller gets to choose) and return a function of type (Foo a - Int). *Which* function is returned (e.g. one that tries to pattern match on the Foo) makes no difference to whether foo1 typechecks. On the other hand, a function of type foo2 :: Foo a - (a - Int) receives something of type Foo a as an argument. It may pattern-match on the Foo a, thus bringing into scope the fact that (a ~ Maybe v). Now when constructing the output function of type (a - Int) it may make use of this fact. -Brent ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] List comprehensions with Word8
Prelude 10 `mod` 256 0 So [1..10] == [1..0]. Cheers, On Thu, May 16, 2013 at 6:15 PM, Jose A. Lopes jose.lo...@ist.utl.pt wrote: Hello everyone, I was playing with Word8 and list comprehensions and the following examples came up. I have to admit the behavior looks quite strange because it does not seem to be consistent. Can someone shed some light on reason behind some of these outputs? By the way, I have abbreviated some outputs with ellipsis ... [1..10] :: [Word8] [1,2,3,4,5,6,7,8,9,10] [1..100] :: [Word8] [1,2,3,4,5,6,7,8,9,10,...,100] [1..1000] :: [Word8] [1,2,3,4,5,6,7,8,9,10,...,232] [1..1] :: [Word8] [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16] [1..10] :: [Word8] [1,2,3,4,5,6,7,8,9,10,...,160] [1..100] :: [Word8] [1,2,3,4,5,6,7,8,9,10,...,64] [1..1000] :: [Word8] [1,2,3,4,5,6,7,8,9,10,...,128] [1..1] :: [Word8] [] [1..10] :: [Word8] [] Thank you, Jose -- José António Branquinho de Oliveira Lopes Instituto Superior Técnico Technical University of Lisbon ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hackage checking maintainership of packages
I do think it's a real problem even for seasoned haskellers. I don't have problems in remembering which packages I should use for the things I've already used before recently, but I need to search Hackage just as everyone else as soon as I need to do something new. I also agree that this is more of a social problem not a tooling one. Hackage would just provide a tool for helping this kind of social interaction. On Mon, May 6, 2013 at 1:25 PM, Carter Schonwald carter.schonw...@gmail.com wrote: is that really a problem though? Who's problem are we trying to solve? Is this being proposed to help seasoned haskellers, or make getting started easier for new folks? those are two VERY different problems. Also many of the maintainers for heavily used packages are incredibly busy as is, do they need to keep track of even *more* email? I'd hope not. In some respects, just having the hackage2 deps and revdeps stats is a good proxy for how likely a package is to be well maintained. On Mon, May 6, 2013 at 8:45 AM, Niklas Hambüchen m...@nh2.me wrote: Well, that's what the once every 3 months is good for. On Mon 06 May 2013 20:34:13 SGT, Tobias Dammers wrote: The problem is that people tend to (truthfully) check such a box, then stop maintaining the package for whatever reasons, and never bother unchecking the box. ___ 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 -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hackage checking maintainership of packages
Just checking the repo wouldn't work. It may still have some activity but not be maintained and vice-versa. On Sun, May 5, 2013 at 2:19 PM, Doug Burke dburke...@gmail.com wrote: On May 5, 2013 7:25 AM, Petr Pudlák petr@gmail.com wrote: Hi, on another thread there was a suggestion which perhaps went unnoticed by most: -- Forwarded message -- From: Niklas Hambüchen m...@nh2.me Date: 2013/5/4 ... I would even be happy with newhackage sending every package maintainer a quarterly question Would you still call your project X 'maintained'? for each package they maintain; Hackage could really give us better indications concerning this. This sounds to me like a very good idea. It could be as simple as If you consider yourself to be the maintainer of package X please just hit reply and send. If Hackage doesn't get an answer, it'd just would display some red text like This package seems to be unmaintained since D.M.Y. Best regards, Petr For those packages that give a repository, a query could be done automatically to see when it was last updated. It's not the same thing as 'being maintained', but is less annoying for those people with many packages on hackage. Doug ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] warp and http-conduit on concurrent threads on windows
Quick tip: did you try using withSocketsDo[1]? [1] http://hackage.haskell.org/packages/archive/network/2.4.1.2/doc/html/Network.html#g:2 On Thu, Mar 28, 2013 at 5:00 PM, Lars Kuhtz hask...@kuhtz.eu wrote: Hi, I'd like to know what is wrong with the following program on windows8 (GHC 7.4.2, 32bit): {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} module Main where import Control.Concurrent.Async import qualified Control.Exception as E import Network.HTTP.Conduit import Network.HTTP.Types import Network.Wai import Network.Wai.Handler.Warp query port = E.catch (simpleHttp (http://haskell.org:; ++ show port) = print . take 10 . show) (\(e :: HttpException) - print $ caught: ++ show e) listen = run 8080 $ \_ - return $ responseLBS ok200 [] abc main = do withAsync (query 12345) $ \a - do withAsync listen $ \b - do wait a wait b I compile the program with ghc --make -threaded Main.hs and run it as ./Main +RTS -N. On POSIX systems this works as expected. Even if the failing query runs in a forever loop the listen thread responds promptly to requests. On windows the listen thread seems blocked by the failing query thread. Sometimes the query returns (relatively) prompt. But sometimes (about a third of all runs) it takes very long (about 20 sec). Also, sometimes it returns with Connection timed out (WSAETIMEDOUT), sometimes with getAddrInfo: does not exist (error 11003), and sometimes just with FailedConnectionException. The fact that the listen thread is blocked seems to contradict the following quote form the documentation of Control.Concurrent: -- Quote from Control.Concurrent -- Using forkOS instead of forkIO makes no difference at all to the scheduling behaviour of the Haskell runtime system. It is a common misconception that you need to use forkOS instead of forkIO to avoid blocking all the Haskell threads when making a foreign call; this isn't the case. To allow foreign calls to be made without blocking all the Haskell threads (with GHC), it is only necessary to use the -threaded option when linking your program, and to make sure the foreign import is not marked unsafe. -- End Quote -- By the way: using withAsyncBound instead of withAsync seems to improve (but not completely solve) the issue. Thanks, Lars ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Unused definitions across modules in a package
On Wed, Feb 20, 2013 at 9:20 PM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: My (getting-long-in-the-tooth-and-could-do-with-a-rewrite) SourceGraph package does identify these definitions. What a coincidence, then! I was trying to use SourceGraph for other reasons but it didn't work for my codebase. I haven't investigated with it couldn't parse the files, though, and I use many extensions. Nice to know that it supports this feature =). Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Unused definitions across modules in a package
Hey! GHC warns me about unused definitions in a module. However, is it possible to warn me about unused definitions in a package? For example, suppose that module A exports function f and that module B uses A.f (everything on a single package). However, after some time B stops using A.f. Is there a way of receiving a warning saying that A exports f but no other module uses it.? (I know that this warning wouldn't be useful for libraries, since their whole point is to export things.) Cheers! -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] haskell build phase is very slow
On Mon, Feb 4, 2013 at 7:45 PM, Ben Doyle benjamin.peter.do...@gmail.com wrote: General advice on speeding compilation is here: [2]. Its first advice should already be enough to give you something usable. Call cabal configure with the --disable-optimization flag and see if it helps. Cheers, =) -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Yet another Conduit question
I guess you could use the Flush datatype [1] depending on how your data is generated. Cheers, [1] http://hackage.haskell.org/packages/archive/conduit/0.5.4.1/doc/html/Data-Conduit.html#t:Flush On Fri, Feb 1, 2013 at 6:28 AM, Simon Marechal si...@banquise.net wrote: On 01/02/2013 08:21, Michael Snoyman wrote: So you're saying you want to keep the same grouping that you had originally? Or do you want to batch up a certain number of results? There are lots of ways of approaching this problem, and the types don't imply nearly enough to determine what you're hoping to achieve here. Sorry for not being clear. I would like to group them as much as possible, that is up to a certain limit, and also within a time threshold. I believe that the conduit code will be called only when something happens in the conduit, so an actual timer would be useless (unless I handle this at the source perhaps, and propagate ticks). That is why in my first message I talked about stacking things into the list until the conduit has no more input available, or a maximum size is reached, but was not sure this even made sense. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Handling exceptions or gracefully releasing resources
Everything that Johan Tibell said + you may be interested in the resourcet package [1] (which is used by conduit to handle resources). Cheers, [1] http://hackage.haskell.org/package/resourcet On Tue, Jan 29, 2013 at 8:59 PM, Thiago Negri evoh...@gmail.com wrote: `Control.Exception.bracket` is a nice function to acquire and release a resource in a small context. But, how should I handle resources that are hold for a long time? Should I put `Control.Exception.finally` on every single line of my finalizers? What exceptions may occur on an IO operation? Every IO function has the risk of throwing an exception? Thanks, Thiago. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Handling exceptions or gracefully releasing resources
AFAIR, the only object that you need to be careful with is the Space [1], everything else is garbage collected. You could put the Space in a ResourceT, but only if it ran on its own thread (as soon as a block of ResourceT finishes, everything is deallocated, so you wouldn't be able to follow the approach taken by HipmunkPlayground). Cheers, [1] http://hackage.haskell.org/packages/archive/Hipmunk/5.2.0.10/doc/html/Physics-Hipmunk-Space.html#v:freeSpace On Wed, Jan 30, 2013 at 11:15 AM, Thiago Negri evoh...@gmail.com wrote: Felipe, I'm trying to use your Hipmunk package. :) The resources I need to keep around are the objects used for the simulation. Do you recomend using resourcet to handle this or something else? Thanks. 2013/1/30 Felipe Almeida Lessa felipe.le...@gmail.com Everything that Johan Tibell said + you may be interested in the resourcet package [1] (which is used by conduit to handle resources). Cheers, [1] http://hackage.haskell.org/package/resourcet On Tue, Jan 29, 2013 at 8:59 PM, Thiago Negri evoh...@gmail.com wrote: `Control.Exception.bracket` is a nice function to acquire and release a resource in a small context. But, how should I handle resources that are hold for a long time? Should I put `Control.Exception.finally` on every single line of my finalizers? What exceptions may occur on an IO operation? Every IO function has the risk of throwing an exception? Thanks, Thiago. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Ticking time bomb
IMHO Hackage and Cabal should support package signing even if they aren't package managers. On Wed, Jan 30, 2013 at 6:59 PM, Joachim Breitner nome...@debian.org wrote: Hi, Am Mittwoch, den 30.01.2013, 11:27 -0800 schrieb Edward Z. Yang: https://status.heroku.com/incidents/489 Unsigned Hackage packages are a ticking time bomb. another reason why Cabal is no package manager¹. (Ok, I admit that I don’t review every line of diff between the Haskell packages I uploads. But thanks to http://hdiff.luite.com/ I at least glance over them most of the time – a hurdle that malicious code would have to take. And once a package has entered a distribution like Debian (which it only can with a valid cryptographic signatures), checksums and signatures are used in many places to (mostly) guarantee that the package reaches the user unmodified.) Greetings, Joachim ¹ http://ivanmiljenovic.wordpress.com/2010/03/15/repeat-after-me-cabal-is-not-a-package-manager/ -- Joachim nomeata Breitner Debian Developer nome...@debian.org | ICQ# 74513189 | GPG-Keyid: 4743206C JID: nome...@joachim-breitner.de | http://people.debian.org/~nomeata ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Where did the Cabal manual go?
Do you mean the Cabal User Guide? http://www.haskell.org/cabal/users-guide/ On Sun, Jan 27, 2013 at 1:07 PM, Richard Cobbe co...@ccs.neu.edu wrote: I'm not able to access the cabal manual today: links to my local copy and links to the copy at haskell.org result in a 404. I'm running the Haskell Platform, 2012.4.0.0, 64-bit, OS X 10.8.2. On my first attempt this morning, I loaded file:///Library/Haskell/doc/start.html in my browser and clicked on the Cabal link. The browser can't find file:///Library/Haskell/doc/ghc-doc/Cabal/index.html, and indeed the directory /Library/Haskell/doc/ghc-doc/Cabal doesn't exist. Ok, I think, so my local copy's gotten corrupted. One sudo /Library/Haskell/bin/uninstall-hs --remove thru 7.4.2 and reinstall later, I try again; no change. I also can't find any docs by doing find /Library/Haskell -iname \*cabal\* find /Library/Frameworks/GHC.framework -iname \*cabal\* either. I also get a 404 when I click on the Cabal link from http://lambda.haskell.org/platform/doc/current/start.html. I can probably recover a copy from system backups, but what's going on? Richard ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Use forM_ with Maybe, it's Foldable!
Herbert Valerio actually pointed out to me in PVT that funnily enough I've actually *forgotten* and *rediscovered* this idiom! =) http://www.haskell.org/pipermail/libraries/2011-November/017257.html Cheers! On Sat, Jan 26, 2013 at 5:43 PM, Felipe Almeida Lessa felipe.le...@gmail.com wrote: Hey, Just wanted to share this little insight I had that I don't think is a common idiom. Often times I need to define: whenJust :: Monad m = Maybe a - (a - m b) - m () whenJust (Just x) f = f x whenJust Nothing _ = return () It always bugged me that you can't find this function anywhere. Actually, you can find it on at least a couple of packages [1], but you can't find it on a standard place. Or can you? A few days ago I decided to hoogle the type of whenJust [2] and what I discovered is that import Data.Foldable (forM_) whenJust = forM_ For example, instead of: mfoo - doSomething case mfoo of Just foo - ... Nothing - return () You may just write: forM_ mfoo $ \foo - ... There you go. I hope this is useful to someone =). Cheers, [1] http://holumbus.fh-wedel.de/hayoo/hayoo.html?query=whenJust [2] http://www.haskell.org/hoogle/?hoogle=Maybe%20a%20-%3E%20(a%20-%3E%20m%20b)%20-%3E%20m%20() -- Felipe. -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: hslogstash (library for working with Logstash and related tools)
For someone as lazy as myself: http://hackage.haskell.org/package/hslogstash https://github.com/bartavelle/hslogstash Cheers, On Fri, Jan 25, 2013 at 2:48 PM, Simon Marechal si...@banquise.net wrote: This is a library for sysadmins and/or tool writers. It provides proper types and correct serialization for Logstash messages, along with small utilities for working with ElasticSearch or Redis (using hedis). This library focus will be on safety (no messages lost). Right now, it can be used to: * send properly formated messages to Logstash * read Logstash messages from Redis or any socket * write Logstash messages to ElasticSearch or any socket This is the work of a sysadmin, thus very likely to be horrible to read. Suggestions are very welcome. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: monad-bool 0.1
Em 23/01/2013 04:03, John Wiegley jo...@fpcomplete.com escreveu: I'll ask Ross Paterson to deprecate monad-bool. And in future, I'll seek review here first before uploading. Release early and release often, don't worry about asking the mailing list beforehand (unless you want to, of course). Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Up-front Unit Testing in Haskell
Where can we find it, Kazu? =) -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Type hierarchy
For your particular constraints, it can be as easy as: class IsA a where toA :: a - A foo' :: IsA a = a - C foo' = foo . toA However, you may asking the wrong question since it smells like you're trying to embed OO into Haskell =). Cheers, On Wed, Jan 16, 2013 at 1:03 PM, Thiago Negri evoh...@gmail.com wrote: Hello. How do I achieve type hierarchy in Haskell? Suppose we have the following code: foo :: A - C bar :: B - C I want something that allow me to say that B is a subtype of A, meaning: 1. I can use a value of type A where a value of type A is needed. 2. I can use a value of type B where a value of type B is needed. 3. I can use a value of type B where a value of type A is needed. 4. I can't use a value of type A where a value of type B is needed. What are my options? I've thought in type classes and data types with an attribute representing the extension. Any other way to do this? Thanks, Thiago. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HaskellDB-HDBC-PostgreSQL installation problem
AFAIK, persistent's PostgreSQL support does depend on libpq via postgresql-libpq. On Wed, Jan 9, 2013 at 12:39 PM, Alexander Alexeev m...@eax.me wrote: Try Persistent package. It doesn't depends on libpq and has many useful features (see http://www.yesodweb.com/book/persistent for details) On 01/09/2013 05:50 PM, Christopher Done wrote: Tricky. For what it's worth, if you can't figure this out in the end, you could perhaps use my pgsql-simple which is implemented in pure haskell: https://github.com/chrisdone/pgsql-simple It's been in use on hpaste.org for about 2 years. On 9 January 2013 14:44, Johannes.Reiher johannes.rei...@fh-zwickau.de wrote: Hello Community, I have a problem installing the HaskellDB-HDBC-PostgreSQL package with cabal. I'm using Haskell Platform in Windows and I tried to install this package, but there was the error could not find pq library. So I tried to install libpq wich includes pq but there was another error: this package needs a unix installation. Is there any way to install pq on Windows or get the HaskellDB-HDBC-PostgreSQL in another way? Thanks for your advice Johannes Reiher ___ 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 -- Best regards, Alexander Alexeev http://eax.me/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hackage suggestion: Gather the list of the licenses of all dependencies of a package
While you're at it, maybe whitelisting cpphs would be nice as well =). On Thu, Dec 13, 2012 at 12:03 PM, Michael Snoyman mich...@snoyman.com wrote: On Thu, Dec 13, 2012 at 3:53 PM, Vincent Hanquez t...@snarc.org wrote: On 12/13/2012 12:51 PM, Michael Snoyman wrote: I think that's a great idea. I just implemented this on PackDeps: http://packdeps.haskellers.com/licenses As with all features on that site, I'll be happy to deprecate it as soon as Hackage incorporates the feature in the future. awesome Michael ! However i think ithis shouldn't take dependencies from tests and benchmarks. This doesn't make differences for the overall license that the library exposes. -- Vincent Hmm, that's a good point. I'll admit I hadn't really thought this through, but I can actually see an argument going both ways on this: * Viral licenses won't actually affect you if they're just used for test suites. * But company lawyers will probably be nervous about it anyway. Nonetheless, I think you have the right of it. Unless people say otherwise, I'm going to implement Vincent's change. Michael ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hackage suggestion: Gather the list of the licenses of all dependencies of a package
From [1] I gather that its license really is LGPL/GPL. However, when used as a preprocessor its license doesn't really matter. Many packages on that list have a LGPL taint because one of its deps use cpphs. So the whitelist of cpphs would be stating that nobody is using cpphs as a library (which may be false, but is mostly true ;). [1] http://code.haskell.org/cpphs/README On Thu, Dec 13, 2012 at 1:08 PM, Michael Snoyman mich...@snoyman.com wrote: Are you referring to: http://code.haskell.org/cpphs/LICENCE-commercial If the package is dual-licensed BSD3 and LGPL, maybe Malcolm could change the cabal file to mention the BSD3 so that its package description is less intimidating? On Thu, Dec 13, 2012 at 4:12 PM, Felipe Almeida Lessa felipe.le...@gmail.com wrote: While you're at it, maybe whitelisting cpphs would be nice as well =). On Thu, Dec 13, 2012 at 12:03 PM, Michael Snoyman mich...@snoyman.com wrote: On Thu, Dec 13, 2012 at 3:53 PM, Vincent Hanquez t...@snarc.org wrote: On 12/13/2012 12:51 PM, Michael Snoyman wrote: I think that's a great idea. I just implemented this on PackDeps: http://packdeps.haskellers.com/licenses As with all features on that site, I'll be happy to deprecate it as soon as Hackage incorporates the feature in the future. awesome Michael ! However i think ithis shouldn't take dependencies from tests and benchmarks. This doesn't make differences for the overall license that the library exposes. -- Vincent Hmm, that's a good point. I'll admit I hadn't really thought this through, but I can actually see an argument going both ways on this: * Viral licenses won't actually affect you if they're just used for test suites. * But company lawyers will probably be nervous about it anyway. Nonetheless, I think you have the right of it. Unless people say otherwise, I'm going to implement Vincent's change. Michael ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] LGPL and Haskell (Was: Re: ANNOUNCE: tie-knot library)
When deciding what license to use, I think one should also think about the role of their library. For example, containers is quite central to the Haskell community and not easily replaceable. The tie-knot library, OTOH, may be rewritten from scratch or even just skipped (just tie the knot yourself). A GPLed containers forces the library user to somehow get a way of complying to the license. A GPLed tie-knot, OTOH, may be just ignored. What I'm trying to say is that if your library is nice but someone may just rewrite it without much effort, then using GPL will just drive potential users of your library away, which is bad not just for the library but also for those potential users as well. Perhaps you have a nice library but it may be replaced (with some small pain) by another, similar library. (In particular, I'm not saying that tie-knot is a library that should be ignored. On the contrary, I think it's quite nice and it would be a shame if I had to ignore it when tying a knot just because of its restrictive license.) Of course, if everything on Hackage was GPLed, then it wouldn't make sense to release something as BSD as you wouldn't be able to use it anyway. But the reality right now is that we have: (Apache,3) (BSD3,3359) (BSD4,3) (MIT,269) (PublicDomain,142) (GPL,409) (GPL-2,27) (GPL-3,147) (LGPL,138) (LGPL-2,2) (LGPL-2.1,25) (LGPL-3,21) (OtherLicense,179) This data comes from a quick shell session while considering the latest .cabal of all Hackage packages, so take it with a grain of salt =). Cheers, On Wed, Dec 12, 2012 at 2:12 PM, Jonathan Fischer Friberg odysso...@gmail.com wrote: +1 Very similar to my point (see original thread), but put in a better way. :) As an interesting coincidence, this exact thing happened to someone just now. (thread containers license issue) Jonathan On Wed, Dec 12, 2012 at 5:00 PM, Clark Gaebel cgae...@uwaterloo.ca wrote: Since we've already heard from the aggressive (L)GPL side of this debate, I think it's time for someone to provide the opposite opinion. I write code to help users. However, as a library designer, my users are programmers just like me. Writing my Haskell libraries with restrictions like the (L)GPL means my users need to jump through hoops to use my software, and I personally find that unacceptable. Therefore, I gravitate more towards BSD3 and beer-ware type licenses. This also means my users aren't subjected to my religious views just because they want to use my ones and zeros. Also, with GHC's aggressive inlining, even if you do have a static linking exception in your (L)GPL license, it still may not hold up! Although the entire idea is untested in court, GHC can (and will!) inline potentially huge parts of statically linked libraries into your code, and this would force you to break the license terms if you were to distribute the software without source code. In Haskell-land, the GPL is the ultimate in viral licensing, and very hard to escape. That's why I don't use (L)GPL licenses. Just making sure both sides have a horse in this race :) - Clark On Wed, Dec 12, 2012 at 9:51 AM, kudah kudahkuka...@gmail.com wrote: On Wed, 12 Dec 2012 10:06:23 +0100 Petr P petr@gmail.com wrote: 2012/12/12 David Thomas davidleotho...@gmail.com Yet another solution would be what David Thomas suggest: To provide the source code to your users, but don't allow them to use the code for anything but relinking the program with a different version of the library (no distribution, no modification etc.). You can also provide object code for linking, though I'm sure this will not work with Haskell object files. Providing alternative distribution of your program linked dynamically, or a promise to provide one on notice, also satisfies the LGPL as long as dynamic-version is as functional as the static and can be dropped-in as a replacement. ___ 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 -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] containers license issue
Crisis averted! =) On Wed, Dec 12, 2012 at 11:15 PM, Johan Tibell johan.tib...@gmail.com wrote: On Wed, Dec 12, 2012 at 12:18 PM, Dmitry Kulagin dmitry.kula...@gmail.com wrote: Clark, Johan, thank you! That looks like perfect solution to the problem. Clean-room reimplementation merged and released as 0.5.2.0. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: tie-knot library
Hey, Petr! Have you considered licensing your library as BSD? Given the current way that Haskell programs are compiled, your library is effectively licensed as GPL and that will scare away many people from using it. Cheers, =) On Mon, Dec 10, 2012 at 6:58 PM, Petr P petr@gmail.com wrote: Dear Haskellers, I'd like to announce a small library tie-knot: Ties the knot on a given set of structures that reference each other by keys - replaces the keys with their respective values. Takes Map k (v k) and converts into Map k v' where v' is the fixed point of v. Motivation: I needed to assemble a finite-state machine from an external description where each node was described by some identifier. I needed a simple library that would replace all key referencess with the actual values. See https://github.com/ppetr/tie-knot for examples. Hackage: http://hackage.haskell.org/package/tie-knot - Petr Pudlak ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Maintainer of hgettext
Did you try pinging him again? On Wed, Dec 5, 2012 at 3:59 PM, Ivan Perez ivanperezdoming...@gmail.com wrote: Hello haskellers, A few months ago I sent an email to Vasyl Pasternak regarding a couple of bugs in hgettext [1], together with a small patch that fixes them. I never received an answer and I can see that the error persists. Does anyone know where he is? What would you recommend at this point? Cheers, Ivan. [1] http://hackage.haskell.org/package/hgettext ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is it possible to have constant-space JSON decoding?
Aeson doesn't have an incremental parser so it'll be difficult/impossible to do what you want. I guess you want an event-based JSON parser, such as yajl [1]. I've never used this library, though. Cheers, [1] http://hackage.haskell.org/package/yajl-0.3.0.5 On Tue, Dec 4, 2012 at 12:11 PM, Iustin Pop ius...@google.com wrote: Hi, I'm trying to parse a rather simple but big JSON message, but it turns out that memory consumption is a problem, and I'm not sure what the actual cause is. Let's say we have a simple JSON message: an array of 5 million numbers. I would like to parse this in constant space, such that if I only need the last element, overall memory usage is low (yes, unrealistic use, but please bear with me for a moment). Using aeson, I thought the following program will be nicely-behaved: import Data.Aeson import qualified Data.Attoparsec.ByteString.Lazy as AL import qualified Data.ByteString.Lazy as L main = do r - L.readFile numbers case AL.parse json r :: AL.Result Value of AL.Fail _ context errs - do print context print errs AL.Done _ d - case fromJSON d::Result [Value] of Error x - putStrLn x Success d - print $ last d However, this uses (according to +RTS -s) ~1150 GB of memory. I've tried switching from json to json', but while that uses slightly less memory (~1020 MB) it clearly can't be fully lazy, since it forces conversion to actual types. Looking at the implementation of FromJSON [a], it seems we could optimise the code by not forcing to a list. New (partial) version does: AL.Done _ d - case d of Array v - print $ V.last v And this indeed reduces the memory, when using json', to about ~700MB. Better, but still a lot. It seems that the Array constructor holds a vector, and this results in too much strictness? Looking at the memory profiles (with json and Array), things are quite interesting - lots of VOID, very small USE, all generated from Data.Aeson.Parser.Internal:array. Using -hd, we have a reasonable equal split between various attoparsec combinators, Data.Aeson.Parser.Internal epressions, etc. So, am I doing something wrong, or is it simply not feasible to get constant-space JSON decoding? Using the 'json' library instead of 'aeson' is no better, since that wants the input as a String which consumes even more memory (and dies, when compiled with -O2, with out of stack even for 64MB stack). thanks, iustin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] 1st São Paulo Haskell Meeting [1° Encontro de Haskellers em São Paulo]
Hey! I'd like to invite you to the 1st São Paulo Haskell Meeting! It's going to be something simple, we just want to meet each other and talk about Haskell =). We already have 9 people confirmed on the Google+ event [1], so come join us already! Cheers, PS: We still didn't set the place yet. [1] https://plus.google.com/events/cng3rcv1tjl84g2juddk1i36icg -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Real-time code in Haskell (Was: Can a GC delay TCP connection formation?)
http://hackage.haskell.org/packages/archive/base/4.6.0.0/doc/html/System-Mem.html#v:performGC On Tue, Nov 27, 2012 at 5:52 PM, timothyho...@seznam.cz wrote: What triggers GC in haskell? We obviously aren't using Java's method of GC as needed(for good reasons, Java's method is terrible because you get slow downs when you need speed the most). But we should be able to learn something from Java and have a gc::IO() method that one could call BEFORE a critical region of code... -- Původní zpráva -- Od: Mike Meyer m...@mired.org Datum: 27. 11. 2012 Předmět: [Haskell-cafe] Real-time code in Haskell (Was: Can a GC delay TCP connection formation?) On Tue, Nov 27, 2012 at 3:45 AM, Gregory Collins g...@gregorycollins.net wrote: If you have a hard real-time requirement then a garbage-collected language may not be appropriate for you. This is a common meme, but frankly, it isn't true. When writing real-time code, you just need to make sure that everything that happens takes a known maximum amount of time. Then, you can sum up the maximums and verify that you do indeed finish in the real-time window of the task. GC is a problem because it's not predictable, and may not have a maximum. However, it's no worse than a modern version of the C function malloc. Some of those even do garbage collection internally before doing an OS call if they're out of memory. The solution is the same in both cases - make sure you don't do GC (or call malloc) in the critical region. Both require knowing implementation details of everything you call, but it isn't impossible, or even particularly difficult. Lazyness, on the other hand ... I haven't thought about. I suspect you need to force the evaluation of everything you're going to need before you start the critical region, but I wonder if that's enough? Has anyone out there investigated this? Thanks, mike ___ 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 -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC 6.13 and GHC 7.6 in parallel on Linux
On Thu, Sep 27, 2012 at 1:02 PM, spacestat...@venussociety.org spacestat...@venussociety.org wrote: How is it possible to run 2 different versions of GHC on the same computer ( OS , in my case OpenSuse 6.1x and hopefully 7.6 ) Just use hsenv [1] (formerly known as virthualenv). [1] https://github.com/Paczesiowa/hsenv Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] cost-centre names
On Sun, Sep 16, 2012 at 7:57 AM, Marco Túlio Pimenta Gontijo marcotmar...@gmail.com wrote: I have a question about cost-centre names, as shown on .hp files produced by +RTS -hc. They have the form A/B/C/D/E/F/G/... Usually, it seems that it means A, called by B, called by C, etc, but that's not the case sometimes. I have a case here (called with -L200): replaceOneOf’/clean/tagsText/anyTag/dropTagClose/parseObservations/specificTagText/tagText/parseOab/dropTagText/dropTill/tag/tagOpen... tagsText calls clean which calls replaceOneOf', but anyTag does not call tagsText. parseObservations calls dropTagClose which calss anyTag, but specificTagText does not call parseObservations. They seem to be grouped by three. Is this correct? How should I interpret it? That's probably because anyTag took a closure as argument, and that closure called tagsText when forced. Does that make sense? Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] hstats median algorithm
Some comments wrt. performance: On Mon, Sep 3, 2012 at 9:57 AM, timothyho...@seznam.cz wrote: Right (medianBucket,stubLen) = foldr (\thisBucket@(thisBucketLen,_) eitheriOrMedianBucket - case eitheriOrMedianBucket of Left i - if i + thisBucketLen (length `div` 2) then Right (thisBucket, thisBucketLen-((length `div` 2) - i)) else Left (i + thisBucketLen) _ - eitheriOrMedianBucket) (Left 0) myBuckets Use a let to store length `div` 2, GHC probably won't do this for you automatically. Ditto for i + thisBucketLen. buckets' - mapM (\n- newSTRef (0, if n = guessedMiddleStart n = guessedMiddleEnd then Just [] else Nothing)) [0..numBuckets] You should really use a mutable array here instead of a list of STRefs (I recommend vector's STVector [1]). [1] http://hackage.haskell.org/packages/archive/vector/0.9.1/doc/html/Data-Vector-Mutable.html Increment length. modifySTRef lengthRef (+1) This will create a big thunk for the length, you should use oldLength - readSTRef lengthRef writeSTRef lengthRef $! oldLength + 1 (I'm not sure if a strict modifySTRef exists somewhere...) Put the value into the appropriate bucket. modifySTRef (buckets' `genericIndex` bucket) --Obvious optimization, use an array and not a list. (\(oldLen,oldListMaybe)- case oldListMaybe of Just oldList - (oldLen+1,Just (number:oldList)) Nothing - (oldLen + 1, Nothing)) Ditto for oldLen here. Also, you can simplify this lambda a lot: import Control.Applicative (($)) \(oldLen, oldVal) - let newLen = oldLen + 1 newVal = (number:) $ oldVal in newLen `seq` newVal `seq` (newLen, newVal) HTH! Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] hstats median algorithm
On Mon, Sep 3, 2012 at 11:18 AM, Felipe Almeida Lessa felipe.le...@gmail.com wrote: Ditto for oldLen here. Also, you can simplify this lambda a lot: import Control.Applicative (($)) \(oldLen, oldVal) - let newLen = oldLen + 1 newVal = (number:) $ oldVal in newLen `seq` newVal `seq` (newLen, newVal) Or, using BangPatterns, \(oldLen, oldVal) - let !newLen = oldLen + 1 !newVal = (number:) $ oldVal in (newLen, newVal) Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Yesod a href render issue
On Fri, Aug 31, 2012 at 9:45 PM, David McBride toa...@gmail.com wrote: Hamlet is whitespace sensitive like haskell and python. If you put a tag after text, it is treated as text. Write the a... on the next line and it will work. Another option is to manually put the closing /a when the tag is in the middle of the line. This is especially useful for tags such as em or strong, e.g. This is strongvery/strong important! vs. This is # strongvery \ important! Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] ANNOUNCE: Perdure
[moving discussion to haskell-cafe] Congratulations and thanks for your new open source contribution! I hope you feel at home =). Your library looks really interesting but I'm completely overwhelmed by its size. Its Cabal description is huge and there's no example of how to use the library (it actually took me some time to understand what the library tries to accomplish). I took a quick look at the modules but there are so many that I couldn't really make sense of anything in a short time. So, could you perhaps write a full example of how to use the library? It looks like a nice library but I need a starting point =). Cheers! -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Conduit: Where to run monad stacks?
I can't give you a definite answer. However, I guess that's because the monad sequencing (i.e. where = of your monad is called) is inside the 'pipe' function [1] (i.e., $$, $=, =$), the function that connects pipes and runs them. 'pipe' needs to be able to interleave lifted actions between both upstream and downstream pipes, and for that they need to live on the same monad. What you want is somehow having upstream and downstream pipes on different monads. HTH, [1] http://hackage.haskell.org/packages/archive/conduit/0.5.2.3/doc/html/src/Data-Conduit-Internal.html#pipe -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Cloud Haskell real usage example
On Tue, Aug 21, 2012 at 9:01 PM, Thiago Negri evoh...@gmail.com wrote: My view of Cloud Haskell usage would be something similar to this: a master node sending work to slaves; slave instances getting up or down based on demand. So, the master node should be slave-failure-proof and also find new slaves somehow. Am I misunderstanding the big picture of Cloud Haskell or doing anything wrong in the following code? (Disclaimer: I can't speak for Cloud Haskell's developers.) AFAIK this is CH's goal. However, they're not quite there yet. Their network implementation is still a lot naive as you're seeing =). Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Platform Versioning Policy: upper bounds are not our friends
On Sat, Aug 18, 2012 at 3:57 AM, David Feuer david.fe...@gmail.com wrote: If the language is changed (without possibility of breakage, I believe) so that names declared in a module shadow imported names, incompatibility can only arise if two different imports offer the same name, and it is actually used. This already happens in practice (e.g. take, how many modules declare that?) and is one of the problems that qualified imports solve. Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Platform Versioning Policy: upper bounds are not our friends
On Thu, Aug 16, 2012 at 10:01 AM, Chris Smith cdsm...@gmail.com wrote: Twan van Laarhoven twa...@gmail.com wrote: Would adding a single convenience function be low or high risk? You say it is low risk, but it still risks breaking a build if a user has defined a function with the same name. Yes, it's generally low-risk, but there is *some* risk. Of course, it could be high risk if you duplicate a Prelude function or a name that you know is in use elsewhere in a related or core library... these decisions would involve knowing something about the library space, which package maintainers often do. If you import qualified then adding functions will never break anything. Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parsec type error with Flexible Contexts
Hello! I've managed to reduce your code to a much simpler test case (without parsec) but I'm still not sure why this is happening: {-# LANGUAGE MultiParamTypeClasses, FlexibleContexts #-} data D m = D { bar1 :: P m () , bar2 :: P m () } data P m c = P class S m c where foo :: S m () = P m () foo = undefined emptyDef :: S m () = D m emptyDef = D { bar1 = foo , bar2 = foo } haskellStyle :: S m () = D m haskellStyle = emptyDef { bar1 = foo , bar2 = foo } Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parsec type error with Flexible Contexts
Here's an even smaller one: {-# LANGUAGE MultiParamTypeClasses, FlexibleContexts #-} data D m = D { bar :: P m () } data P m c = P class S m c where foo :: S m () = P m () foo = undefined emptyDef :: S m () = D m emptyDef = D foo haskellStyle :: S m () = D m haskellStyle = emptyDef { bar = foo } Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Deprecating packages on Hackage
On Sat, Aug 4, 2012 at 3:30 PM, Andrey Chudnov achud...@gmail.com wrote: Hello. What are the best practices in deprecating packages on Hackage? I've seen packages marked DEPRECATED in the synopsis field on Hackage, and one could add GHC deprecated pragmas for every module, but is that the best one can do? You may also send an e-mail to Hackage's maintainers asking them to mark your package as deprecated. Packages deprecated this way do not show on Hackage's package list. Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Getting a segmentation fault when starting/stopping the RTS, from C, several times.
Em 15/07/2012 18:38, Albert Y. C. Lai tre...@vex.net escreveu: On 12-07-10 11:35 PM, Brandon Allbery wrote: Quoth the Fine Manual (8.2.1.1. Using your own main() http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html#using-own-main ): There can be multiple calls to |hs_init()|, but each one should be matched by one (and only one) call to |hs_exit()|^[14 http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html#ftn.id740774 ] . So this should theoretically work. Except that [14] says: the outermost hs_exit() de-initialises, and afterwards, cannot reliably re-initialise in current implementations. So the currently working use-case is just: Prog ::= nop | hs_init(); Prog; hs_exit() Would that be: Prog ::= nop | hs_init(); Prog'; hs_exit(); Prog' ::= nop | hs_init(); Prog'; hs_exit(); | Prog' Prog' Cheers, -- Felipe – enviado do meu Galaxy Tab. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] ANNOUNCE: lens-family 0.0.0
Hackage links for anyone as lazy as myself =). http://hackage.haskell.org/package/lens-family-core http://hackage.haskell.org/package/lens-family -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] combining predicates, noob question
On Fri, Jul 6, 2012 at 2:11 PM, Sebastián Krynski skryn...@gmail.com wrote: As I was using predicates (a - bool) , it appeared the need for combining them with a boolean operator (bool - bool - bool) in order to get a new predicate combining the previous two. So I wrote my function combinerPred (see code below). While I think this is JUST ok, i'm feeling a monad in the air. So.. where is the monad? combinerPred :: (a - Bool) - (a - Bool) - (Bool - Bool - Bool) - (a - Bool) combinerPred pred1 pred2 op = \x - op (pred1 x) (pred2 x) That's the `(-) a` monad: import Control.Applicative combinerPred :: (a - Bool) - (a - Bool) - (Bool - Bool - Bool) - (a - Bool) combinerPred pred1 pred2 op = op $ pred1 * pred2 Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Estágio com Haskell em SP (Haskell internship at São Paulo, Brazil)
(English message follows after the break.) Olá! Estamos procurando um estagiário para trabalhar conosco em São Paulo capital. Nós somos uma startup apaixonada por Haskell com uma boa participação na comunidade e grandes projetos e desafios! Se você está interessado, basta me mandar um e-mail (felipe.le...@gmail.com) com um link para sua conta do GitHub (ou para projetos em que você já tenha trabalhado). Você não precisa ser experiente em Haskell nem ter nenhum código Haskell publicado, mas isso seria um diferencial =). Como a startup está em stealth mode, não posso divulgar o nome da empresa e por isso estou usando meu e-mail pessoal. Até mais! === Hey! We're looking for an intern to work with us in São Paulo, Brazil. We're a startup passionate about using Haskell with great projects and challenges! If you're interested, just send me an e-mail (felipe.le...@gmail.com) with a link to your GitHub account (or to any projects you've worked at). You don't need to be an experienced Haskeller nor have any published Haskell code, but that would be a plus =). As the startup is in stealth mode, I can't disclose the company's name nor use my work e-mail (that's why I'm using my personal one). Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: reform - a type-safe form generation and validation library in the spirit of formlets and digestive-functors 0.2
On Mon, May 21, 2012 at 7:18 PM, Jeremy Shaw jer...@n-heptane.com wrote: I hope to do a full comparison of reform vs digestive-functors 0.3 vs yesod forms in a few weeks. That would be awesome! Just sayin' =). Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] darcs patch dependencies in dot format
Truly amazing! I wonder it would fare with larger repositories. =) Cheers, -- Felipe – enviado do meu Galaxy Tab. Em 12/05/2012 09:52, Sönke Hahn sh...@cs.tu-berlin.de escreveu: Hi all! Yesterday I wrote a little tool to output the dependencies of darcs patches in dot format. The hardest part was to wrap my head around the darcs API and find a way to let it compute the patch dependencies. I don't know, if I got it right, but it looks correct at first glance. Here is the code: https://patch-tag.com/r/shahn/darcs2dot To use it just execute the program in a darcs repo and it will output a dot graph to stdout. The graph does not contain all dependencies, but the transitive reduction. The patch names are truncated at 15 characters. And here is an example graph: http://open-projects.net/~shahn/patchDeps.pdf These are the patch dependencies of one of my darcs repos (https://patch-tag.com/r/shahn/hate). Some observations I made: * There are two completely separate subgraphs. One subgraph seems to be for the testsuite, the other for the actual code. This means, the two don't depend on each other and could easily be put in two distinct repos. * There is a re-implementation patch with a lot of incoming and outgoing edges. (Which makes sense.) * There are some sequences of patches (e.g. these four allow ... patches in the upper left corner) that seem to contain related patches. * darcs's patch system is awesome! Any comments or suggestions? Cheers, Sönke ___ 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] Unit and pair
On Tue, May 8, 2012 at 2:36 PM, MigMit miguelim...@yandex.ru wrote: Hi café, a quick question. Is there a somewhat standard class like this: class Something c where unit :: c () () pair :: c x y - c u v - c (x, u) (y, v) ? I'm using it heavily in my current project, but I don't want to repeat somebody else's work, and it seems general enough to be defined somewhere; but my quick search on Hackage didn't reveal anything. I know about arrows; this, however, is something more general, and it's instances aren't always arrows. Are you aware of generalized arrows [1]? It's still a lot more than your Something, though. [1] http://www.cs.berkeley.edu/~megacz/garrows/ -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Learn you
On Wed, May 2, 2012 at 2:41 PM, Wojciech Jedynak wjedy...@gmail.com wrote: In formal grammar it should be Sugoi Haskell tanoshiku WO manabou! - this WO is a particle identifying the object and this omission is normal in colloquial, spoken Japanese. My basic Japanase is very rusty, but shouldn't that be sugoi Haskell wo tanoshiku manabou? Not trying to find errors, just trying to learn something myself =). Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: planar-graph-1.0
Hello! I'm sorry if this is a dumb question, I was just reading the API docs, but: what happens if one by one I add all edges of a non-planar graph using addEdge? Are there any sanity checks that would tell me sorry, but your graph isn't planar, or would it just give me wrong answers? Cheers, =) -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] ANN: cabal-install-0.14.0
On Tue, Apr 17, 2012 at 1:59 PM, Andres Löh andres.l...@googlemail.com wrote: * Completely new modular dependency solver (default in most cases) Great! =D -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: Selenium WebDriver client for Haskell
That looks great, Adam, thanks for sharing! I've been using watir-webdriver but ruby tends to be a lot more painful to use than Haskell (even though I use ruby only for the tests!). Looking forward to see what I can do with your package =). Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Too much inlining on text package
On Sun, Apr 8, 2012 at 2:47 AM, Bryan O'Sullivan b...@serpentine.com wrote: I fixed the too-much-inlining bug tonight. As a bonus, Text literals are now decoded straight from GHC's packed encoding, without an intermediate step through String. Generated code now looks like this at -O and above: $ ghc -O -ddump-simpl -c CS.hs CS.foo :: Data.Text.Internal.Text [GblId, ...] CS.foo = Data.Text.unpackCString# x\NULy Very nice! =) Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] ANNOUNCE: haskell-src-exts-1.13.0
On Wed, Mar 28, 2012 at 5:52 PM, dag.odenh...@gmail.com dag.odenh...@gmail.com wrote: Wait, what? Perhaps they were assigned the task of updating haskell-src-exts code to support Haskell2010? =) -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [ANNOUNCE] vector-conduit
Nice package! An idea for sourceVector is to use the streaming interface [1]. It would be nice if GHC could fuse the array with sourceVector, avoiding to produce the array in the first place, but I'm not going to hold my breath =). Cheers, [1] http://hackage.haskell.org/packages/archive/vector/0.9.1/doc/html/Data-Vector-Generic.html#v:stream -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [ANNOUNCE] vector-conduit
On Thu, Mar 22, 2012 at 8:03 PM, Jared Hance jaredha...@gmail.com wrote: I looked over it and decided to simply go with head/tail (not sure why I used the index thing... head/tail is so much more functional). That should still get some fusion benefit, right, since it all uses streams under the hood? I'm almost sure that it won't fuse using head and tail, but YMMV. Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Are there arithmetic composition of functions?
import Control.Applicative f, g :: Float - Float f x = x + 1 g x = 2 * x h = (+) $ f * g Cheers, =) -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Theoretical question: are side effects necessary?
On Fri, Mar 16, 2012 at 9:23 AM, Christopher Svanefalk christopher.svanef...@gmail.com wrote: Are there any problems which cannot be solved a side effect-free language (such as Haskell)? In other words, are there problems that would explicitly demand semantics that can only be provided by a language allowing direct modification of external state variables, such as Java and C++? Haskell, Java, C++ and most other languages out there are Turing-complete. That means that all of them are able to compute the same things. Assuming that the Church-Turing hypothesis is true, all algorithms may be coded in all of them. If not, are there problems which are simply infeasible to solve with a side effect-free language? If you're asking about performance, as in is there a problem that can be solved in O(f(n)) time in Java but not in Haskell-sans-IO-and-ST?, then it becomes a harder question. I'm not sure what the answer is. Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Too much inlining on text package
Hello! tl;dr: text package's pack function is creating huge chunks of code everywhere. Michael Snoyman and I have been trying to nail the performance problems of persistent's Template Haskell code -- GHC was taking a lot of memory and CPU time to compile these. What we found out is that the code size was getting increased 20-fold by the simplifier on phase 0 on GHC 7.0 (c.f. http://groups.google.com/group/yesodweb/msg/9f625fcf85575263). So, what was increasing in size? Consider this extremely simple module (attached as Bug.hs): module Bug (text) where import qualified Data.Text as T text :: T.Text text = T.pack text Until simplifier phase 0, the code size floats but tops at 12. Here's the core: Bug.text :: Data.Text.Internal.Text [LclIdX, Unf=Unf{Src=vanilla, TopLvl=True, Arity=0, Value=False, ConLike=False, Cheap=False, Expandable=False, Guidance=IF_ARGS [] 11 0}] Bug.text = Data.Text.Fusion.unstream (Data.Text.Fusion.Common.streamList @ GHC.Types.Char (GHC.Base.map @ GHC.Types.Char @ GHC.Types.Char Data.Text.Internal.safe (GHC.Base.unpackCString# text))) Which is straightforward. However, on simplifier phase 0 the code size jumps to 391 (!!), a 32-fold increase. I've attached the core (after.hs) since it's too large to copy here on the body. So it seems that the (unstream . streamList) pair above is getting inlined to a HUGE chunk of code (at least Data.Text.Array.new is getting inlined). Worse yet, this happens for every single pack that you use, even those packs hidden by OverloadedStrings! Does anyone have any ideas why GHC is inlining so much code everywhere? While everything I said here was tested on GHC 7.0, we have evidence that GHC 7.4 suffers from the same problem. We don't know about GHC 6.12, though. This seems to be a problem for everyone who uses text, which we hope is everyone using Haskell ;-). Cheers, -- Felipe. Simplifier SimplMode {Phase = 0 [main], inline, rules, eta-expand, case-of-case} max-iterations=4 iteration=2 Bug.text :: Data.Text.Internal.Text [LclIdX, Unf=Unf{Src=vanilla, TopLvl=True, Arity=0, Value=False, ConLike=False, Cheap=False, Expandable=False, Guidance=NEVER}] Bug.text = case GHC.Base.map @ GHC.Types.Char @ GHC.Types.Char Data.Text.Internal.safe (GHC.Base.unpackCString# text) of tpl_arP { __DEFAULT - letrec { a_stU :: forall s1_ao6. Data.Text.Array.MArray s1_ao6 - GHC.Types.Int - [GHC.Types.Char] - GHC.Types.Int - GHC.Prim.State# s1_ao6 - (# GHC.Prim.State# s1_ao6, (Data.Text.Array.MArray s1_ao6, GHC.Types.Int) #) [LclId, Arity=5, Unf=Unf{Src=vanilla, TopLvl=False, Arity=5, Value=True, ConLike=True, Cheap=True, Expandable=True, Guidance=NEVER}] a_stU = \ (@ s1_ao6) (arr_ao7 :: Data.Text.Array.MArray s1_ao6) (top_ao8 :: GHC.Types.Int) (eta_B3 :: [GHC.Types.Char]) (eta_B2 :: GHC.Types.Int) (eta_B1 :: GHC.Prim.State# s1_ao6) - letrec { a_stS :: [GHC.Types.Char] - GHC.Types.Int - GHC.Prim.State# s1_ao6 - (# GHC.Prim.State# s1_ao6, (Data.Text.Array.MArray s1_ao6, GHC.Types.Int) #) [LclId, Arity=3, Unf=Unf{Src=vanilla, TopLvl=False, Arity=3, Value=True, ConLike=True, Cheap=True, Expandable=True, Guidance=NEVER}] a_stS = \ (s_aoa :: [GHC.Types.Char]) (i_aob :: GHC.Types.Int) (eta_Xf :: GHC.Prim.State# s1_ao6) - case s_aoa of s1_aoI { __DEFAULT - case i_aob of i1_aoJ { GHC.Types.I# ipv_aoL - case s1_aoI of _ { [] - (# eta_Xf, (arr_ao7, i1_aoJ) #); : x_arU xs_arV - case x_arU of tpl1_arX { GHC.Types.C# ipv_stw - case xs_arV of tpl2_arY { __DEFAULT - let { a_ape :: GHC.Prim.State# GHC.Prim.RealWorld - GHC.Prim.State# s1_ao6 - (# GHC.Prim.State# s1_ao6, (Data.Text.Array.MArray s1_ao6, GHC.Types.Int) #) [LclId, Arity=2, Unf=Unf{Src=vanilla, TopLvl=False, Arity=2, Value=True, ConLike=True, Cheap=True, Expandable=True, Guidance=IF_ARGS [0 0] 38 12}] a_ape = \ _ (s2_apg :: GHC.Prim.State# s1_ao6) - let { x1_aph :: GHC.Prim.Int# [LclId,
Re: [Haskell-cafe] Double-dispatch
{-# LANGUAGE MultiParamTypeClasses #-} class Intersectable a b where intersectsWith :: a - b - Bool -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Test suite sections of cabal
On Thu, Feb 16, 2012 at 12:56 AM, Kazu Yamamoto k...@iij.ad.jp wrote: 2) build-dependency I need to repeat all build-dependency of a library section to a test suite section. Specifying the library itself to build-dependency of a test suite section does not work. This violates the DRY philosophy. You may specify the same library as a dependency given that you use different hs-source-dirs. For example, see skein's Cabal file [1]. Of course, you won't be able to directly test any internal function. HTH, [1] http://hackage.haskell.org/packages/archive/skein/0.1.0.5/skein.cabal -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Test suite sections of cabal
On Thu, Feb 16, 2012 at 7:24 AM, Kazu Yamamoto k...@iij.ad.jp wrote: Do you mean that if we separate directories for src and test, build-depends of test-suite works, and if we don't separate, it does not work? If we have separate directories, then you can build-depends: own-package. This means that on the test suite's build-depends you need to list only the dependencies that the test-suite needs, not every dependency. Also, you don't need to constrain the version of any duplicated dependency. Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] [ANNOUNCE] fb package, bindings to Facebook's API
Hello, everyone! I'm pleased to finally announce the fb package, a Haskell-only package that provides bindings to Facebook's API. This package is sponsored by my employer, which will soon enough be able to become the copyright holder of all of our open source contributions. http://hackage.haskell.org/package/fb It's by no means complete, but we thrive to be as correct as possible and to turn API errors into type errors caught at compile time. Right now the current version is fb 0.7.2. While this is the first announcement, this package is already being actively used by Facebook authentication code on Yesod (yesod-auth-fb package) and internally at my day job's projects. Hope you find it useful! =) Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: stm-conduit-0.2.1
Your package uses TMChans which AFAIK are unbounded. That means that if the writer is faster than the reader, then everything will be kept into memory. This means that using TMChans you may no longer say that your program uses a constant amount of memory. Actually, you lose a lot of your space reasoning since, being concurrent processes, you can't guarantee almost anything wrt. progress of the reader. This doesn't mean that your package is broken, this means that it has a caveat that should be stated on the docs. Congrats on your Hackage debut! Cheers! =) -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] ANNOUNCE: hs-json-rpc 0.0.0.1
[Redirecting to haskell-cafe] Congrats on your first release! While I haven't looked into your package in more depth, I'd suggest taking a look at http-conduit [1]. While I don't know of any benchmarks, it should be faster or at least as fast the HTTP package. It's also used by many people everyday (myself included), which means that it has no major bugs and that bugs are promptly solved. It also has some features that HTTP doesn't. Cheers! [1] http://hackage.haskell.org/package/http-conduit -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Conduit experiment: Is this correct?
On Fri, Feb 3, 2012 at 1:38 PM, yi huang yi.codepla...@gmail.com wrote: Since Sink works in a CPS fashion, by which i mean every step it return a new push close pair, i think it can be used multiple time. Actually, this is exactly why it *can't* be used multiple times. Cheers! -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Again, version conflicting problem with cabal-install
On Fri, Feb 3, 2012 at 2:22 PM, Andres Löh andres.l...@googlemail.com wrote: A controlled way of ignoring version constraints (mainly upper bounds, actually) is certainly on my TODO list for the new solver. The main issue to work out is a good way how to control the disabled bounds via the command line, because you usually don't want to ignore all of them. Currently, my UI-preference is a flag --force-allow=foo-1.3 with the semantics that all dependencies on foo will be changed to allow foo-1.3 to be chosen. Would that be ok? Other suggestions? Can't this be integrated with the current --constraint flag? If the constraint is able to be satisfied without unrestricting any bounds, fine. Otherwise, unrestrict any bounds on that constraint. What would be the drawbacks? An advantage is being able to specify --constraint='foo = 1.3' to get foo-1.3.7.2 instead of having to find out exactly which version you want. And if you already know what you want, you may always say --constraint='foo == 1.3.7.2'. Looking forward to the new solver! =) Cheers! -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] network-conduit failing to close sockets
2012/2/1 Ertugrul Söylemez e...@ertes.de: Hello there, I have tried to implement a simple echo server using the network-conduit library version 0.2.1. This is the code: module Main where import Data.Conduit import Data.Conduit.Network main :: IO () main = runTCPServer (ServerSettings 4000 Nothing) ($$) It works, but at some point it dies with too many open files, even though I never open two connections simultaneously: % ./echo-server echo-server: accept: resource exhausted (Too many open files) Apparently it fails to close the sockets properly. This is the client side code I have used for testing in GHCi: :m Network Control.Monad System.IO replicateM_ 512 (connectTo 127.0.0.1 (PortNumber 4000) = hClose) I'm running the action once, then wait a few seconds to give the server a chance to close the handles. Then I run it again, causing the server program to die with the above mentioned error message. Am I doing something wrong or is this a bug in network-conduit? This part of network-conduit is very new so bugs are expected. Michael, it seems that runTCPServer [1] should setup a release key on the ResourceT in order to close the socket after app finishes, right? Cheers! =) [1] http://hackage.haskell.org/packages/archive/network-conduit/0.2.1/doc/html/src/Data-Conduit-Network.html#runTCPServer -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] strict version of Haskell - does it exist?
On Tue, Jan 31, 2012 at 6:05 AM, Marc Weber marco-owe...@gmx.de wrote: I didn't say that I tried your code. I gave enumerator package a try counting lines which I expected to behave similar to conduits because both serve a similar purpose. Then I hit the the sourceFile returns chunked lines issue (reported it, got fixed) - Anyway: My log files are a json dictionary on each line: { id : foo, ... } { id : bar, ... } Now how do I use the conduit package to split a chunked file into lines? Or should I create a new parser many json newline ? Currently there are two solutions. The first one is what I wrote earlier on this thread: jsonLines :: C.Resource m = C.Conduit B.ByteString m Value jsonLines = C.sequenceSink () $ do val - CA.sinkParser json' CB.dropWhile isSpace_w8 return $ C.Emit () [val] This conduit will run the json' parser (from aeson) and then drop any whitespace after that. Note that it will correctly parse all of your files but will also parse some files that don't conform to your specification. I assume that's fine. The other solution is going to released with conduit 0.2, probably today. There's a lines conduit that splits the file into lines, so you could write jsonLines above as: mapJson :: C.Resource m = C.Conduit B.ByteString m Value mapJson = C.sequenceSink () $ do val - CA.sinkParser json' return $ C.Emit () [val] which doesn't need to care about newlines, and then change main to main = do ... ret - forM_ fileList $ \fp - do C.runResourceT $ CB.sourceFile fp C.$= CB.lines C.$= -- new line is here mapJson C.$= CL.mapM processJson C.$$ CL.consume print ret I don't know which solution would be faster. Either way, both solutions will probably be faster with the new conduit 0.2. Except that I think my processJson for this test should look like this because I want to count how often the clients queried the server. Probalby I should also be using CL.fold as shown in the test cases of conduit. If you tell me how you'd cope with the one json dict on each line issue I'll try to benchmark this solution as well. This issue was already being coped with in my previous e-mail =). -- probably existing library functions can be used here .. processJson :: (M.Map T.Text Int) - Value - (M.Map T.Text Int) processJson m value = case value of Ae.Object hash_map - case HMS.lookup (T.pack id) hash_map of Just id_o - case id_o of Ae.String id - M.insertWith' (+) id 1 m _ - m _ - m _ - m Looks like the perfect job for CL.fold. Just change those three last lines in main from ... C.$= CL.mapM processJson C.$$ CL.consume into ... C.$$ CL.fold processJson and you should be ready to go. Cheers! -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [ANNOUNCE] biostockholm 0.2
On Thu, Jan 26, 2012 at 11:42 PM, Felipe Almeida Lessa felipe.le...@gmail.com wrote: - Fast enough: the streaming interface achieves 12 MiB/s for parsing, which is pretty nice considering that there are some known overheads on its implementation. I've just released biostockholm 0.2.1 which uses conduit 0.2. Now the streaming interface achieves 31 MiB/s when parsing Rfam 9.1's full data on my computer, which is a 2.6x increase in performance! Kudos to Michael Snoyman who squashed the biggest known overhead that I've mentioned above on this new conduit 0.2 release. Cheers! =) -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] strict version of Haskell - does it exist?
On Tue, Jan 31, 2012 at 1:36 PM, Marc Weber marco-owe...@gmx.de wrote: Adding a \state - (the way Felipe Lessa told me) make is work and it runs in about 20sec and that although some conduit overhead is likely to take place. Just out of curiosity: did you use conduit 0.1 or 0.2? Cheers! =) -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [ANN] Crypto-API 0.9 Release
On Tue, Jan 31, 2012 at 9:36 PM, Thomas DuBuisson thomas.dubuis...@gmail.com wrote: Release 0.9 Changes: * Crypto.Classes now exports 'Data.Serialize.encode' * AsymCipher now has proper fundeps * cpolysArr is no longer one big line Also: * MacKey has phantom types. This seems to be the only breaking change [1]. Cheers, [1] http://hdiff.luite.com/cgit/crypto-api/commit?id=0.9 -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] strict version of Haskell - does it exist?
On Mon, Jan 30, 2012 at 6:21 AM, Herbert Valerio Riedel h...@gnu.org wrote: On Sun, 2012-01-29 at 23:47 +0100, Marc Weber wrote: So maybe also the JSON parsing library kept too many unevaluated things in memory. So I could start either writing my own JSON parsing library (being more strict) Jfyi, aeson has been added strict parser variants json' and value' some time ago, so you shouldn't have to write your own stricter JSON parsing library... Also, besides using those variants, you may also use the attoparsec-conduit library [1]. If you have processJson :: Value - IO X then you'd need just something like import Data.Aeson (Value, json') import Data.Attoparsec.Char8 (isSpace_w8) import qualified Data.ByteString as B import qualified Data.Conduit as C import qualified Data.Conduit.Attoparsec as CA import qualified Data.Conduit.Binary as CB import qualified Data.Conduit.List as CL main = do ... ret - forM_ fileList $ \fp - do C.runResourceT $ CB.sourceFile fp C.$= jsonLines C.$= CL.mapM processJson C.$$ CL.consume print ret jsonLines :: C.Resource m = C.Conduit B.ByteString m Value jsonLines = C.sequenceSink () $ do val - CA.sinkParser json' CB.dropWhile isSpace_w8 return $ C.Emit () [val] This code is extremely resource-friendly, since (a) you can't leak file descriptors and (b) you just have to make sure that processJson function isn't too lazy. It should be quite fast as well. Cheers! =) [1] http://hackage.haskell.org/package/attoparsec-conduit -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] strict version of Haskell - does it exist?
On Mon, Jan 30, 2012 at 2:12 PM, Marc Weber marco-owe...@gmx.de wrote: @ Felipe Almeida Lessa (suggesting conduits and atto parsec) I mentioned that I already tried it. Counting lines only was a lot slower than counting lines and parsing JSON using PHP. Then please take a deeper look into my code. What you said that you've tried is something else. Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] help with safecopy + acid-state
On Mon, Jan 30, 2012 at 4:46 PM, Johannes Waldmann waldm...@imn.htwk-leipzig.de wrote: Thanks - which zero? (there are two of them.) You should not change the deriveSafeCopy of your old data type. The only allowed change is renaming your data type (see below). You should increment the version of the new version of your data type, akin to releasing a new version of a library. Can I really rename old.T = new.T_orig ? It looks as if then tries to load the wrong acid-state snapshot. The name of your data type doesn't matter as acid-state doesn't store that on the disk. HTH, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] TCP Server
On Sun, Jan 29, 2012 at 10:14 AM, Jean-Marie Gaillourdet j...@gaillourdet.net wrote: But it does try to solve the problem, doesn't it? Obviously conduit is an alternative to the iteratee-like packages. Why else would Yesod replace enumerator by conduit? That is the reason why I added it into my list of iteratee-like packages. I'm sorry if I misunderstood your message. I read your e-mail as though you were saying that the choice between these libraries has only to do with your taste, and your taste will decide the other libraries with which yours may interoperate. This may be true between iteratee, enumerator and iterIO (module some specific features of each one of them), but that's not true for pipes (since it doesn't handle IO at all right now) and conduit (since it has a different concept despite having the same goal). Cheers, =) -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] TCP Server
On Sat, Jan 28, 2012 at 9:40 AM, Yves Parès yves.pa...@gmail.com wrote: I think there is still no consensus on which iteratee library is the one to use. There are at least iteratee, enumerator, iterIO, conduit, and pipes. The reusability of your libary depends on the choice of iteratee-style library you select. Yes, and IMO this is a growing problem. Since iteratees were designed, a lot of different libraries providing this kind of service have appeared. Of course they all have advantages and inconvenients, but some libraries that could be compatible are not, because they rely on a different iteratee-ish package. For instance pipes (as its documentation states) is really like iteratee... but with more concrete names. Still it's sufficient to break compatibility. Or else, we have to make sure that each one (iteratee, enumerator, conduit, pipes...) has its own set of associated packages and that each provide equivalent functionalities, but then = combinatorial explosion. I find it funny that conduit is said to be an iteratee library since it has no iteratees! We've had more than one iteratee library since at least 1.5 years with the iteratee (Mar 2009) and enumerator (Aug 2010) packages, and AFAIK now we have four iteratee libraries: those two, iterIO (May 2011) and pipes (Jan 2012). However, conduit is not the fifth since it has no iteratees, no enumerators, no enumeratees... it's a different concept, not a different implementation. In principle it's possible to have some code that converts functions between these different iteratee packages -- at least between iteratee, enumerator and iterIO since these seem to have more or less the same implementation ideas. Converting from pipes may be possible, but to pipes seems pretty difficult since pipes sweeps IO under the rug. Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] help with safecopy + acid-state
On Fri, Jan 27, 2012 at 3:04 PM, Johannes Waldmann waldm...@imn.htwk-leipzig.de wrote: data T_orig = T_orig Foo $(deriveSafeCopy 0 'base ''T_orig) data T = T Foo Bar $(deriveSafeCopy 0 'extension ''T) instance Migrate T where type MigrateFrom T = T_Orig ... As you can read from deriveSafeCopy's documentation [1], you need to increase the version of your data type (e.g. change that zero to one). HTH, [1] http://hackage.haskell.org/packages/archive/safecopy/0.6.1/doc/html/Data-SafeCopy.html#v:deriveSafeCopy -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] [ANNOUNCE] biostockholm 0.2
Hello! I'm pleased to announce the second major release of the biostockholm library! This library allows you to parse and render files in the Stockholm 1.0 format, which is used by Pfam, Rfam, Infernal and others for holding information about families of proteins or non-coding RNAs. http://hackage.haskell.org/package/biostockholm Despite this low increase in number from 0.1 to 0.2, this is actually a big rewrite of the library. Now we have: - An streaming interface similar to what SAX parsers provide. This allows you to consume Stockholm files using constant memory (80k in a simple case). - More test cases. It's able to consume its own pretty printed version of Rfam through the document interface, and is also capable of reading the full Rfam stockholm file (which has some huge families) through the streaming interface. - QuickCheck properties. Now we have three different QuickCheck properties covering almost everything. These have helped uncover some tricky bugs that were never found before. However, two of these three properties still don't pass, but I consider the failing examples that I've investigated just corner cases. Unfortunately, Stockholm lacks a formal specification. - Conduit interface. Besides a lazy I/O version, now there's a conduit interface. - Code much easier to read and reason about. - Fast enough: the streaming interface achieves 12 MiB/s for parsing, which is pretty nice considering that there are some known overheads on its implementation. For the tasks that biostockholm 0.1 already handled, biostockholm 0.2 tends to be slightly slower. However, biostockholm 0.2 is able to handle some previously impossible cases where an streaming solution is required. Cheers! -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hierarchical tracing for debugging laziness
On Wed, Jan 25, 2012 at 7:38 PM, Yves Parès yves.pa...@gmail.com wrote: But I haven't found a way to tell GHCI to fully evaluate 'x' but _not_ print its value. Use the :force, Yves! let {a = htrace a 12; b = htrace b 29; c = htrace c 10; d = htrace d 90; x = htrace , (htrace + (a+b), htrace * (c*d)) } :force x , + a b * c d x = (41,900) Cheers! =) -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hierarchical tracing for debugging laziness
Really nice! Looks like it could be a useful mini-package on Hackage. -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Efficient temporary file storage??
On Mon, Jan 23, 2012 at 9:37 PM, Nick Rudnick nick.rudn...@googlemail.com wrote: if you want to temporarily store haskell data in a file – do you have a special way to get it done efficiently? In an offline, standalone app, I am continuously reusing data volumes of about 200MB, representing Map like tables of a rather simple structure, key: (Int,Int,Int) value: [((Int,Int),LinkId)] which take quite a good deal of time to produce. Is there a recommendation about how to 'park' such data tables most efficiently in files – any format acceptable, quick loading time is the most desirable thing. Use cereal [1], usually it's fast and easy enough. If you need to be able to access your files for a long time, consider using safecopy [2] (which internally uses cereal as well). [1] http://hackage.haskell.org/package/cereal [2] http://hackage.haskell.org/package/safecopy HTH, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Network.Browser and Network.TLS
On Mon, Jan 16, 2012 at 6:28 PM, Myles C. Maxfield myles.maxfi...@gmail.com wrote: I am interested in extending the Network.HTTP code in the HTTP package to support HTTPS via TLS. [snip] I am left with the conclusion that it is impossible to support TLS in Network.Browser without breaking many Haskell programs. It is obviously possible to fork the HTTP library, but I'd like to improve the state of the existing libraries. Likewise, it is possible to create a new module that supports HTTPS but has different typed functions and lots of code duplication with Network.Browser, but that is quite inelegant. If you need Network.Browser's functionality, it would be great if it could be ported to work with http-conduit. I wouldn't consider using HTTP on any production code. Perhaps I should just use the Network.HTTP.Enumerator module and not deal with Network.Browser? Maybe I'm going about this in entirely the wrong way. What are you trying to do? On most cases http-conduit has everything you need. Cheers! -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A simple telnet client using Conduit
On line 29, instead of liftIO $ do mapM_ ... runResourceT $ do ... ... why not liftIO $ mapM_ ... ... ... ? Regarding threads, you should use resourceForkIO [1] which has a quite nicer interface. So you telnet would end like: telnet :: String - Int - IO () telnet host port = runResourceT $ do (releaseSock, hsock) - with (connectTo host $ PortNumber $ fromIntegral port) hClose liftIO $ mapM_ (\h - hSetBuffering h LineBuffering) [ stdin, stdout, hsock ] resourceForkIO $ sourceHandle stdin $$ sinkHandle hsock sourceHandle hsock $$ sinkHandle stdout release releaseSock Disclaimer: code not tested =). Cheers, [1] http://hackage.haskell.org/packages/archive/conduit/0.0.2/doc/html/Control-Monad-Trans-Resource.html#v:resourceForkIO -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A simple telnet client using Conduit
On Wed, Jan 11, 2012 at 10:28 PM, Erik de Castro Lopo mle...@mega-nerd.com wrote: Thanks for the input Felipe. Felipe Almeida Lessa wrote: On line 29, instead of liftIO $ do mapM_ ... runResourceT $ do Well that was because that whole block needs to run in IO. My point is that the second runResourceT is not necessary. Regarding threads, you should use resourceForkIO [1] which has a quite nicer interface. I did read about resourceForkIO and it says: Introduce a reference-counting scheme to allow a resource context to be shared by multiple threads. Once the last thread exits, all remaining resources will be released. In my case, I don't have any resources that are shared between threads. All I have is the actual ThreadId returned by forkIO. Since that ThreadId actually isn't used explicitly anywhere (but is implicitly passed to killThread when release releaseThread is called). Actually, hsock is shared between both threads. With your original code, it gets closed regardless of what the other thread is doing. Which in this case is what you want, but you need to be careful. The other thing about your solution is the question of what happens to the ThreadId returned by resourceForkIO. Rewriting your solution to explicity handle the ThreadId I get: telnet :: String - Int - IO () telnet host port = runResourceT $ do (releaseSock, hsock) - with (connectTo host $ PortNumber $ fromIntegral port) hClose liftIO $ mapM_ (\h - hSetBuffering h LineBuffering) [ stdin, stdout, hsock ] tid - resourceForkIO $ sourceHandle stdin $$ sinkHandle hsock sourceHandle hsock $$ sinkHandle stdout liftIO $ killThread tid release releaseSock The problem here is that I am not sure if the explicit killThread is actually needed [...] What about inverting which thread gets to do what? _ - resourceForkIO $ sourceHandle hsock $$ sinkHandle stdout sourceHandle stdin $$ sinkHandle hsock release releaseSock My reasoning is that: - 'sourceHandle stdin' will close after the user presses ^D, thereby reaching 'release releaseSock'. - After the socket is closed, 'sourceHandle hsock' will close as well, killing the thread. Note that without 'release releaseSock' the socket would not be closed until the other thread died. [...] and it is, I think my solution, where killThread happens automatically is actually better. If what happens within the outer call to resourceT is a long running process, your solution (in the absence of the explicit killThread) could leave threads lying around that would have been cleaned up much earlier in my soltuion. Actually, I'm not sure if my solution is better or worse than yours. The question is how long does it take for the thread to die after hsock gets closed? If the answer is right away, then my solution is simpler =). Otherwise, you solution is less resource-hungry. Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to show a utf8 string?
On Tue, Jan 10, 2012 at 7:55 AM, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Hi, I am using LDAP hackage to do some ldap searching. I am not sure if this is its problem. All Chinese chars returned like \29579. How to convert it to the actual Chinese char? I thought it was my terminal's fault, so tried to use System.IO.UTF8 to put the result into a file and viewed by firefox, no luck. Are you using print? Did you try putStrLn? Cheers, =) -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] too many open files using snap
On Sun, Jan 8, 2012 at 12:27 PM, Gregory Collins g...@gregorycollins.net wrote: A too many open files error is usually due to running out of file descriptors for network sockets. On my Linux machine the per-process limit for file descriptors defaults to 1024, and on my Mac the default is 256. You can see your current limit by running ulimit -a from the terminal. If you're on Linux, then you may $ ls -lah /proc/PID/fd to see where these open files are pointing to. HTH, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [web-devel] [ANNOUNCE] First release of crypto-conduit
On Sat, Jan 7, 2012 at 8:06 AM, Greg Weber g...@gregweber.info wrote: I am wondering if you can provide even higher-level APIs for the common case: hash - runResourceT $ hashFile my-file and possibly something that runs the ResourceT transformer: hash - runHashFile my-file That's dead simple to add, I just wonder which ones should be added (since triplicating the whole API wouldn't be fun). So you're assuming that hashing is the most common case of the library, right? Now, having 'hashFile' inside ResourceT isn't terribly useful and if the user needs it, it's trivial to implement, so I'm thinking of just exporting a single new function: hashFile :: (MonadIO m, Hash ctx d) = FilePath - m d I'll include it on the next version. =) Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [web-devel] [ANNOUNCE] First release of crypto-conduit
On Sat, Jan 7, 2012 at 9:12 AM, Aristid Breitkreuz arist...@googlemail.com wrote: And while we're at it, some code to deal with the cumbersome decoding of those hash objects would be nice! I'm sorry, but what do you mean by cumbersome decoding? Cheers, =) -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [web-devel] [ANNOUNCE] First release of crypto-conduit
On Sat, Jan 7, 2012 at 12:16 PM, Aristid Breitkreuz arist...@googlemail.com wrote: Well, how do you get a ByteString from the hash object? Just use encode from Data.Serialize. =) Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] [ANNOUNCE] First release of crypto-conduit
Hello! I'm pleased to announce the first release of crypto-conduit [1]! The crypto-api [2] package provides APIs for many cryptographic operations, such as cryptographic hashes and block ciphers. This new crypto-conduit package allows you to use many of these operations with conduits [3], giving you safe I/O using constant memory and no leaks. As an example, here's how you could get the SHA1 hash a file: import Crypto.Conduit -- from crypto-conduit import Crypto.Hash.SHA1 (SHA1) -- from cryptohash import Data.Conduit -- from conduit import Data.Conduit.Binary (sourceFile) -- from conduit main = do hash - runResourceT $ sourceFile my-file $$ sinkHash print (hash :: SHA1) The code snippet above, despite having only sourceFile ... $$ sinkHash on its core, guarantees that the file handle is not kept open and uses a constant amount of memory. Sweet! Please break this package! Although it comes with a test suite, it has just seen the light of the day. Cheers, =) [1] http://hackage.haskell.org/package/crypto-conduit [2] http://hackage.haskell.org/package/crypto-api [3] http://hackage.haskell.org/package/conduit -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to split this string.
On Mon, Jan 2, 2012 at 10:12 AM, max m...@mtw.ru wrote: This is the simplest solution of the proposed, in my opinion. Thank you very much. Better yet, don't use String and use Text. Then you just need T.splitOn \r\n [1]. Cheers, [1] http://hackage.haskell.org/packages/archive/text/0.11.1.12/doc/html/Data-Text.html#v:splitOn -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe