02:18:55 <HugoDaniel> sleeeeep
09:44:48 <balor> Is FromData deprecated in happstack-6.* with acid-state?
10:30:34 <Lemmih> If it is from happstack-data then it probably is.
10:33:33 <balor> Do you have any idea what replaced it?
10:34:10 <balor> Lemmih, and did you get my example last night?
10:45:52 <Lemmih> balor: Yes. I'll look into including it.
10:46:29 <Lemmih> balor: Btw, version numbers only have to be unique for the type and not globally.
10:50:36 <balor> Lemmih, ah. Great thanks.
10:54:16 <balor> if I'm handling /foo/1, where '1' is the first foo (i.e. it's RESTful).  How do I get the '1'?
12:21:44 <balor> Why does the following not work for getting a parameter from the URL? http://hpaste.org/48405
12:33:14 <balor> Gah...FromReqUri has been deprecated too
12:40:51 <balor> no
12:40:59 <balor> apparently I can't spell
13:59:56 <balor> Could someone have a look at https://patch-tag.com/r/balor/Folder/snapshot/current/content/pretty/src/Pages/FoldrDocument.hs for me.  It 404s on access to /0 (where 0 is an id) for no reason that I can see.
14:00:29 <balor> It just looks like the path conversion in getDocument *always* fails
14:19:00 <Lemmih> Look ok.
14:21:08 <Lemmih> balor: 'fromReqURI "0" :: Maybe DocId' works?
14:28:26 <balor> no
14:28:46 <balor> instance FromReqURI DocId where
14:28:46 <balor>     fromReqURI "0" = Just (DocId 0)
14:28:47 <balor> fails
14:30:58 <balor> even " fromReqURI _ = Just (DocId 0)" fails
14:31:21 <balor> It just looks like the call to path never calls the getDocumentById function
14:40:28 <HugoDaniel> http://hpaste.org/48416
14:40:38 <HugoDaniel> here is my base code for quick&dirty happstack hacks
14:41:30 <HugoDaniel> quite a mess
14:43:17 <stepkut> balor: use methodOnly instead of methodM
14:43:38 <stepkut> methodM also checks that there are no more unconsumed path segments
14:44:27 <stepkut> (which is a bit confusing, IMO)
14:46:35 <Lemmih> Yeah, someone should tell the maintainer of happstack to fix it.
14:47:32 <stepkut> fix methodM to remove the nullDir check?
14:47:53 <Lemmih> Yep.
14:48:58 <stepkut> yeah. The problem is, changing that behavior does not change the type signature. And no one reads release notes. So apps that depend on that behavior will break and people won't know why..
14:49:41 <balor> thanks.
14:49:49 <stepkut> I think the type to change it would be if we switch to the more monadic style of guarsd like, dir "foo" ;  p <- path ; etc
14:49:49 <dsfox> remove the whole function
14:49:52 <balor> You've no idea how long I've been trying to track that down
14:50:01 <Lemmih> Include it with other changes that /do/ break peoples code. (:
14:50:05 <Lemmih> Or rename the function.
14:50:33 <Lemmih> methodHaHaYourCodeDoesntWorkNow.
14:51:21 <dsfox> I love deprecated messages that tell me what I need to do to fix it
14:51:49 <dsfox> Imagine if it even told you why the change was made!
14:52:08 <stepkut> there is an deprecated function called 'method'. We could make 'method' == methodOnly and deprecated methodM
14:54:06 <stepkut> another issue with the dir / path stuff is that it does not make it easy to parse partial path segments. For example, it would be nice if you could do something like, (i, c) <- int . "-" . char, to parse "/1-c"
15:01:15 <balor> On a major number change I'm generally happier with my code breaking than calling a function with the wrong semantics.
15:04:23 <stepkut> gotta run, bbl.
15:08:04 <balor> ACTION wishes Data.Set had a getOne method like Data.IxSet
20:12:47 <balor> $(makeAcidic ''Foo ['bar]) gives me a datastore called "foo" and a function called "Bar" right?  Then to run a query against the store it's "query store Bar".  Does that mean I have to pass the store around into all functions?
20:13:29 <balor> where "store  <- openAcidState (...)"
20:15:41 <stepkut> yes
20:15:59 <stepkut> makeAcidic does not really 'give you' a datastore called "foo"
20:16:12 <stepkut> or create anything named "foo" for that matter
20:16:22 <stepkut> but it does create a type Bar which can be used with update/query
20:16:41 <stepkut> and update/query now require an explicit reference to the data store
20:19:54 <balor> So create the store in Main, then how do I thread it through the URL handlers.  For example 'msum ["/feep" $ feepHandler]' is the handler for feeps.  Do I now have to have 'msum ["/feep" $ feepHandler store]'?
20:20:55 <stepkut> that is one possibility
20:21:09 <stepkut> you could also use the ReaderT monad
20:25:57 <balor> hmmmm....
20:28:39 <stepkut> ?
20:29:41 <balor> I was just hoping to not have to rewrite the guestbook Main.hs.
20:29:58 <stepkut> ah
20:30:04 <stepkut> progress is pain :)
20:30:16 <stepkut> can't have one without the other :p
20:32:35 <balor> It's a tradeoff.  Learning happstack is fun, but if it has to work by the morning then I need to be a bad gambler - double down on my losses.
20:33:32 <stepkut> adding a ReaderT is pretty straight-forward
20:36:39 <stepkut> http://hpaste.org/48435
20:37:12 <stepkut> if you want to be extra fancy, you can make a newtype and do newtype deriving
20:40:06 <balor> So then all my functions that return a "ServerPartT IO (HSP XML)" become "ServerPartT (ReaderT AcidState IO) (HSP XML)"?
20:40:33 <stepkut> yep
20:40:50 <stepkut> or you can create a type alias
20:41:07 <stepkut> type App = ServerPartT (ReaderT AcidState IO)
20:41:13 <stepkut> and do, App (HSP XML)
20:41:28 <stepkut> then if you change the type again later, you do not have to update the signature everywhere
20:53:43 <balor> Does "type App st = ServerPartT (ReaderT (AcidState st) IO)" look more correct?
20:55:24 <stepkut> depends if you plan to use App with multiple different versions of st in your application
20:55:32 <balor> no I don't
20:55:48 <balor> the st would then be the makeAcidic'ed type I'm using
20:55:54 <stepkut> then I would not bother to make the 'st' part abstract
20:56:12 <stepkut> but you are correct that you probably want (ReaderT (AcidState Foo) IO) or s omething
20:56:14 <stepkut> sorry about that
20:56:45 <balor> I'm getting there...someday I'll understand :)
20:56:54 <stepkut> not used to working without a type checker -- don't know how those python people do it :p
20:57:22 <stepkut> so, your type would work: type App st = ServerPartT (ReaderT (AcidState st) IO)
20:57:49 <stepkut> but it better to just make the 'st' part fixed i think, type App = ServerPartT (ReaderT (AcidState Foo) IO)
21:11:47 <balor> I get that.  I understand bits in the small.  I have difficulty taking the small examples and building anything non-trivial
21:12:36 <balor> For example, if you drop Happstack.State from Main.hs in the guestbook example, then you have to reimplement waitForTermination.  I don't really know where to start with that.
21:17:31 <stepkut> yeah, waitForTermination needs to go somewhere les
21:17:32 <stepkut> else
21:17:44 <stepkut> so far I have just copied and pasted into my apps -- which is not a great solution :)
21:18:00 <balor> and shutdownSystem
21:18:10 <stepkut> shutdownSystem is happstack-state specific
21:18:22 <stepkut> there is an acid-state equivalent
21:18:39 <stepkut> as a hack, you can use 'getLine' instead of waitForTermination
21:18:50 <balor> createCheckpointAndClose cool
21:19:02 <stepkut> yeah
21:28:24 <balor> Here's what I've got so far http://hpaste.org/48438.  I'm trying to get the AcidState from the ReaderT in order creatCheckpoint on it.
21:28:46 <balor> I don't think it's too far wrong, but I'm probably getting confused about which Monad I'm in
21:30:09 <stepkut> looks mostly right not me, the state <- ask line is not indented the same amout as the line after it though
21:30:12 <stepkut> that will cause problems
21:31:30 <balor> no, ask is not in scope.  I need to be in ReaderT somwhere
21:33:00 <stepkut> not in scope? Did you import it from Control.Monad.Reader ?
21:46:21 <balor> Maybe I'm asking the wrong question.  How do I mapServerT over my routes?  One attempt, with ghc compile error, is here http://hpaste.org/48440
21:54:10 <stepkut> well, routes has the wrong type signature
21:54:14 <stepkut> routes :: ServerPart Response
21:54:48 <stepkut> don't you need, routes :: ServerPartT (ReaderT (AcidState Foldr) IO) Response ?
21:55:45 <balor> ah
21:55:50 <balor> an App Response
21:55:55 <stepkut> right
21:56:23 <balor> and I need to propogate App all the way down the call tree
21:56:23 <stepkut> secondly, you have openAcidicState as an argument to runReaderT
21:56:29 <stepkut> but that is not right
21:56:45 <stepkut> that will have the type, IO (AcidState Foldr)
21:56:58 <stepkut> you just want, (AcidState Foldr)
21:57:18 <balor> so it goes in a do block
21:57:27 <stepkut> yeah
21:57:58 <stepkut> before the call to simpleHTTP you want, store <- openAcidState (Foldr empty)
21:58:04 <balor> yup
21:58:06 <stepkut> then you just do, runReaderT m store
21:58:25 <stepkut> otherwise you are storing a function that opens the acid state in the environment
22:09:49 <balor> Propagating App down into AppTemplate I'm getting "    The first argument of `EmbedAsChild' should have kind `* -> *',
22:09:49 <balor>     but `App IO' has kind `*'"
22:11:13 <balor> So replacing ServerPartT IO with ServerPartT (ReaderT (AcidState Foldr) IO) IO goes from kind *->* to kind *
22:11:48 <stepkut> hm
22:12:02 <stepkut> you have too many IOs there
22:12:38 <stepkut> you are replacing IO with (ReaderT (AcidState Foldr) IO)
22:12:49 <stepkut> so you should just have, ServerPartT (ReaderT (AcidState Foldr) IO)
22:12:53 <stepkut> no extra IO at the end
22:14:21 <balor> wow
22:14:53 <balor> it works
22:15:05 <balor> well...now to see if I can query state somewhere
22:17:42 <stepkut> sweet
22:17:59 <stepkut> you can make a query function that automatically gets the state for you
22:18:20 <stepkut> query_ e = do store <- ask ; query' store e
22:27:24 <balor> If I "$(makeAcidic ''Foldr ['getDocument, 'addDocument])" can I just export GetDocument from the module?
22:28:26 <balor> as I need the GetDocument to query' store GetDocument theid
22:37:39 <stepkut> yep
22:43:14 <balor> yes! yes! It works....live...liiiiive...liiiiivvvEEEe my beauty
22:43:48 <stepkut> sweeeeeet!
22:58:23 <balor> My elements of the IxSet have a unique Int64 id (for REST).  It seems silly to query everything in the IxSet in order to get the size and increment it to assign an id to a new element.
22:58:32 <balor> is there a better way?
23:01:14 <stepcut> that is not safe anyway
23:01:22 <stepcut> what happens if you delete an element?
23:01:40 <balor> oh yeah
23:01:56 <stepcut> I usually do something like, data MyState = MyState { ixset :: IxSet Foo, nextFooId :: FooId }
23:02:24 <stepcut> on the TODO-list for IxSet/kdtree is to see if there is a reasonable way to do that automatically
23:02:39 <balor> That'd be cool.
23:02:44 <stepcut> yeah
23:36:18 <stepcut> also, I find that using NamedFieldPuns and RecordWildCards makes things a lot easier when using acid-state with record types
23:37:53 <balor> How do you get the nextFooId out of an (AcidState MyState)?
23:40:06 <balor> I've got "do methodM; store <- ask;..."  where store is the AcidState
23:40:56 <stepcut> I usually don't..
23:41:22 <stepcut> I usually just have the function that adds a new value also update the id to be unique
23:41:56 <balor> I need to redirect the URL to the latest update
23:41:58 <stepcut> but if you wanted to get the nextFooId out, then you would make a new function like, getNextId :: Update Foo FooId and register that with makeAcidic
23:42:07 <balor> d'oh
23:42:15 <balor> I've been thinking too complex
23:42:26 <stepcut> :)
23:42:50 <stepcut> for the latest update, maybe you want to do it differently..
23:43:02 <stepcut> but it is hard to say without more context
23:43:20 <stepcut> well. that could actually work fine
23:44:46 <stepcut> if you are doing something like, do fid <- update store GetNextId ; let foo = foo { fooId = fid } ; update store (InsertFoo foo) ; seeOther ("/foo/" ++ show fid) (toResponse "")