Re: [Haskell-cafe] tplot (out of memory)
Hi, Manish Trivedi trivman...@gmail.com writes: I am running into a weird out of memory issue. While running timeplot over an input file having ~800 rows. From below provided info, seems like machine has enough ram (1849MB). Please let me know if anyone has pointers. I have run tplot on much larger files than that without troubles. Which version are you using? I assume this is the one from hackage which AFAIK is the one I am also using. Could you post a sample input file? Regards, -- Arnaud Bailly FoldLabs Associate http://foldlabs.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Asking for advice on programming style and also performance
Hi, Am Montag, den 03.09.2012, 18:31 +0200 schrieb Harald Bögeholz: I would greatly appreciate advice from experienced Haskellers why this has happened. The program is hosted on github; this is the direct link to the change with unexpected outcome: https://github.com/ctbo/slitherlink/commit/b6f58699258ef68ddee21a1346bd184465aaaba2 I’m not sure if you are notified via github, but there are comments there below the commit. Greetings, Joachim -- Joachim nomeata Breitner m...@joachim-breitner.de | nome...@debian.org | GPG: 0x4743206C xmpp: nome...@joachim-breitner.de | http://www.joachim-breitner.de/ signature.asc Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Over general types are too easy to make.
I agree with Timothy. In the Agda code base, we have many occurrences of Timothy's pattern aux (OneSpecificConstructor args) = ... aux _ = __IMPOSSIBLE__ where __IMPOSSIBLE__ generates code to throw an internal error. A finer type analysis that treats each constructor as its own type would save us from the impossible catch-all clause. Type-theoretically, what you want is proper, i.e., untagged unions of data types with disjoint sets of constructors. data C1 params = C1 args1 data C2 params = C2 args2 type D params = C1 params | C2 params Now D is the untagged union of C1 and C2. This allows you to give precise typing of aux without uglifying your data structure design with extra tags. Untagged unions are a bit nasty from the type-checking perspective, because you are moving from a name-based type discipline to a structure-based one. (Maybe this was meant by rows.) Ocaml can do this, as far as I know, but I use Haskell... Good we discussed this. And off to limbo... Cheers, Andreas On 02.09.12 11:57 PM, timothyho...@seznam.cz wrote: Looks like I failed to reply all -- Původní zpráva -- Od: timothyho...@seznam.cz Datum: 2. 9. 2012 Předmět: Re: Re: [Haskell-cafe] Over general types are too easy to make. Care to link me to a code repository that doesn't have this problem? The only Haskell program that I have in my github that hasn't suffered this doesn't actually have any data declarations in it. Sure, if you're using data as a Boolean/Ternian replacement you won't have a trouble. But any multi record data constructor should be it's own type. I was going to go try and find an example from GHC, but you said that you think this problem is domain specific, and it's true that all of my work has had to do with code parsing/generation. So I went to look in darcs... Even with the shallow types of darcs we can still find examples of this problem: http://hackage.haskell.org/packages/archive/darcs/2.8.1/doc/html/src/Darcs-Match.html take a look at the function nonrangeMatcher, specifically OneTag, OneMatch, SeveralPatch... You can inspect the data declaration for DarcsFlag here http://hackage.haskell.org/packages/archive/darcs/2.8.1/doc/html/src/Darcs-Flags.html ... Now ask yourself, what are the types for tagmatch and mymatch. They take Strings as arguments. Obviously they are typed incorrectly. tagmatch SHOULD have the type :: OneTag - Matcher p. and mymatch SHOULD have the type PatchU - Matcher p where data PatchU = OnePatchU OnePatch | SeveralPatchU SeveralPatch... But we can't just easily go and change the types. Because unfortunately GADT data declarations are not used here. You've probably come across this many times. You just never realized it, because it's a case of GHC letting you do something you shouldn't be doing, rather than GHC stopping you from doing something you wish to. Timothy -- Původní zpráva -- Od: Chris Smith cdsm...@gmail.com Datum: 2. 9. 2012 Předmět: Re: [Haskell-cafe] Over general types are too easy to make. On Sun, Sep 2, 2012 at 9:40 AM, timothyho...@seznam.cz wrote: The thing is, that one ALWAYS wants to create a union of types, and not merely an ad-hock list of data declarations. So why does it take more code to do the right thing(tm) than to do the wrong thing(r)? You've said this a few times, that you run into this constantly, or even that everyone runs into this. But I don't think that's the case. It's something that happens sometimes, yes, but if you're running into this issue for every data type that you declare, that is certainly NOT just normal in Haskell programming. So in that sense, many of the answers you've gotten - to use a GADT, in particular - might be great advice in the small subset of cases where average Haskell programmers want more complex constraints on types; but it's certainly not a good idea to do to every data type in your application. I don't have the answer for you about why this always happens to you, but it's clear that there's something there - perhaps a stylistic issue, or a domain-specific pattern, or something... - that's causing you to face this a lot more frequently than others do. If I had to take a guess, I'd say that you're breaking things down into fairly complex monolithic parts, where a lot of Haskell programmers will have a tendency to work with simpler types and break things down into smaller pieces. But... who knows... I haven't seen the many cases where this has happened to you. -- Chris ___ Haskell-Cafe mailing
[Haskell-cafe] From monads to monoids in a small category
Monads are monoids in the category of endofunctors This Monoid instance for the endofunctors of the set of all elements of (m a) typematch in Haskell with FlexibleInstances: instance Monad m = Monoid (a - m a) where mappend = (=) -- kleisly operator mempty = return The article can be found here: http://haskell-web.blogspot.com.es/2012/07/from-monads-to-monoids-in-small.html I would appreciate some comments. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] tplot (out of memory)
Hi Manish, Please provide the input file, I'll debug this. On Mon, Sep 3, 2012 at 1:06 PM, Manish Trivedi trivman...@gmail.com wrote: Hi, I am running into a weird out of memory issue. While running timeplot over an input file having ~800 rows. From below provided info, seems like machine has enough ram (1849MB). Please let me know if anyone has pointers. # free -m total used free sharedbuffers cached Mem: 3825 1975 1849 0 13 71 -/+ buffers/cache: 1891 1934 Swap: 4031111 3920 #time tplot -o out.png -or 1024x768 -k 'CurrentPerHour' 'lines' -k 'RequiredPerHour' 'lines' -if adgroup_delivery_chart.input -tf 'date %Y-%m-%d %H:%M:%OS' tplot: user error (out of memory) real0m0.026s user0m0.018s sys0m0.008s -Manish ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Eugene Kirpichov http://www.linkedin.com/in/eugenekirpichov ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] From monads to monoids in a small category
Your post feels similar to another one posted recently... http://web.jaguarpaw.co.uk/~tom/blog/2012/09/02/what-is-a-monad-really.html just fyi, :-), kris On Tue, Sep 4, 2012 at 6:39 AM, Alberto G. Corona agocor...@gmail.com wrote: Monads are monoids in the category of endofunctors This Monoid instance for the endofunctors of the set of all elements of (m a) typematch in Haskell with FlexibleInstances: instance Monad m = Monoid (a - m a) where mappend = (=) -- kleisly operator mempty = return The article can be found here: http://haskell-web.blogspot.com.es/2012/07/from-monads-to-monoids-in-small.html I would appreciate some comments. ___ 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] From monads to monoids in a small category
Not to mention the ugly formatting ;) 2012/9/5 Richard O'Keefe o...@cs.otago.ac.nz: On 4/09/2012, at 10:39 PM, Alberto G. Corona wrote: Monads are monoids in the category of endofunctors This Monoid instance for the endofunctors of the set of all elements of (m a) typematch in Haskell with FlexibleInstances: instance Monad m = Monoid (a - m a) where mappend = (=) -- kleisly operator mempty = return The article can be found here: http://haskell-web.blogspot.com.es/2012/07/from-monads-to-monoids-in-small.html I would appreciate some comments. s/kleisly/Kleisli/ In the article, s/Lets/Let's/ /Here 'm b' as/ s/as/is/ s/this_are/this are/ s/first, is/first is/ s/haskell/Haskell/ s/polimorphic/polymorphic/ s/x=/x =/ s/let's/Let's/ s/condition, associativity/condition, associativity,/ /if not where that way, .* guess/ I *think* you mean to say something like (If it were not so, it would be impossible to define the denotational semantics of imperative languages in terms of monads, I guess.) Generally, it's according TO, not according WITH, and associated WITH, not associated TO. instance Functor a doesn't seem to be legal Haskell. At this point I stopped reading. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] From monads to monoids in a small category
On Tue, Sep 4, 2012 at 3:39 AM, Alberto G. Corona agocor...@gmail.comwrote: Monads are monoids in the category of endofunctors This Monoid instance for the endofunctors of the set of all elements of (m a) typematch in Haskell with FlexibleInstances: instance Monad m = Monoid (a - m a) where mappend = (=) -- kleisly operator mempty = return The objects of a Kliesli category for a monad m aren't endofunctors. You want something like: instance Monad m = Monoid (m a - m (m a)) where ... /These/ are endofunctors, in virtue of join transforming an m (m a) into an (m a). ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] From monads to monoids in a small category
On Tue, Sep 4, 2012 at 4:21 PM, Alexander Solla alex.so...@gmail.comwrote: On Tue, Sep 4, 2012 at 3:39 AM, Alberto G. Corona agocor...@gmail.comwrote: Monads are monoids in the category of endofunctors This Monoid instance for the endofunctors of the set of all elements of (m a) typematch in Haskell with FlexibleInstances: instance Monad m = Monoid (a - m a) where mappend = (=) -- kleisly operator mempty = return The objects of a Kliesli category for a monad m aren't endofunctors. You want something like: instance Monad m = Monoid (m a - m (m a)) where ... /These/ are endofunctors, in virtue of join transforming an m (m a) into an (m a). Actually, even these aren't endofunctors, for a similar reason that : you really want something like instance Monad m = Monoid (m a - m a) where mempty = id mappend = undefined -- exercise left to the reader (i.e., you want to do plumbing through the Eilenberg-Moore category for a monad, instead of the Kliesli category for a monad -- my last message exposes the kind of plumping you want, but not the right types.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Over general types are too easy to make.
On Tue, Sep 4, 2012 at 5:14 AM, Andreas Abel andreas.a...@ifi.lmu.de wrote: I agree with Timothy. In the Agda code base, we have many occurrences of Timothy's pattern aux (OneSpecificConstructor args) = ... aux _ = __IMPOSSIBLE__ where __IMPOSSIBLE__ generates code to throw an internal error. +1 I've run into this situation quite a few times. I'm guessing it's especially irritating to fans of -Wall, in particular coupled with -Werror, the former of which includes exhaustiveness checking for patterns. Even without changing the type system it might still be useful, for example, to prevent such warnings for those cases when the missing patterns can be statically determined never to be used -- e.g. for functions known not to escape the module's scope. (Incidentally, exhaustiveness checking in lambdas doesn't seem to be enabled as of GHC version 7.2.2.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] SYB with class: Bug in Derive.hs module
I've pushed the discussed changes to the repo[1], it'd be good if you (and other users) could test them before they get to hackage. [1] darcs get http://patch-tag.com/r/Saizan/syb-with-class/ -- Andrea ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] How to waitForProcess?
Hi, I have code like this and it leaves lots of zombies of flow-export. Then I add waitForProcess Well I do not know where to put it. Before or after 'hGetContents' both make the program hung. exportCSV :: FilePath - IO [String] exportCSV file = do csv_ - withBinaryFile file ReadMode $ \i - do (_, Just o, _, h) - createProcess $ CreateProcess (RawCommand /usr/bin/flow-export [-f2]) Nothing Nothing (UseHandle i) CreatePipe Inherit True False hGetContents o return $ tail $ lines csv_ -- 竹密岂妨流水过 山高哪阻野云飞 And for G+, please use magiclouds#gmail.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to waitForProcess?
On 5 September 2012 13:45, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Hi, I have code like this and it leaves lots of zombies of flow-export. Then I add waitForProcess Well I do not know where to put it. Before or after 'hGetContents' both make the program hung. You're probably being bitten by hGetContents being lazy. Force the result of hGetContents (e.g. `evaluate . length = hGetContents o ') and then use waitForProcess. exportCSV :: FilePath - IO [String] exportCSV file = do csv_ - withBinaryFile file ReadMode $ \i - do (_, Just o, _, h) - createProcess $ CreateProcess (RawCommand /usr/bin/flow-export [-f2]) Nothing Nothing (UseHandle i) CreatePipe Inherit True False hGetContents o return $ tail $ lines csv_ -- 竹密岂妨流水过 山高哪阻野云飞 And for G+, please use magiclouds#gmail.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com http://IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to waitForProcess?
You might have to use hGetContents, then waitForProcess, and then terminateProcess -- you can then check if the process is indeed terminated using getProcessExitCode. On Wed, Sep 5, 2012 at 1:45 PM, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Hi, I have code like this and it leaves lots of zombies of flow-export. Then I add waitForProcess Well I do not know where to put it. Before or after 'hGetContents' both make the program hung. exportCSV :: FilePath - IO [String] exportCSV file = do csv_ - withBinaryFile file ReadMode $ \i - do (_, Just o, _, h) - createProcess $ CreateProcess (RawCommand /usr/bin/flow-export [-f2]) Nothing Nothing (UseHandle i) CreatePipe Inherit True False hGetContents o return $ tail $ lines csv_ -- 竹密岂妨流水过 山高哪阻野云飞 And for G+, please use magiclouds#gmail.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to waitForProcess?
Forgot about that, just read 'readProcess' code to figure out. Thanks. On Wed, Sep 5, 2012 at 12:37 PM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: On 5 September 2012 13:45, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Hi, I have code like this and it leaves lots of zombies of flow-export. Then I add waitForProcess Well I do not know where to put it. Before or after 'hGetContents' both make the program hung. You're probably being bitten by hGetContents being lazy. Force the result of hGetContents (e.g. `evaluate . length = hGetContents o ') and then use waitForProcess. exportCSV :: FilePath - IO [String] exportCSV file = do csv_ - withBinaryFile file ReadMode $ \i - do (_, Just o, _, h) - createProcess $ CreateProcess (RawCommand /usr/bin/flow-export [-f2]) Nothing Nothing (UseHandle i) CreatePipe Inherit True False hGetContents o return $ tail $ lines csv_ -- 竹密岂妨流水过 山高哪阻野云飞 And for G+, please use magiclouds#gmail.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com http://IvanMiljenovic.wordpress.com -- 竹密岂妨流水过 山高哪阻野云飞 And for G+, please use magiclouds#gmail.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to waitForProcess?
On Tue, Sep 4, 2012 at 9:39 PM, Mike Ledger eleventyn...@gmail.com wrote: You might have to use hGetContents, then waitForProcess, and then terminateProcess -- you can then check if the process is indeed terminated using getProcessExitCode. Er? When waitForProcess returns the process is dead; there's nothing to terminateProcess. If you do it the other way around then you may not get full output. For starters, I would not build up the CreateProcess record directly but use the proc record and override it with your I/O definitions. I've been bit by this before (I think some older version of System.Process lacked useful predefined records?). There is a severe gotcha here if you do things naively (like your example code does). If there is more output than will fit in a pipe, *no* ordering of read / wait in a single thread will work without deadlocking; you have no choice but to do the read in a separate thread. This is not a Haskell issue, it is how pipes work on POSIX systems. (I don't know if Windows has the same problem.) -- brandon s allbery allber...@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe