Experimental IRC log happs-2007-09-21

Available formats: content-negotiated html turtle (see SIOC for the vocabulary)

Back to channel and daily index: content-negotiated html turtle

These logs are provided as an experiment in indexing discussions using IRCHub.py, Irc2RDF.hs, and SIOC.

00:06:55<nbarterd>answering my own question: yeah, the new url is ...:8000/blog/edit
00:46:53<shapr>yarr
00:47:01<shapr>mmm, unicycling!
00:47:24<shapr>Unicycling is almost as nifty as programming.
10:26:49<nomeata>Hi. I’m working my way through a simple state happs app.
10:27:11<Lemmih>Any problems?
10:27:26<nomeata>I was told that I can make a function that uses the state (“readVal”) available to my handlers using “$(expose 'readVal)”
10:27:36<nomeata>And that I can then use it using “query ReadVal”. correct so far?
10:28:03<Lemmih>Yes. It's $(expose ['readval]), though.
10:28:10<nomeata>right
10:28:31<nomeata>and can I get the state in readVal using “ask”? e.g.: readVal = ask in the simplest case?
10:28:43<Lemmih>Yes.
10:28:52<nomeata>ok, then I get the following error:
10:29:01<nomeata>/home/jojo/incoming/happs-test//haskell/Main.hs:53:2:
10:29:01<nomeata> No instance for (Typeable r[aPRQ])
10:29:01<nomeata> arising from the superclasses of an instance declaration
10:29:01<nomeata> at /home/jojo/incoming/happs-test//haskell/Main.hs:53:2
10:29:01<nomeata> Possible fix:
10:29:01<nomeata> add (Typeable r[aPRQ])
10:29:06<nomeata> to the instance declaration superclass context
10:29:08<nomeata> In the instance declaration for `QueryEvent ReadVal r[aPRQ]'
10:29:43<nomeata>the HTTP handler looks like this:
10:29:49<nomeata>method GET $ do (MySt val count) <- query ReadVal; ok ((show val) ++ (show count))
10:29:59<nomeata>and the state function is:
10:30:01<nomeata>data MyState = MySt { appVal :: Int, appCount :: Int } deriving (Read, Show, Typeable)
10:30:08<nomeata>and I defined a StartState instance.
10:30:45<nomeata>line 53 is the $(expose ..) line.
10:31:10<Lemmih>readVal is too general. You have to tell it to return a MyState.
10:31:31<Lemmih>Or use the 'askState' function.
10:31:51<nomeata>in what monad would readVal have to work? This surely wont work, right:
10:31:53<nomeata>readVal :: MyState
10:31:53<nomeata>readVal = ask
10:32:05<Lemmih>readVal :: Query MyState MyState
10:32:46<nomeata>why MyState twice? once for the type of my state, and once for the return value?
10:32:56<Lemmih>Exactly.
10:33:25<nomeata>so can I actually have more than one state, with different types?
10:33:43<nomeata>hmm. no I get:
10:33:46<nomeata>/home/jojo/incoming/happs-test//haskell/Main.hs:57:7:
10:33:46<nomeata> Ambiguous type variable `st' in the constraints:
10:33:46<nomeata> `StartState st'
10:33:46<nomeata> arising from use of `stdMain'
10:33:46<nomeata> at /home/jojo/incoming/happs-test//haskell/Main.hs:57:7-39
10:33:47<nomeata> `Serialize st'
10:33:49<nomeata> arising from use of `stdMain'
10:33:51<nomeata> at /home/jojo/incoming/happs-test//haskell/Main.hs:57:7-39
10:33:53<nomeata> Probable fix: add a type signature that fixes these type variable(s)
10:34:35<Lemmih>When you do what?
10:35:22<nomeata>compile, with readVal :: Query MyState MyState and the rest unchanged
10:35:49<Lemmih>That's weird. Can you paste the code on hpaste?
10:35:55<nomeata>sure
10:36:49<nomeata>http://hpaste.org/2839
10:36:58<nomeata>a lot of code is commented out, from earlier experiments.
10:40:12<Lemmih>HAppS doesn't know how to serialize that state.
10:40:40<nomeata>ah, ok, could have thought of that myself
10:40:52<Lemmih>This might be of inspiration: http://happs.org/HAppS/HAppS-Server/Examples/httpState.hs
10:41:52<nomeata>but then, MyState has Read, Show and Typable, I thought that’d be enough to derive Serialize
10:42:02<Lemmih>Not anymore.
10:42:23<Lemmih>We use Data, Default and XML now.
10:42:35<nomeata>ah, I also need toString and fromString
10:42:44<nomeata>..reading in HAppS/State/Serialize.hs
10:43:08<nomeata>ah, the line that I saw there is commented out. I need a syntax-aware grep :-)
10:43:10<Lemmih>Or you can just use 'deriveAll'.
10:44:06<nomeata>yes, but I want to understand what’s going on, so I’m trying to avoid TH where possible
10:44:27<Lemmih>Ok, you can derive Serialize by hand.
10:44:59<Lemmih>encodeBinary = defaultEncodeString; decodeBinary = defaultDecodeString
10:45:12<Lemmih>^^ That'll work if you derive Read/Show.
10:46:33<nomeata>hmm. adding these does not help:
10:46:35<nomeata>instance ToString MyState where
10:46:35<nomeata> toString = show
10:46:35<nomeata>
10:46:35<nomeata>instance FromString MyState where
10:46:35<nomeata> fromString _ = return . read
10:46:43<nomeata>I’ll try by deriving Serialize myself
10:47:47<nomeata>nope, even with instance Serialize MyState I get the error about Ambiguous type variable st...
10:50:23<Lemmih>Oh!
10:50:45<nomeata>http://hpaste.org/2839#a1 ← current version
10:50:54<Lemmih>You need: :*: stateFuns
10:51:00<Lemmih>Instead of :*: End.
10:51:12<nomeata>ah, more magic coming out of $(expose, right?
10:51:54<Lemmih>Yeah.
10:52:25<Lemmih>The name was rather arbitrarily chosen and will probably change before it's released.
10:52:45<nomeata>ok, it compiles now, thx
10:53:05<nomeata>the error message I get when I remove the Serialize instance is pretty ugly :-)
10:53:13<Lemmih>It sure is.
10:53:17<nomeata>/home/jojo/incoming/happs-test//haskell/Main.hs:47:7:
10:53:17<nomeata> No instances for (Data.Generics.SYB.WithClass.Basics.Data XmlD
10:53:17<nomeata> MyState,
10:53:17<nomeata> Default MyState,
10:53:17<nomeata> Data.Generics.SYB.WithClass.Basics.Data NormalizeD MyState,
10:53:17<nomeata> Data.Generics.Basics.Data MyState)
10:53:19<nomeata> arising from use of `stdMain'
10:53:21<nomeata> at /home/jojo/incoming/happs-test//haskell/Main.hs:47:7-45
10:53:23<nomeata> Possible fix:
10:53:25<nomeata> add an instance declaration for
10:53:27<nomeata> (Data.Generics.SYB.WithClass.Basics.Data XmlD MyState,
10:53:29<nomeata> Default MyState,
10:53:31<nomeata> Data.Generics.SYB.WithClass.Basics.Data NormalizeD MyState,
10:53:33<nomeata> Data.Generics.Basics.Data MyState)
10:53:35<nomeata> In the expression: stdMain ((simpleHTTP http) :*: stateFuns)
10:53:39<nomeata> In the definition of `main':
10:53:43<nomeata> main = stdMain ((simpleHTTP http) :*: stateFuns)
10:53:43<nomeata> where
10:53:45<nomeata> http = [method GET (ok $ "GETting root hello"),
10:53:47<nomeata> dir
10:53:49<nomeata> "val"
10:53:51<nomeata> [(method GET)
10:53:53<nomeata> $ (do (MySt val count) <- query ReadVal
10:53:55<nomeata> ok ((show val) ++ (show count)))]]
10:53:59<nomeata>ok, I’ll be more experimenting after lunch. I’m also considering to make it a tutorial − let’s see how far I get.
10:54:00<nomeata>thanks so far and see you later
12:06:33<nomeata>yay, my simple state test program finally works. thx Lemmih!
12:11:37<nomeata>any chance to get http://happs.org/auto/apidoc/index.html up for 0.9.1?
12:29:24<tuukkah>hi nomeata!
12:29:37<nomeata>tuukkah: hi
12:29:41<tuukkah>i hear the apidocs don't currently build :-/
12:30:30<nomeata>too bad, would be useful :-)
12:32:23<tuukkah>haddock doesn't parse files with template haskell or something like that
13:38:03<nomeata>I see that I can return a datatype as XML, because there is an instance of ToMessage a for Xml a. But what if I don’t like the way the XML is created, how do I overwrite it? ToElement?
13:39:08<nomeata>And should I even care about HAppS.Server.MinHaXML or is that internal?
13:40:42<Igloo>Make an Xml YourType instance. You probably want to implement toXml and readXml'
13:42:16<Lemmih>I wonder if bencoding would be better than xml.
13:42:36<nomeata>but then this will also be used for the state serialisation, right?
13:55:11<nomeata>I woudn’t mind the default Xml if the values of an Algebraic type were not just appended to each other as numbers:
13:55:48<nomeata>MySt {appVal = 8, appCount = 9, irrelevant = True} becomes <MySt>981</MySt>
13:56:26<nomeata>in the checkpoint file, this reads: <mySt haskellType="MyState"><![CDATA[8]]><![CDATA[9]]><![CDATA[1]]></mySt>, but the browser does not get that, it seems.
13:56:59<nomeata>and it would be hard to work with with XSLT
13:58:15<Igloo_>What do you mean by "does not get that"?
13:58:22<Igloo_>And what do you want instead?
14:00:28<nomeata>I’d like to see <MySt><appVal>8</appVal><appCount>9</appCount>...</MySt> so I can extract the values in XSLT
14:01:08<nomeata>and with get I mean:
14:01:09<nomeata>$ GET http://localhost:8000/val/
14:01:09<nomeata><?xml version='1.0' encoding='UTF-8' ?>
14:01:09<nomeata><mySt>1230281</mySt>
14:01:36<nomeata>(if I just feed the MySt value to “ok”, no XSLT involved)
14:02:18<Igloo_>Ah, hmm, I wouldn't be surprised if XML apps were allowed to normalise like that
14:02:52<nomeata>probably yes, but then the original way (<mySt haskellType="MyState"><![CDATA[8]]><![CDATA[9]]><![CDATA[1]]></mySt>) is not really great
14:24:12<nomeata>anyways, i got to go. I’ll work on that later.
17:56:58<Lemmih>Haddock documentation coming up.
17:58:30<Saizan>Igloo++
17:58:47<shapr>yow
18:00:39<Lemmih>No karma to me? *sob*
18:01:08<Saizan>well no karma for anyone since lambdabot is not here :)
18:01:35<Igloo>What'd I do?
18:01:45<Saizan>ops
18:02:05<Saizan>i just read the nick wrong..
18:02:07<Lemmih>Igloo: General awesomeness, I think.
18:02:12<Igloo>Ah :-)
18:02:21<Saizan>s/Igloo/Lemmih/
18:03:40<Lemmih>Is recording the documentation a good way of pushing it to the public?
18:27:28<Lemmih>shapr: How's the second monitor?
18:27:39<shapr>It's nice
18:29:16<Lemmih>shapr: Wanna help me clean up HAppS.Server.HTTP.Types and HAppS.State.Transaction ?
18:29:30<shapr>Yeah sure
18:31:34<Lemmih>Get the latest patches and have a look at the documentation for HAppS.Server.SimpleHTTP.
18:32:25<Lemmih>You may need to pull HAppS-Util, and HAppS-State.
18:32:44<shapr>I'll just pull everything.
18:36:52<Lemmih>We need to remove all non-types from Types.hs.
18:37:19<Lemmih>And there's some duplication functionality (redirect,redirect_,redirect',redirect'_).
18:44:12<shapr>There's a whole bunch of dead code too.
18:45:10<Lemmih>Yeah, we can throw that out.

Back to channel and daily index: content-negotiated html turtle