trapped has quit [Read error: Connection reset by peer]
aturley has joined #ponylang
aturley has quit [Ping timeout: 246 seconds]
montanonic has quit [Ping timeout: 264 seconds]
montanonic has joined #ponylang
montanonic has quit [Ping timeout: 260 seconds]
aturley has joined #ponylang
aturley has quit [Ping timeout: 246 seconds]
montanonic has joined #ponylang
montanonic has quit [Ping timeout: 258 seconds]
jemc has joined #ponylang
<Scramblejams>
Can someone give me a snippet that shows how to iterate over the headers in a Payload object?
<Scramblejams>
Ideally over the pairs
<Scramblejams>
But at this time of night I'm not as picky :-D
<Scramblejams>
Not sure why I can't just say "let header_pairs = my_payload.headers().pairs()", then do a for loop over that
aturley has joined #ponylang
aturley has quit [Ping timeout: 252 seconds]
<Scramblejams>
Hmm. Okay, if I change my request handler's apply function to have a type signature of "fun val apply(request: Payload val)" instead of making request an iso, I can get to the headers. However, I then can't call payload.respond() on it
<Scramblejams>
What I don't get is, if I do set request to be an iso, why can't I do whatever I want with it? It's an iso, I own it, shouldn't I be able to fiddle with it willy nilly until I call respond() which requires consuming it?
<Scramblejams>
I need it to be a val so I can get the headers, then I need it to be an iso so I can call respond(). Guess I need to read up about trn?
<Scramblejams>
So if it's iso, I get this http://pastebin.com/5ziu3ydw . If it's val, I get this http://pastebin.com/aZweGNrF . I understand why I can't consume a val, but of course I can't call respond() without it being an iso...
unbalancedparen has quit [Quit: WeeChat 1.5]
<Scramblejams>
Seems like surrounding the key, value loop in a "recover val" block should do it, but nope.
<doublec>
Scramblejams: if your request is an iso, the data you get out of it is restricted in their capability
<doublec>
Scramblejams: this is viewtype adaption
<Scramblejams>
doublec: Okay, so how does one receive a payload, iterate over its headers and then call respond() on it?
<doublec>
Scramblejams: Say an iso object has a ref field. You can't get that field as a ref because then you have a writeable alias to something internal to an iso - two ways to write to it
<doublec>
Scramblejams: looking now
<Scramblejams>
Okay, I can see that.
<doublec>
I'm struggling to see how you can use headers()
<doublec>
It returns the 'ref' map using viewpoint adaption which is a 'tag' for an iso
<Scramblejams>
Well if you're struggling then I'm toast! :-D
* doublec
thinks
aturley has joined #ponylang
<jemc>
I think this is probably one of those areas of the HTTP package that need to be redesigned
<jemc>
conceptually I'd think the Request should be a val, and the RespondFn should be a separate iso instead of being part of the request
<Scramblejams>
Mmm. This just keeps happening to me, every time I try to do a simple pony project I run headlong into some can of worms. To be expected at pony's current maturity level, I suppose, but frustrating nonetheless.
<doublec>
Scramblejams: ok, got it
<Scramblejams>
Well thanks for letting me know that there's a design issue, that'll keep me from beating my head against the wall any more tonight. :-)
<doublec>
Scramblejams: 'trn' on the left of the table, 'ref' on the top, give 'box'
<doublec>
Scramblejams: notice how 'iso' on the left with 'ref' on the top gave 'tag' which was our problem
<Scramblejams>
Okay, I had to look and see that pairs() is ref
<doublec>
Scramblejams: pairs() is box
<Scramblejams>
LOL
<doublec>
Scramblejams: It's the returned Map from headers() that is the ref or trn
<doublec>
depending on what we call it with
<doublec>
So iso Payload, calling headers() returns a trn Map
<doublec>
s/trn/tag/
<doublec>
We can't call pairs() on that tag map because pairs() requires a box receiver
aturley has quit [Ping timeout: 264 seconds]
<doublec>
But a trn Payload, calling headers, returns a box Map
<doublec>
Which we can now call pairs on
<doublec>
And because we converted to a trn inside a recover block the compiler knows that reference never escapes so we can consume it back to the iso at the end of the block.
<doublec>
Which allows us to call respond.
<Scramblejams>
Okay. One thing that's confused me about recover is, how does it 'know' what to recover? I've seen some pretty big blocks of code wrapped inside recover, and it's not clear to me looking at it what it is and isn't affecting.
<doublec>
Scramblejams: it basically provides a scope where it only sendable things can go in
<doublec>
Scramblejams: and this allows the compiler to know that anything that is the result of the recover block isn't aliased
<doublec>
Scramblejams: and can be converted to another capability
<doublec>
Scramblejams: you'll see your usecase mentioned ""Borrow" an iso as a ref, do a series of complex mutable operations on it, and return it as an iso again."
<Scramblejams>
ah k thanks
<doublec>
I borrowed it as a trn, but a ref works too
<Scramblejams>
Alright, well, many thanks for your help tonight. I'm still pretty snowed but I'll keep at it.
<doublec>
Scramblejams: no problem, it's definitely a difficult part of the language to grasp
<Scramblejams>
Probably not going to get any easier, is it?
<doublec>
It does get easier
<Scramblejams>
(that is, as pony develops)
<doublec>
Library design can help
<doublec>
In this case, the design makes it difficult
<doublec>
Mostly because for efficiency they don't want to copy the map
<doublec>
Or find a way to make the headers a val inside the payload
<doublec>
since you don't want to modify it
<doublec>
Scramblejams: do you mind if I use a variant of your example in a blog post?
<Scramblejams>
Please do! I'll keep an eye out for it.
<doublec>
Scramblejams: If I get time I'd like to write sometihng up about it
<doublec>
Scramblejams: thanks!
<Scramblejams>
I really appreciate explain-capabilities-like-I'm-5 stuff. Like, "look at the pairs() function, see how it says box next to it? that means we need yadda yadda yadda..." Capability keywords are plastered everywhere and I often don't know what the relevant one is to look at.
<doublec>
Yeah, I find it helps a lot to walk through the capability transitions on each call
<Scramblejams>
Sure could use a nice graphical example of doing that, if you're looking for topics :-)
<doublec>
I've avoided writing about it because my first post on Pony said that capability tutorials would be the new monad tutorial (ie. everyone writes one) haha
<Scramblejams>
My gosh I need about twelve of those to read.
<Scramblejams>
When we're actually saturated in capabilities tutorials, then you can worry about avoiding cliches.
<Scramblejams>
Yes, thanks, but I forgot about it, so good to be reminded of it.
<doublec>
But I'm a do by example person so really like lots of examples walking through how it works
<doublec>
The "Recovery allows us to convert a reference capability..." portion of that post is a good description of what recovery actually does
<doublec>
"The value of a recover block is the value returned at the end of that block. All the other aliases created within the block will be destroyed upon leaving it."
<Scramblejams>
K. I've got to do a lot more reading. This is the hardest language I've tried to learn. That could be because I've never tried Haskell, I suppose.
tm-exa has joined #ponylang
<doublec>
I think it's closer to languages like Rust and ATS - that don't have a GC but have a type system that tells you when you're doing memory wrong
<Scramblejams>
And here I was, basically hoping for Ocaml-with-actors-green-threads-and-low-latency... :-D
<doublec>
Pony has a GC but you're still managing pointer access so have to think about it
<doublec>
Scramblejams: It does get easier, once it clicks :)
* doublec
has to head out. Have fun!
<Scramblejams>
Thanks again for the help!
<doublec>
np
tm-exa has quit [Quit: Computer has gone to sleep]
tm-exa has joined #ponylang
tm-exa has quit [Ping timeout: 260 seconds]
jemc has quit [Ping timeout: 272 seconds]
tm-exa has joined #ponylang
aturley has joined #ponylang
aturley has quit [Ping timeout: 240 seconds]
gsteed has joined #ponylang
aturley has joined #ponylang
aturley has quit [Ping timeout: 264 seconds]
montanonic has joined #ponylang
montanonic has quit [Ping timeout: 258 seconds]
amclain has quit [Quit: Leaving]
aturley has joined #ponylang
aturley has quit [Ping timeout: 272 seconds]
montanonic has joined #ponylang
Praetonus has joined #ponylang
aturley has joined #ponylang
aturley has quit [Ping timeout: 260 seconds]
gsteed has quit [Quit: Leaving]
aturley has joined #ponylang
trapped has joined #ponylang
_andre has joined #ponylang
aturley has quit [Ping timeout: 258 seconds]
montanonic has quit [Ping timeout: 272 seconds]
aturley has joined #ponylang
aturley has quit [Ping timeout: 258 seconds]
aturley has joined #ponylang
aturley has quit [Ping timeout: 240 seconds]
M-hrjet has quit [Remote host closed the connection]
M-hrjet has joined #ponylang
aturley has joined #ponylang
aturley has quit [Ping timeout: 244 seconds]
jemc has joined #ponylang
michael_campbell has joined #ponylang
unbalancedparen has joined #ponylang
gsteed has joined #ponylang
jemc has quit [Ping timeout: 260 seconds]
SilverKey has joined #ponylang
Perelandric has joined #ponylang
SilverKey has quit [Quit: Halted.]
btbytes has joined #ponylang
SilverKey has joined #ponylang
aturley has joined #ponylang
aturley has quit [Ping timeout: 244 seconds]
runehog has quit [Remote host closed the connection]
runehog has joined #ponylang
runehog has quit [Remote host closed the connection]
btbytes has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
aturley has joined #ponylang
amclain has joined #ponylang
SilverKey has quit [Quit: Halted.]
aturley has quit [Ping timeout: 250 seconds]
hibnico has joined #ponylang
SilverKey has joined #ponylang
hibnico has quit [Quit: hibnico]
runehog has joined #ponylang
Praetonus has quit [Quit: Leaving]
hibnico has joined #ponylang
hibnico has quit [Client Quit]
k0nsl has quit [Ping timeout: 246 seconds]
k0nsl has joined #ponylang
hibnico has joined #ponylang
mrkishi_ has joined #ponylang
hibnico has quit [Client Quit]
mrkishi has quit [Ping timeout: 252 seconds]
aturley has joined #ponylang
SilverKey has quit [Quit: Halted.]
jemc has joined #ponylang
tm-exa has quit [Quit: Computer has gone to sleep]
SilverKey has joined #ponylang
ericbmerritt has joined #ponylang
SilverKey has quit [Client Quit]
SilverKey has joined #ponylang
mrkishi_ has quit [Ping timeout: 276 seconds]
mrkishi has joined #ponylang
btbytes has joined #ponylang
tm-exa has joined #ponylang
mrkishi_ has joined #ponylang
mrkishi has quit [Ping timeout: 264 seconds]
mrkishi has joined #ponylang
mrkishi_ has quit [Ping timeout: 272 seconds]
mrkishi has quit [Ping timeout: 276 seconds]
mrkishi has joined #ponylang
mrkishi_ has joined #ponylang
mrkishi has quit [Ping timeout: 272 seconds]
mrkishi_ has quit [Ping timeout: 276 seconds]
mrkishi has joined #ponylang
tm-exa has quit [Quit: Computer has gone to sleep]
mrkishi has quit [Ping timeout: 272 seconds]
jemc has quit [Ping timeout: 276 seconds]
mrkishi has joined #ponylang
btbytes has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
btbytes has joined #ponylang
runehog_ has joined #ponylang
runehog has quit [Read error: Connection reset by peer]
Matthias247 has joined #ponylang
btbytes has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
SilverKey has quit [Quit: Halted.]
btbytes has joined #ponylang
_andre has quit [Quit: leaving]
runehog_ has quit [Remote host closed the connection]
montanonic has joined #ponylang
btbytes has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
SilverKey has joined #ponylang
runehog has joined #ponylang
c355e3b has quit [Quit: Connection closed for inactivity]
aturley has quit [Ping timeout: 258 seconds]
SilverKey has quit [Quit: Halted.]
SilverKey has joined #ponylang
btbytes has joined #ponylang
btbytes has quit [Client Quit]
c355e3b has joined #ponylang
aturley has joined #ponylang
btbytes has joined #ponylang
montanonic has quit [Ping timeout: 264 seconds]
montanonic has joined #ponylang
aturley has quit [Ping timeout: 272 seconds]
jemc has joined #ponylang
SilverKey has quit [Quit: Halted.]
aturley has joined #ponylang
aturley has quit [Ping timeout: 258 seconds]
unbalancedparen has quit [Quit: WeeChat 1.5]
montanonic has quit [Ping timeout: 258 seconds]
montanonic has joined #ponylang
Matthias247 has quit [Read error: Connection reset by peer]
hibnico has joined #ponylang
nyarum has joined #ponylang
nyarumes has quit [Read error: Connection reset by peer]
nyarumes has joined #ponylang
nyarum has quit [Read error: Connection reset by peer]