03:18:05 <sm> stepcut: hmm, when I replace hack-handler-happstack with hack-handler-hyena it no longer stack overflows
03:18:17 <stepcut> :)
03:18:28 <stepcut> something must be wrong in hack-handler-happstack ?
03:21:04 <sm> ..but hyena has other problems, by the looks of it
03:21:35 <sm> next thing is to try with happstack and no hack. I'm afraid this will be a time sink
03:22:28 <sm> would you know a good idiomatic happstack app to look at these days ?
03:22:48 <stepcut> um
03:23:08 <stepcut> not really.. I am working on an idiomatic app -- but it requires patches that are not available yet
03:23:48 <sm> alright.. I'll start with the tutorial
03:24:05 <stepcut> there is the thing in happstack/happstack/templates/project
03:24:43 <sm> um, can I assume happs-tutorial works with happstack 0.4.1 ? it won't cabal install
03:25:12 <sm> ok, thx
03:25:32 <stepcut> I know nothing of happs-tutorial
03:25:39 <stepcut> well, except that it exists
03:26:49 <sm> I wonder why I can't browse the templates dir at http://patch-tag.com/r/mae/happstack/snapshot/current/content/pretty/happstack
03:27:28 <stepcut> dunno.. that is odd
03:29:38 <stepcut> http://groups.google.com/group/patch-tag-users/browse_thread/thread/d1d81575abd93816
03:33:09 <sm> yes, this is a hassle.. I'll have to make my hsps work with happstack as well. I'd be much better off waiting for your example
03:33:21 <sm> maybe I can roll back to my pre-hsp pre-hack code
03:34:09 <stepcut> I just committed a patch to happstack that makes using HSP stuff with happstack better
03:34:20 <stepcut> though it does it by getting rid of the need to use the HSP monad at all
03:34:46 <sm> thanks
03:34:53 <sm> is that.. bad ?
03:35:01 <sm> sounds like a good thing :)
03:35:32 <stepcut> it is a good thing
04:04:56 <sm> night stepcut, all
04:05:02 <stepcut> night
15:08:05 <rdtsc> how do you deal with request input parameters?
15:10:20 <mightybyte> Try withData or withDataFn
15:12:25 <rdtsc> I tried
15:13:05 <mightybyte> Didn't work?
15:13:09 <rdtsc> there is too many code for parameters processing in this way
15:14:38 <rdtsc> unfortunately hpaste is down =(
15:16:13 <mightybyte> What part of the request do you want?
15:17:52 <rdtsc> rqInputs
15:18:32 <mightybyte> Try lookInput
15:18:50 <mightybyte> ...or one of the other lookXYZ functions.
15:20:38 <rdtsc> I get a Maybe value, and i have to unwrap it
15:21:34 <mightybyte> What's wrong with that?
15:22:16 <rdtsc> maybe it's better to wrap result in Error monad?
15:23:06 <mightybyte> Depends on what you are doing.
15:23:21 <rdtsc> if i use Error monad in all my handlers it is very convenient to get inputs
15:23:22 <mightybyte> Getting a Maybe value is a good thing.  It forces you to handle errors.
15:24:29 <mightybyte> It essentially eliminates a large class of bugs you'd get in languages like C/C++/Java  --  the class of null pointer bugs.
15:25:34 <rdtsc> how does it this?
15:26:46 <mightybyte> It forces you to handle both cases (Just and Nothing).
15:27:51 <rdtsc> but this functions can handle all cases themselves
15:28:02 <mightybyte> Which functions?
15:28:04 <rdtsc> i mean functions such as look
15:28:52 <mightybyte> But the look* family of functions must be used in conjuction with something like the withData* or getData* functions.
15:30:38 <mightybyte> withDataFn is just a wrapper around getDataFn that handles errors with mzero.
15:31:50 <rdtsc> http://paste.org/pastebin/view/15326
15:32:25 <rdtsc> such aproach is more convenient for me
15:32:45 <rdtsc> i think it can be written without 'getDataFn'
15:34:31 <mightybyte> You've got a lot of repetition there.
15:36:19 <rdtsc> strictly, I have
15:38:08 <rdtsc> but my handlers code looks like 'getInputStringRead "id" >>= \id -> getInputString "objectname" >>= renameObject id'
15:38:24 <rdtsc> *getInputRead of course
15:43:57 <rdtsc> mightybyte: what repetitions beside not calling getInputString in getInputRead?
15:48:18 <rdtsc> i did some fixes
15:48:37 <rdtsc> http://paste.org/pastebin/view/15327
15:53:54 <mightybyte> You can use the maybe function instead of case statements on Maybe values.
15:55:31 <rdtsc> I don't see how it can be done
15:56:03 <mightybyte> The case statement in getInputString can be replaced with the following:
15:56:30 <mightybyte> maybe (throwError $ "Parameter " ++ input ++ " not found") return resM
15:59:15 <rdtsc> i got it
16:00:19 <mightybyte> The Monad instance for Maybe also makes it very convenient to chain operations on Maybe values.
16:02:21 <rdtsc> mightybyte: please, show how to combine getting inputs in my example through maybe monad?
16:02:33 <rdtsc> getInputStringRead "id" >>= \id -> getInputString "objectname" >>= renameObject id
16:03:28 <mightybyte> rdtsc: Well, it depends on your needs.
16:04:04 <mightybyte> Maybe allows you to handle failures without repeating cases over and over.
16:04:26 <rdtsc> mightybyte: i need to get integer id and name of object and rename it through renameObject function
16:04:27 <mightybyte> But the result doesn't give you any indication why the failure happened.
16:04:50 <mightybyte> If you need that, then an error monad of some kind is probably better.
16:05:21 <rdtsc> it is more important to get automagic processing of all failures rather than printing pretty error messages
16:06:23 <mightybyte> Chapter 19 of Real World Haskell talks about this in more detail.
16:06:26 <mightybyte> http://book.realworldhaskell.org/read/error-handling.html
16:08:53 <rdtsc> i'll read
16:09:25 <rdtsc> thanks for advices
16:09:40 <mightybyte> No problem.
18:43:56 <sm> morning all
18:44:10 <sm> do you know of a non-happstack way of doing what waitForTermination does ?
18:44:35 <sm> I'd like to not depend on happstack for that
18:45:22 <sm> or, is that something that should be added to System.Process ?
18:46:08 <mightybyte> I don't see why not.
18:46:15 <sm> I'll suggest it
18:46:15 <rdtsc> sm: look at it sources
18:46:23 <sm> just did, and it looks a bit hairy
18:48:59 <rdtsc> version for windows looks terrible
18:51:06 <sm> bah, mail to the process maintainer email rejected
18:54:38 <sm> but posting via gmane works
18:59:47 <sm> rdtsc: no idea what's going on there..
19:01:05 <sm> well, something primitive. O well, perhaps my request will stir up a patch, or an alternate technique
19:03:03 <rdtsc> sm: i'm recent visitor here
19:03:18 <sm> welcome
19:11:35 <McManiaC> sm: I'd use MVars for it
19:11:52 <McManiaC> or … hmm
19:11:53 <McManiaC> ^^
19:11:56 <McManiaC> yeh
19:12:04 <McManiaC> MVars with Control.Exception
19:12:45 <sm> http://hpaste.org/fastcgi/hpaste.fcgi/view?id=18963 does look clunky
19:13:14 <sm> I think there's a bracket function which could also help
19:14:31 <sm> hmm.. I just have not really mastered process control, error management, and the combination of these
19:14:47 <McManiaC> http://npaste.de/G2/
19:14:49 <McManiaC> like this
19:14:58 <McManiaC> no idea if IOException is what you want…
19:14:59 <McManiaC> ^^
19:15:24 <sm> interesting, thanks for the example
19:18:32 <McManiaC> no idea if thats how waitForTermination works… been a while since I took a look at the code
19:18:35 <McManiaC> :)
19:19:00 <sm> actually it seems to be.. http://hackage.haskell.org/packages/archive/happstack-state/0.4.1/doc/html/src/Happstack-State-Control.html#waitForTermination
19:19:36 <sm> same principle, anyhow
19:19:48 <McManiaC> yeh
19:19:49 <McManiaC> :)