14:17:57 <CalmNelly> ACTION yawns and stretches
15:13:01 <CalmNelly> i have a question
15:13:43 <CalmNelly> I have my request handler setup up like so:
15:13:45 <CalmNelly> propcheck :: ServerPart Response
15:13:45 <CalmNelly> propcheck =
15:13:45 <CalmNelly>     msum [ dir "feedback" $ feedback
15:13:45 <CalmNelly>          , dir "static" $ fileServe [] "."
15:13:45 <CalmNelly>          , propForm
15:13:46 <CalmNelly>          ]
15:14:05 <CalmNelly> Now I consider propForm the mainpage
15:14:56 <CalmNelly> whenever I type in an address that doesn't get matched I get propForm, which I understand don't mind
15:15:17 <CalmNelly> BUT, I'd to have the address changed
15:16:03 <CalmNelly> to the correct address, instead of loading propForm with an incorrect address.
15:16:48 <CalmNelly> So i don't have people copying and pasting: http://propcheck.com/propchecksucks/
15:16:59 <CalmNelly> and it still works
15:20:45 <McManiaC> CalmNelly: you could change your last entry to something like seeOther "/"
15:22:13 <stepcut> McManiaC: that won't work by itself, because propForm would match before seeOther did
15:22:43 <stepcut> CalmNelly: you need to do, nullDir >> propForm, so that propForm will only match on /
15:22:56 <McManiaC> stepcut: yup, of course :)
15:23:00 <stepcut> CalmNelly: then you can add as the last line, seeOther "/" (toResponse "/")
15:23:13 <stepcut> so that any non-matched URLs will be redirected to /
15:23:33 <stepcut> specifically, it will send a Response which will tell the browser to do a redirect to the new page
15:24:47 <CalmNelly> k let me see
15:36:02 <CalmNelly> I dont know how to form this
15:36:17 <CalmNelly> nullDir >> propForm is on it's own separate line?
15:36:40 <CalmNelly> before seeOther "/" ...
15:52:10 <CalmNelly> propcheck =
15:52:10 <CalmNelly>     msum [ dir "feedback" $ feedback
15:52:10 <CalmNelly>          , dir "static" $ fileServe [] "."
15:52:10 <CalmNelly>          , nullDir >> propForm
15:52:10 <CalmNelly>          , seeOther "/" (toResponse "/")
15:52:11 <CalmNelly>          ]
15:52:42 <CalmNelly> this doesn't work
15:59:04 <stepcut> it should.. in what way does it not work ?
16:06:55 <CalmNelly> it won't compile
16:07:08 <stepcut> what error ?
16:07:44 <CalmNelly> having a problem with seeOther and toResponse
16:07:56 <CalmNelly> ambiguous type variable
16:08:20 <stepcut> are you using OverloadedStrings?
16:08:38 <CalmNelly> yes
16:08:52 <stepcut> try, seeOther "/" (toResponse ("/" :: String))
16:08:53 <stepcut> I guess
16:10:17 <CalmNelly> http://pastebin.com/50RGPztD
16:11:14 <CalmNelly> these are my imports
16:11:15 <CalmNelly> http://pastebin.com/Uqydgrda
16:11:31 <CalmNelly> err...mine/yours
16:20:04 <CalmNelly> here's the original error, because adding the :: String
16:20:06 <CalmNelly> http://pastebin.com/xnXBj9dV
16:20:48 <stepcut> I guess you need to make them both ("/" :: String)
16:20:55 <stepcut> or stop using OverloadedStrings
16:23:32 <CalmNelly> I'm just using OverloadedStrings cause you used in your example, thought it wouldn't hurt
16:24:31 <stepcut> it is useful with BlazeHtml, but it is also troublesome because it means that a string literal like "/" has many possible types, not just String
16:25:03 <stepcut> and it happens that seeOther and toResponse can also take multiple types.. so the compile doesn't really know what to pick
16:25:16 <stepcut> so you have to either tell it explicitly, or you have to not use OverloadedStrings
16:25:35 <stepcut> perhaps I will modify the example to not use OverloadedStrings, as it seems to be troublesmoe..
16:26:37 <CalmNelly> ahhh, we'll it would only be used in the parsing list, so I wouldn't think it would be a big problem if I'm using blaze
16:27:24 <CalmNelly> at least for my purposes, my site is not as complex, so i don't mind the ugliness
16:27:47 <CalmNelly> now I'm getting this
16:27:50 <CalmNelly> GetProp.lhs:43:47: parse error on input `"'
16:28:20 <stepcut> what is line 43 ?
16:28:54 <CalmNelly>          , seeOther ("/" :: String) (toResponse "/" :: String)
16:29:26 <CalmNelly> i just added the brackets to see if it made a diff just now
16:30:15 <CalmNelly> the brackets made it worse
16:30:20 <stepcut> heh
16:31:28 <stepcut> did you get, seeOther ("/" :: String) (toResponse "/" :: String)
16:31:29 <stepcut> oops
16:31:34 <stepcut> stupid copy and paste buffers
16:31:41 <CalmNelly> :P
16:31:58 <stepcut> did you get an error about, 'Couldn't match expecting type String against inferred type Response' ?
16:32:28 <CalmNelly> when I did the brackets, yes
16:32:54 <CalmNelly> without then, just the parse error
16:33:03 <stepcut> right, because you really want, (toResponse ("/" :: String)), otherwise it will be parsed as ((toResponse "/") :: String)
16:33:25 <stepcut> I wonder if it would be better to not user OverloadedStrings
16:33:44 <stepcut> the trade off is that you would have to use the 'string' function more in your blaze-html templates
16:34:10 <stepcut> or, you could put the templates in one file that uses OverloadedStrings, and the dir, seeOther, toResponse stuff in a different module
16:34:56 <CalmNelly> the last one seems better
16:35:25 <CalmNelly> but with the former, where would i have to be using the 'string' function?
16:36:12 <stepcut> looking at this example,
16:36:13 <stepcut> http://happstack.com/docs/crashcourse/Templates.html#helloblaze
16:36:28 <stepcut> pretty much everywhere a string literal appears in helloBlaze and appTemplate I think
16:36:48 <stepcut> for example, instead of H.p "hello, blaze!", you would need, H.p (string "hello, blaze!")
16:37:53 <CalmNelly> ...that sounds awful.
16:38:42 <CalmNelly> well, I guess I'll put it in a different module once it gets bigger
16:38:56 <CalmNelly> for now, putting the strings with the types is fine
16:39:06 <CalmNelly> it works good now
16:39:14 <CalmNelly> thanks
16:39:36 <stepcut> well having to put, :: String, everywhere is awful too :)
16:40:22 <CalmNelly> yeah, that's why once it gets more complex, i'll move it into a separate module
16:40:59 <stepcut> yeah
16:41:26 <CalmNelly> I like being lazy, because i can always justify it by saying i'm just following the principles of haskell
16:42:59 <CalmNelly> Next, I'm going to try and figure out how to prevent someone for going directly to a page that is generated from a form
16:43:15 <CalmNelly> err, using input from a form
16:44:01 <CalmNelly> i'll try on my own, but i'm sure i'll need help
16:45:35 <Gracenotes> could also define a seeOther with less typeclasses
16:47:43 <stepcut> Gracenotes: yeah, I usually do something like, seeOtherBlaze :: String -> m Response ; seeOtherBlaze uri = seeOther uri (H.a (string uri))
16:48:12 <Gracenotes> not sure why you'd have the entity body include the uri
16:50:34 <stepcut> Gracenotes: that's what the spec says..
16:51:18 <stepcut> http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.4
16:51:22 <Gracenotes> stepcut: eh? I thought it was just the Location header that mattered
16:51:43 <stepcut> Gracenotes: pretty much
16:51:54 <Gracenotes> well I see a SHOULD at least
16:51:55 <stepcut> Gracenotes: it's really only there for pre http 1.1 clients
17:09:29 <Gracenotes> hm. my top-level component has 14 subcomponents at this point
17:09:52 <Gracenotes> not sure if that's low or high
17:14:09 <stepcut> nice
18:18:06 <CalmNelly> Okay, so I can't figure this out...I have '/feedback' which is a page that relies on form input, so when I go directly to that page, I get an error which is expected.
18:18:41 <stepcut> ok
18:19:02 <CalmNelly> I'm wondering is there is a type of guard that I could place in the handler, to distinguish if data has been posted
18:19:04 <CalmNelly> or
18:19:24 <CalmNelly> If I do something separately with the error that is generated
18:19:55 <stepcut> there are a few options
18:20:40 <CalmNelly> :D
18:20:56 <stepcut> you could add, methodM POST, to /feedback. Then that server part would only match if someone did a POST request (aka, submitted the form). If they just type the URL in the bar, then that part would match, and it would fall through
18:21:28 <stepcut> http://happstack.com/docs/crashcourse/RouteFilters.html#method
18:22:49 <stepcut> additionally, inside the, dir "feedback" guard you could have two parts (by adding them inside another msum). One would be the normal feedback part. If the feedback part fails, then the second part could be an error message that is specific to /feedback
18:23:44 <stepcut> the crash course probably needs an example showing how you can easily nest msums inside msums
18:25:35 <CalmNelly> okay, let me try those options
18:28:00 <stepcut> upgrading safari, brb
19:08:34 <CalmNelly> oh man, that msum is great
19:09:35 <stepcut> :)
19:39:54 <CalmNelly> is it bad to rely on Happstack's error message for incorrect paths?
19:40:23 <CalmNelly> and is there a way to change it?
19:45:42 <CalmNelly> i want the functionality that this provides:
19:45:43 <CalmNelly> nullDir >> propForm
19:45:51 <CalmNelly> but I want my own error message
19:49:06 <stepcut> well, you can always make the very last handle in msum be:

19:49:19 <stepcut> , notFound (toResponse "My awesome 404 page")
19:49:40 <CalmNelly> lol @"My awesome 404 page"
20:01:23 <CalmNelly> notFound (toResponse ("notExist" :: String))
20:01:34 <CalmNelly> this keeps displaying my home page
20:03:34 <stepcut> ?
20:04:14 <CalmNelly> notExist :: ServerPart Response
20:04:43 <CalmNelly> i tried : notFound (toResponse notExist)
20:04:54 <CalmNelly> but that doesn't work
20:05:30 <stepcut> yes that would be a type error
20:05:38 <CalmNelly> that's what it told me
20:05:48 <CalmNelly> :s
20:06:37 <CalmNelly> when we put toResponse ("notExist" :: String) , are we specifying the name of the page?
20:06:44 <stepcut> no
20:06:58 <stepcut> notExist is the content of the page
20:07:13 <stepcut> toResponse turns values into http responses
20:07:26 <stepcut> in this case, it would be a text/plain document that says, "notExist"
20:07:42 <stepcut> notFound sets the http response code to 404
20:08:55 <stepcut> you probably want a Response that is a fancy text/html page.. which you can do using blaze-html..
20:09:13 <stepcut> notFound (toResponse (someFancyBlazeHtml))
20:10:20 <CalmNelly> oh, yes i do, i tried that but its still type error
20:11:09 <stepcut> well, if you try to apply, notFound (toResponse notExist), that would be a type error
20:11:28 <stepcut> I would just but the, notFound in the notExist function..
20:15:05 <CalmNelly> I'm not sure what you meant in your last statement.  I put the brackets around like you, but that doesn't do anything
20:17:40 <CalmNelly> ohhh, wait a sec
20:21:13 <CalmNelly> i still can't get it to work
20:22:27 <stepcut> :(
20:23:34 <CalmNelly> *sigh*
20:24:11 <stepcut> in notExist, you are doing something to create  'Response' and something that makes it be in a ServerPart
20:24:43 <stepcut> but I don't know what..
20:25:50 <stepcut> there are really only two functions here, toResponse :: (ToMessage a) => a -> Response, and, notFound :: a -> ServerPart a
20:26:35 <stepcut> if you put them together, notFound . toResponse, a -> ServerPart Response
20:27:02 <stepcut> so, when we did, notFound (toResponse "not found"), it turned a String into a ServerPart Response
20:27:33 <stepcut> but, applying, notFound (toResponse notExist), does not make sense, because notExist already has the type, ServerPart Response
20:28:08 <CalmNelly> yes, that makes sense, let me do a little more detective work
20:28:23 <stepcut> if notExist already contains the correct messaging, but doesn't set the response code to 404, then you could do, notFound =<< notExists
20:28:46 <stepcut> but that would be a bit silly, because when are you going to use notExists with any response code aside from, notFound.. so it would be better to put notFound inside notExists
20:29:11 <stepcut> but I am not sure what notExists looks like, so I can not tell you exactly how that is done..
20:29:22 <CalmNelly> oh okay
20:29:23 <CalmNelly> notExist :: ServerPart Response
20:29:23 <CalmNelly> notExist = ok $ toResponse $
20:29:23 <CalmNelly>     html $ do
20:29:23 <CalmNelly>       B.head $ do
20:29:24 <CalmNelly>         title "Error Page"
20:29:35 <CalmNelly> i have to change my ok
20:29:39 <CalmNelly> 'ok'
20:29:41 <stepcut> yeah, change ok (aka 202 OK) to notFound (404 Not Found)
20:30:22 <CalmNelly> i did that before, but i guess i screwed up something in the handler
20:37:59 <CalmNelly> I'm trying to reason about this:
20:38:00 <CalmNelly> msum [ dir "feedback" $ msum [ methodM POST >> feedback
20:38:00 <CalmNelly>                                  , errorPage
20:38:00 <CalmNelly>                                  ]
20:38:00 <CalmNelly>          , dir "static" $ fileServe [] "."
20:38:00 <CalmNelly>          , propForm
20:38:01 <CalmNelly>          , notExist
20:38:03 <CalmNelly>          ]
20:38:25 <CalmNelly> this says propForm will always work
20:38:33 <CalmNelly> so notExist doesn't get a chance
20:40:02 <CalmNelly> so now I'm not sure how to say "check if directory doesn't exist then go to home page"
20:41:20 <CalmNelly> ahh, fu.....
20:42:20 <CalmNelly> nevermind, got it
20:42:33 <CalmNelly> i forgot to put the nullDir >> back in
20:47:20 <CalmNelly> Okay, i believe i finally understand...a bit more.  Thanks stepcut, your VERY helpful
20:49:53 <stepcut> s/your/you're/
20:49:53 <stepcut> ;)
20:53:42 <CoolNelly> stepcut: i was testing you, and you passed
20:53:50 <stepcut> :)
20:53:58 <CoolNelly> I'm also f***en tired
20:54:05 <stepcut> :p
20:54:34 <CoolNelly> alright peace out, for now :D
21:39:59 <McManiaC> cool nelly is calm nelly
21:40:00 <McManiaC> :>