jemc changed the topic of #ponylang to: Welcome! Please check out our Code of Conduct => https://github.com/ponylang/ponyc/blob/master/CODE_OF_CONDUCT.md | Public IRC logs are available => http://irclog.whitequark.org/ponylang
aturley has quit [Ping timeout: 244 seconds]
mcguire has joined #ponylang
aturley has joined #ponylang
aturley has quit [Ping timeout: 258 seconds]
mcguire has quit [Ping timeout: 272 seconds]
aturley has joined #ponylang
SilverKey has joined #ponylang
aturley has quit [Ping timeout: 252 seconds]
TwoNotes has quit [Quit: Leaving.]
aturley has joined #ponylang
SilverKey has quit [Quit: Halted.]
aturley has quit [Ping timeout: 250 seconds]
SilverKey has joined #ponylang
c355e3b has quit [Quit: Connection closed for inactivity]
SilverKey has quit [Quit: Cheerio!]
copy` has quit [Quit: Connection closed for inactivity]
jemc has quit [Ping timeout: 276 seconds]
aturley has joined #ponylang
aturley has quit [Ping timeout: 276 seconds]
ob_ has joined #ponylang
unbalancedparen has quit [Quit: WeeChat 1.5]
ob_ has quit [Ping timeout: 272 seconds]
ob_ has joined #ponylang
ob_ has quit [Ping timeout: 246 seconds]
jemc has joined #ponylang
aturley has joined #ponylang
aturley has quit [Ping timeout: 264 seconds]
amclain has quit [Quit: Leaving]
jemc has quit [Ping timeout: 276 seconds]
aturley has joined #ponylang
trapped has joined #ponylang
aturley has quit [Ping timeout: 250 seconds]
jemc has joined #ponylang
aturley has joined #ponylang
nyarum has joined #ponylang
aturley has quit [Ping timeout: 276 seconds]
nyarumes has quit [Ping timeout: 252 seconds]
jemc has quit [Ping timeout: 276 seconds]
SilverKey has joined #ponylang
tm-exa has joined #ponylang
trapped has quit [Read error: Connection reset by peer]
<lisael> hop
tm-exa has quit [Quit: Computer has gone to sleep]
SilverKey has quit [Quit: Halted.]
tm-exa has joined #ponylang
hibnico has joined #ponylang
aturley has joined #ponylang
aturley has quit [Ping timeout: 272 seconds]
tm-exa has quit [Quit: Computer has gone to sleep]
c355e3b has joined #ponylang
tm-exa has joined #ponylang
Applejack_ has joined #ponylang
hibnico has quit [Quit: hibnico]
Scramblejams has quit [Ping timeout: 260 seconds]
Scramblejams has joined #ponylang
Praetonus has joined #ponylang
hibnico has joined #ponylang
Praetonus has quit [Quit: Leaving]
aturley has joined #ponylang
copy` has joined #ponylang
aturley has quit [Ping timeout: 276 seconds]
shepheb has quit [Ping timeout: 276 seconds]
shepheb has joined #ponylang
aturley has joined #ponylang
aturley has quit [Ping timeout: 276 seconds]
<shepheb> SeanTAllen: is your streaming JSON output code up anywhere? I'm curious how it works. I'm working with a little DSL for describing nested HTML views (not in Pony; day job) that seems like it might work.
aturley has joined #ponylang
<shepheb> well, "DSL". not really, it's just an API where most of the functions return this so you can chain them really nicely.
_andre has joined #ponylang
aturley has quit [Ping timeout: 240 seconds]
ob_ has joined #ponylang
ob_ has quit [Ping timeout: 272 seconds]
aturley has joined #ponylang
aturley has quit [Ping timeout: 258 seconds]
<shepheb> calling req.body() seems really messy - it returns a this->Array[ByteSeq], but since you usually have a Payload iso, that seems to return a Array[ByteSeq] tag
<shepheb> I still don't grok what this-> does at all
<shepheb> I just have a vague sense that it means "returns a thing, but through my own viewpoint adaptation" or more precisely "through an alias's viewpoint adaptation"
<shepheb> upshot is that it's distressingly hard to turn an incoming HTTP request's body into a String!
aturley has joined #ponylang
SilverKey has joined #ponylang
<shepheb> ah, my "more precisely" above is wrong.
<shepheb> but I've got an iso origin that's returning its view of a box field - that's a tag.
SilverKey has quit [Quit: Halted.]
<shepheb> if I were fetching over HTTP, I could consume the payload and get its body, and be fine. but I need to respond to this request, and that needs an iso.
SilverKey has joined #ponylang
<shepheb> that's a new one: "Internal failure not reported"
<shepheb> (I hacked in a new method fun body_iter(): Iterator[U8] iso^ into Payload, that got me moving for now.)
jemc has joined #ponylang
<shepheb> jemc: I just got "Error: Internal failure not reported" from ponyc O_o
SilverKey has quit [Quit: Halted.]
Applejack_ has quit [Ping timeout: 250 seconds]
unbalancedparen has joined #ponylang
<jemc> shepheb: is it reproducable?
<shepheb> I can repeatedly run ponyc and get the same result
<shepheb> I don't have a minimal case; I'm working on that.
<shepheb> first guess: object literal with undefined fields?
Applejack_ has joined #ponylang
<shepheb> there's a bit more to it than that, I guess. still distilling.
<shepheb> there we go, got a pretty minimal case. posting to gist.
<jemc> cool, thanks
<jemc> regarding Payload - yeah, seems like a usability issue - I think putting the ResponseHandler inside the Payload object was probably not the best idea from a usability standpoint, as it means you have to keep the Payload an iso until the end when you respond - instead, I think it would be best if the ResponseHandler iso were passed separately and the Payload were passed as a val
<jemc> I haven't used Pony's HTTP package, but I know there has been talk that it needs to be rewritten
<shepheb> I guess I'll manhandle the HTTP library and see if it turns into a PR eventually.
<shepheb> unless someone else out there has already started this, or has ideas on the revamped API.
<shepheb> most of the web stuff I've seen, your handlers get passed the incoming request (probably val) and the outgoing response (reasonably an iso here?)
<jemc> don't know if someone has started a PR to reform the HTTP package, but I know TwoNotes hit the same usability issue and may have ideas for working with it
<shepheb> you examine the request, add the headers, body, status to the response, and send it.
<jemc> yeah, that approach makes sense to me as well
<shepheb> okay, I'll watch for him/her and ask.
<jemc> as an optimization, it would also allow the HTTP server actor to "reuse" the same response object by clearing it and passing it to another handler, thus avoiding some allocations in the hot path
<shepheb> speaking of PRs I want to try to pull my streaming JSON parser and SeanTAllen's streaming JSON emitter together, unify them so they're sane together, and PR them as a new json/stream package.
<shepheb> and rewrite the normal object-tree-in-memory json package to use them internally.
SilverKey has joined #ponylang
<jemc> on it's face that sounds appropriate to me - but I'd note that by then I think we'll have the RFC system finalized so you would probably want to go through that system to get all stakeholders involved in helping to refine the API design
trapped has joined #ponylang
<jemc> hopefully having more eyes on new APIs should help prevent some usability issues like these in the future
<shepheb> SGTM to use JSON and HTTP as two early RFCs through that process.
<jemc> shepheb: debugging your gist right now, but you do realize that the code is invalid, right?
<jemc> I obviously need to fix it to print an error instead of crashing, but it is invalid
graaff has joined #ponylang
<shepheb> jemc: oh, absolutely.
<shepheb> wait, invalid in what way?
<shepheb> the gist as-is is wrong, object literals aren't allowed to have undefined fields.
<jemc> yep, that's what I mean
<jemc> just checking
<shepheb> actually, I meant to say: when the object literal is just written into a local value
<shepheb> you get an unrelated error.
<shepheb> which is marginally better than the internal error.
<shepheb> like it fails to resolve the type of the literal
<jemc> didn't want you to be waiting on me to fix this case only to have me finish and have it print an error for you
<shepheb> no, no
gsteed has joined #ponylang
amclain has joined #ponylang
Applejack_ has quit [Ping timeout: 250 seconds]
<shepheb> slight quirk
<shepheb> if an interface or trait (without an implementation for this method) gives a default value for some argument, and the real implementation doesn't
<shepheb> you can get errors for "not enough arguments" even though there's a default. it seems to me that the defaults are part of the signature, and I shouldn't be allowed to write an implementation that doesn't include the correct defaults.
<shepheb> similar to how I can't write a partial implementation when the interface says total.
<SeanTAllen> shepheb: its not streaming but there is a rough version up... https://gist.github.com/SeanTAllen/f3c3a2c623c0d4338fcbb2f51dd86246
<shepheb> hm. I may play around with a streaming, chainable API the forms a counterpart to my parser.
<shepheb> we'll see how it goes.
<shepheb> my hope is to save some of the hackery of constructing iso maps that then get turned into JsonObject and then into JsonDocs
<shepheb> I'm hacking away on the HTTP stuff, but this is a deep change and more or less causes a rewrite.
<shepheb> we'll see if I can get it to work in the end.
<shepheb> I'm annoyed by traits having no fields.
<shepheb> since, say, a RequestBuilder and a ResponseBuilder are almost identical
<shepheb> I can't put 90% of the code into a trait and have two thin wrappers, without adding a whole bunch of internal methods to get and set various fields; this isn't Java.
<SeanTAllen> I think that is the theory behind "delegates". to make that form of composition easier. although i can't say i've ever actually found it delegates useful. so ¯\_(ツ)_/¯.
<SeanTAllen> New Pony Pattern published: "Supply Chain" -> http://patterns.ponylang.org/creation/supply-chain.html
graaff has quit [Quit: Leaving]
tm-exa has quit [Quit: Computer has gone to sleep]
SilverKey has quit [Quit: Halted.]
hibnico has quit [Quit: hibnico]
<shepheb> I'd love to (a) understand delegates; (b) use them here.
<shepheb> erm. delegates appear to be have been removed from the tutorial altogether?
<SeanTAllen> yes they have.
<SeanTAllen> its still in the repo in all its confusing glory
<shepheb> sadly, that makes them only slightly less mystifying.
<shepheb> er, slightly more.
<SeanTAllen> every time ive tried to use them, it turned out to not make a difference
<SeanTAllen> and no one has come forward with a "look i am using them and it is better than the alternatives" so they are on the slow track to removal at the moment]
<shepheb> sounds about right. I do wish we had a better solution for this case of two classes that are almost identical, though. I hate the feeling that Java's type system can do better - it's pretty basic.
<SeanTAllen> now that i think about it, i dont think delegates help you either
<SeanTAllen> So shepheb, most everything is the same except for a couple key differences?
<SeanTAllen> what are the key differences?
<shepheb> this is building an HTTP request or response.
<shepheb> which means collecting several chunks of data, and moving through a small state machine as we consume the various parts of a request.
<shepheb> the output type is the most important difference, but it's not the only one, so it's not purely a case of generics.
<mcguire1> shepheb, I like the idea that removing delegates from the tutorial makes them *less* mystifying.
<SeanTAllen> without seeing the code, this sounds like a possible fit for something like the Strategy pattern
<shepheb> hm, maybe.
<jemc> shepheb: I often encounter the same frustrations, but there are some options
<shepheb> well, an HTTP request is something like GET /some/url\nheaders...\nbody...
<shepheb> and a response if 200 OK\nheaders...\nbody....
<jemc> regarding the strategy pattern, I sometimes use a field with a primitive that contains the strategy
<shepheb> so it's mostly that first bit that's important. requests and responses have slightly different fields, too.
<shepheb> that's probably usable here.
<shepheb> two simple parsing primitives that return an initialized request or response appropriately.
<jemc> if the inner strategy is a primitive, you can also use a type parameter to set it
<jemc> if you squint, the primitive-as-a-type-parameter almost looks like a mixin
<jemc> (almost) :)
<SeanTAllen> sounds like a pattern to write up jemc
<jemc> yeah, it probably would make a good pattern writeup
SilverKey has joined #ponylang
copy` has quit [Quit: Connection closed for inactivity]
Applejack_ has joined #ponylang
tm-exa has joined #ponylang
<shepheb> jemc: is there a good example of using a type parameter as you said?
<shepheb> that case works for me, but I'm not sure how to actually invoke the strategy in that case.
tm-exa has quit [Client Quit]
<jemc> if you gist what you have so far, I can try to give suggestions
<jemc> the basic idea is to call A.foo(...) if A is your type parameter and foo is your function
<jemc> otherwise I will try to write something up tonight or tomorrow.
<shepheb> the primitives and their common interface are near the top, the _PayloadParser and the two below it.
<shepheb> passing the type parameter right at the bottom
<shepheb> and I tried to do Parser.apply(...)
<shepheb> where Parser is the name of the type parameter, but it was giving me trouble.
<shepheb> if that is the correct syntax, I'll see if I can figure it out.
<jemc> at first glance that looks about like I what I was picturing - what error did you see?
<jemc> ah, you probably want `interface val _PayloadParser`
<shepheb> quite possibly. it's trying to find create() in the interface :/
<jemc> ah right, forgot that bit - you need `new val create()` in the interface
<shepheb> that... is odd.
<shepheb> that worked, but I'm a little puzzled. I guess that's just a bit of a workaround to get interfaces and primitives playing nice?
<jemc> well, whenever you invoke a primitive, it does `create` it, but that will just return a global constant pointer
<shepheb> oh, I see.
<SeanTAllen> there's only ever 1 copy of a primitive
<jemc> and LLVM presumably inlines that into something nice and efficient
<SeanTAllen> thus the lack of state and fields
<SeanTAllen> if you have a class that has no state, turn it into a primitive, better perf, less memory.
copy` has joined #ponylang
<shepheb> I'm getting "not enough arguments" from if _payload is Request then
<shepheb> I thought that was a valid use of "is"
<SeanTAllen> is Request a primitive?
<SeanTAllen> `is` checks identity
<SeanTAllen> so if you do if foo is SomeClass then
<SeanTAllen> it is instantiating an instance of SomeClass and seeing if foo is that instance, which it will never be
<SeanTAllen> unless it is something like if foo is SomePrimitive then
<SeanTAllen> in which case it will match
<SeanTAllen> like
<SeanTAllen> if foo is None then
<SeanTAllen> for SomeClass, you need a match statement.
<shepheb> oh, I see.
<Applejack_> Hi, I'm implementing the Julia micro benchmarks in Pony, and wondering if the equivalent of @timeit Julia macro can be written, which basically takes a function as argument with its arguments too and loops a few times to find the best performance time. More generally, can I pass a function to a function?
<shepheb> I had just discovered that I can do match _payload | let a: Request iso! => ...
<shepheb> SeanTAllen: thanks
<SeanTAllen> you're welcome.
<SeanTAllen> Applejack_: yes, you can pass functions to functions. check out lambda and object literals in the tutorial
<SeanTAllen> shepheb: why iso! ?
<SeanTAllen> thats an alias to an iso which i've never found was what i actually wanted.
<shepheb> I don't actually need to use it.
<shepheb> I'm purely checking the type, since handling requests is different from handling responses.
<shepheb> maybe it would be better to add that as another method on the Strategy
<shepheb> expect_body(): Bool
<jemc> shepheb: then you can leave out the `let`
<shepheb> I tried | Request and got errors.
<jemc> hm
<shepheb> somewhat to my own surprise I got this refactored HTTP library to compile. much testing to be done.
<SeanTAllen> congrats shepheb
<jemc> shepheb: yeah, I was wrong - if you leave off the `let` it sees `Request` as an value (and tries to instantiate it) instead of seeing it as a type to compare
<jemc> I guess that needing to match on type, but not needing the refined reference is a rare enough use case that I forgot this
<shepheb> it's harmless enough
<shepheb> what's more surprising is that let _: Request iso! => didn't work
<jemc> yeah, that one probably should work - could open a ticket about it
<shepheb> it seems like an explicit don't-care _ is better than choosing a symbol I'm not using elsewhere
<shepheb> okay, let me do that.
Applejack_ has quit [Ping timeout: 250 seconds]
<SeanTAllen> shepheb: what are you doing after you match on the type?
<SeanTAllen> i'm unclear why you wouldn't need the variable
<shepheb> I agree it's obscure. the value can be either a Request or a Resopnse, and I need to know which in order to set up some other values properly.
<shepheb> but I don't need the Response itself in order to do that.
<shepheb> I wasn't surprised that | Response => didn't work, but I was surprised that | let _: Response => didn't.
<SeanTAllen> if i remember correctly, _ is really only intended for matching tuples at the moment
<shepheb> it's surprisingly hard to clone or iterate-and-print an Array[Foo] iso
<jemc> what's the cap of Foo?
<shepheb> I eventually sorted it by realizing that I wanted to print after the last edit, so I did let list': Array[Foo] val = consume list and printed that.
mcguire has joined #ponylang
<shepheb> which is a long way of saying "I don't know Foo's cap, I wasn't forced to think about it."
<shepheb> surprisngly close with the HTTP stuff. it's parsing the request (with body) correctly, and assembling the response correctly, but then the client (curl) gets an empty resonse from the server, maybe because the connection is closed too early.
trapped has quit [Read error: Connection reset by peer]
_andre has quit [Quit: leaving]
SilverKey has quit [Quit: Halted.]
SilverKey has joined #ponylang
ashish01 has joined #ponylang
mcguire has quit [Ping timeout: 276 seconds]
<SeanTAllen> jemc: ill update contributing to account for RFC process in the next day and issue a PR
Matthias247 has joined #ponylang
SilverKey has quit [Quit: Halted.]
jemc has quit [Ping timeout: 250 seconds]
aturley has quit [Ping timeout: 244 seconds]
aturley has joined #ponylang
aturley has quit [Ping timeout: 264 seconds]
<SeanTAllen> jemc: what if we start each sync meeting with the play of a Shaggs song?
Dani_ has joined #ponylang
<Dani_> Hello everyone ! I have a question about some code I was trying out and doesn't work
fefee33 has joined #ponylang
<Dani_> I was copying the "case_fact" example in the tutorial. And tried it out with fact_case(-2)
<Dani_> and it gives me Segmentation fault :( it doesn't enter the "else" statement of the try
<SeanTAllen> Dani_: can you post a gist of your code?
<Dani_> gad
<Dani_> sorry, I'll sent a pastebin
<SeanTAllen> thanks
aturley has joined #ponylang
<SeanTAllen> i think this is something we'd really want dependent types for or to change fac_case to not accept negative numbers
<SeanTAllen> i think you are blowing the stack out
<SeanTAllen> that is going to recursive infinitely assuming infinite resources
aturley has quit [Ping timeout: 240 seconds]
unbalancedparen has quit [Quit: WeeChat 1.5]
<SeanTAllen> Dani_: ^^
<Dani_> Right, I think that too. But isn't that why we need to cast fact_case(n -1) as U64?
<SeanTAllen> I'm not sure I follow...
<Dani_> in fact_case(0) everything is fine. but in fact_case(n) for it to compile I had to cast face_case(n-1) to U64
<Dani_> I thought that was because the compiler couldn't make sure that that call would reach the base case
<SeanTAllen> it being a U64 doesnt guarantee base case is reached
<Dani_> So then why do I need to cast it, if in the definition of the function I already state what value it returns?
<SeanTAllen> because the return type is U64 ?
<SeanTAllen> ie not guarnteed to be a U64
<SeanTAllen> i think
<SeanTAllen> i need to poke at this more
<SeanTAllen> i havent done much with case functions
<SeanTAllen> they compile down to match statements
<SeanTAllen> its a fairly unused feature so far
<Dani_> Okay, thanks Sean anyway
<Dani_> I'm also haven't done much and I was just trying out a few things
<SeanTAllen> if you remove the U64, you will see that it thinks the return type is U64 or None
<SeanTAllen> i'm assuming that is because of the match it compiles down to because...
<Dani_> Sorry, I'm not following
<SeanTAllen> nvm i was wrong,
<Dani_> The fact_case(n: U64) wouldn't be the default case?
<SeanTAllen> more try, less talk from me would be good
ob_ has joined #ponylang
<SeanTAllen> no
<SeanTAllen> its only a default case if you are doing positive numerbs
<SeanTAllen> if you start below 0, you never hit that
<Dani_> I think you hit that, but it enters an inifinite recursion
<SeanTAllen> how would you hit the (0) case?
<Dani_> nono, the (n) case I mean
<Dani_> I was thinking about this you said "i'm assuming that is because of the match it compiles down to because..."
<Dani_> If it would translate it to "case 0: return 1, default: n * fact_case(n-1)"
<Dani_> or maybe "case 0: return 1, case U64: n * fact_case(n-1) default None" or something of the sort
<Dani_> Becasue if not it doesn't make sense to have to cast the result to U64
<SeanTAllen> yeah it has to do with the match statement this compiles down to.
<SeanTAllen> the match statement that gets created can return a U64 or a None
<Dani_> I don't think it should be like that :(
<SeanTAllen> So this is the fundamental issue:
<SeanTAllen> that said, i think this is something that could be improved
<SeanTAllen> if people started using case functions, i think they would get a lot more love. as it is, they aren't used anywhere in the standard lib
<Dani_> Right. I think they are great, but not very known.
Matthias247 has quit [Read error: Connection reset by peer]
<Dani_> It would be nice to avoid the unnecessary cast
<Dani_> And it would be great if there was a way to convert the stack overflow to an exception
<Dani_> Okay, but thanks very much Sean
<SeanTAllen> you're welcome
gsteed has quit [Quit: Leaving]
SilverKey has joined #ponylang
aturley has joined #ponylang
aturley has quit [Ping timeout: 260 seconds]
pulpfiction has joined #ponylang
SilverKey has quit [Quit: Halted.]
aturley has joined #ponylang
aturley has quit [Ping timeout: 260 seconds]