<autodidaddict>
really dumb question.. how do I do an "is not" ?
<autodidaddict>
e.g. "if id is not None"
<autodidaddict>
arg. nvm. needed parens
* autodidaddict
facepalms
<plietar_>
autodidaddict: `if id isnt None`
<autodidaddict>
isnt is a keyword? nice
<autodidaddict>
of course now I'm having trouble setting a value in a JSONDoc
<autodidaddict>
refcaps, obviously
Candle has quit [Ping timeout: 255 seconds]
<autodidaddict>
trying to convert fields that are ref into vals so I can add them to a map
* autodidaddict
pulls out his last remaining hair follicle
<doublec>
autodidaddict: that part of the JSON library is thorny
<autodidaddict>
I'm just calling from_map
<doublec>
autodidaddict: the irc logs are littered with the remains of people usin git
<autodidaddict>
I'm running into the refcaps issue with simple things like `mymap("data") = foofield`
<doublec>
( I jest, it's not too bad)
<autodidaddict>
I'm getting the "ref is not a subtype of val" stuff
<doublec>
autodidaddict: viewtype adaption is important here
<autodidaddict>
yeah, it was last time I had this problem and couldn't figure it out :D
<doublec>
autodidaddict: the refcap of the map, vs the refcap of the map internal to the JSONDoc etc
<autodidaddict>
I'm not even using jsondoc yet
<autodidaddict>
I simply can't set mymap(foo)
<doublec>
autodidaddict: if you can paste some code, or show the refcap of the map, the elements in the map and the thing you are assiging too I can try to help
<autodidaddict>
let result : JsonType
<autodidaddict>
dmap("result") = result
<autodidaddict>
that doesn't work
<autodidaddict>
the let result is a field
Candle has joined #ponylang
<doublec>
What is dmap?
<autodidaddict>
var dmap: Map[String, JsonType] = Map[String, JsonType]
* doublec
looks at json code
<autodidaddict>
that's the type that JsonObject expects for its from_map
<autodidaddict>
JsonType is a big union
<autodidaddict>
my problem is my fields are ref and I need to put a value into my map
<autodidaddict>
er, val
<doublec>
autodidaddict: what's the error you are getting?
<doublec>
I should feed some of that back into the tutorial
<doublec>
Your example is a good one too
<doublec>
because of your "I'm not modifying it why does it need to be ref" intuition
<doublec>
So the thing to be aware of, if you are accessing a 'ref' field, and you want to use it as a 'ref' field, your method needs to be ref.
<doublec>
Otherwise you could access a ref field and store it somewhere giving a writeable alias from a method that is supposed to never allow writing to the object.
<autodidaddict>
I submitted a PR for proper capitalization ;)
<SeanTAllen>
ha
<SeanTAllen>
yes
<SeanTAllen>
which is sadly a breaking change
<SeanTAllen>
but a good change
<autodidaddict>
better to break style stuff at 0.16.x instead of 1.16.x
<doublec>
I do like that non-all case allows reading names that are multiple acronums easier to read
<doublec>
JsonCom vs JSONCOM
<autodidaddict>
yeah, but `JsonObject` is flagged as bad style in 3 different languages ;)
<doublec>
yeah, I lose this war wherever I go :)
<SeanTAllen>
autodidaddict: yes
<SeanTAllen>
SO
<SeanTAllen>
from looking around the standard library
<autodidaddict>
btw, my tests pass again :D
<SeanTAllen>
i have no idea why those JSON constructors all return isp
<SeanTAllen>
uso
<SeanTAllen>
iso
<SeanTAllen>
god damn it
<SeanTAllen>
did i mention im tired
<SeanTAllen>
autodidaddict: if you find yourself always wanting a ref from the constructor, we can do an RFC to make the change
<SeanTAllen>
i start all constructors as
<SeanTAllen>
new create()
<SeanTAllen>
and only change to
<SeanTAllen>
new iso create()
<SeanTAllen>
if its always/almost always used as an iso
<autodidaddict>
I never do "new iso create()"
<SeanTAllen>
well
<SeanTAllen>
you will
<autodidaddict>
mostly because I have no idea why I would ;)
<SeanTAllen>
if you start doing the "notify pattern"
<SeanTAllen>
so you did a little socket programming so far right?
<autodidaddict>
I've learned one pattern, that's enough. Everything else hurts.
<SeanTAllen>
and had to set up a notify object to pass to listen
<autodidaddict>
yes i've done sockets
<SeanTAllen>
the notify like
<SeanTAllen>
TCPConnectionNotify
<SeanTAllen>
is
<SeanTAllen>
new iso create()
<SeanTAllen>
because when you create one, you want an iso to give to TCPConnection
<SeanTAllen>
so all those notify classes are rightly
<SeanTAllen>
new iso create()
<autodidaddict>
why do you want to give an iso to TCPConnection ?
<SeanTAllen>
because its a class
<SeanTAllen>
and TCPConnection will call it synchronously
<SeanTAllen>
which will call user code
<SeanTAllen>
that might update state
<autodidaddict>
that doesn't help
<SeanTAllen>
which means it needs to be iso
<autodidaddict>
why iso? why not another refcap?
<SeanTAllen>
TCPConnection is an actor
<SeanTAllen>
there is only one mutable ref cap you can send to an actor
<SeanTAllen>
that is `iso`
<SeanTAllen>
that is why they are iso
<autodidaddict>
why does a notifier need to be mutable?
<SeanTAllen>
the notifier is a user supplied callback
<SeanTAllen>
where you might want to do things like
<doublec>
buffering for example
<SeanTAllen>
record number of packets processed
<SeanTAllen>
or buffer things
<SeanTAllen>
or for a framed protocol, keep track of whether you are in the header or the body
<doublec>
buferring data until you have a line, then it sends the line to a line notifier. That buffers data until it has a valid message then sends onto a message notifier, etc.
<autodidaddict>
I'm gonna switch to Go for the rest of the night. At least I can write more than 6 lines an hour there
<SeanTAllen>
:(
<SeanTAllen>
god speed!
<doublec>
autodidaddict: any thoughts you have on improving the learning docs appreciated!
<autodidaddict>
I've been thinking about it. I'll jot some notes down once my compiler rage has subsided
jemc has quit [Ping timeout: 255 seconds]
https_GK1wmSU has joined #ponylang
https_GK1wmSU has left #ponylang [#ponylang]
<doublec>
hmm, actor@ and compilation to C seems to be broken on my system
<SeanTAllen>
the pony type system has a proof showing its soundness
<SeanTAllen>
but in the context of that
<SeanTAllen>
they talk about formal verification as one of the topics
<SeanTAllen>
and about garbage collection in general
<SeanTAllen>
and about Pony's design
<emilbayes>
SeanTAllen: Ah ok! Have been watching a lot of pony talks about the philosophy over the last two days and Sylvan keeps emphasizing that there is not yet a formal verification but that the type system and gc is formally specified :)
<Praetonus>
emilbayes: I think he means that the type system and GC are sound but that the actual implementation isn't formally verified
<SeanTAllen>
yes
<emilbayes>
ah ok! He mentions a "Hand proof" of the type system in the MS Research talk too
<jemc>
autodidaddict: the error message says "right side must be a subtype of left side", and the extended info says "Response val is not a subtype of Response ref: val is not a subcap of ref"
<autodidaddict>
yep. I see that error message all day every day
<autodidaddict>
and nothing about it helps me fix the problem :(
<jemc>
your line looks like: `let r: Response = recover val Response(...) end`
<jemc>
it should be `let r: Response val = recover val Response(...) end`
<autodidaddict>
yeah that wouldn't compile before either. I usually try 100-200 permutations of random troubleshooting before using this chat
<autodidaddict>
annnnd now the function I fixed last night by making it a ref fails
<autodidaddict>
FFS
<jemc>
I can only help with the errors you show me - the change I suggested will fix that particular error, but I can't guarantee there aren't other errors in your application
<autodidaddict>
the tests were all passing last night
<autodidaddict>
now that I fixed this one thing, it made my tests from last night not compile
<jemc>
autodidaddict: that error message is telling you that `to_jsonobject` is a `fun ref`, and you're trying to call it on a `val` reference, which is not allowed
<autodidaddict>
yes that's what I just said
<autodidaddict>
sorta
<jemc>
in other words, it's telling you that you're trying to call a mutation method on an immutable reference (`Error val`)
<autodidaddict>
I made that function a "fun ref" last night, and that fixed all the problems I had last night
<autodidaddict>
no clue how to fix this one
<autodidaddict>
I guess I want to make "e" a ref just long enough to call to_jsonobject on it
<SeanTAllen>
i think i see the root of your problem autodidaddict
<autodidaddict>
I did about 20 minutes ago on one of my many fruitless attempts
<autodidaddict>
so what's the root of the problem?
<SeanTAllen>
well im not sure
<SeanTAllen>
so in Error
<SeanTAllen>
this JsonType that is the data field
<SeanTAllen>
what's the purpose of that?
<SeanTAllen>
should that be mutable or immutable?
<autodidaddict>
it's an arbitrary value that I need to potentially pass back to a JSON-RPC 2.0 client. it's part of the spec
<autodidaddict>
immutable, like everything else
<SeanTAllen>
i officially hate these Json classes
<autodidaddict>
I match on an error val .. so I need to either make error a val (which I can't, because as I discovered last night, I can't manipulate maps from inside a fucntion without it being a ref)
<autodidaddict>
the json classes are not causing my problems
<autodidaddict>
I match an error val, and I need to invoke a method on an error ref.. so how do I temporarily get an error ref to call that function ?
<SeanTAllen>
autodidaddict: this isnt true " (which I can't, because as I discovered last night, I can't manipulate maps from inside a fucntion without it being a ref)"
<SeanTAllen>
you made the to_jsonobject a fun ref last night right?
<autodidaddict>
yes
<SeanTAllen>
right
<SeanTAllen>
that wasnt because you need it to manipulate the map
<SeanTAllen>
the problem is not with manipulating a map
<SeanTAllen>
thats a local variable
<SeanTAllen>
the problem is the JsonType field
<autodidaddict>
yeah that's what mine looks like now and it creates that giant pile of errors
<autodidaddict>
compiles when I comment out the ob.data("data")
<autodidaddict>
... so how does one fix thaT?
<SeanTAllen>
well its complaining about JsonArray which is one of the types in the JsonType union
<SeanTAllen>
im looking at that at the moment
<autodidaddict>
it smells like some of the types in the union are ref and others aren't
<autodidaddict>
but I don't know what I'm doing
<SeanTAllen>
no that is exactly what it is
<SeanTAllen>
im really unsure why this is the way it is
<SeanTAllen>
jemc: any idea why JsonType has "String val" but then "JsonObject ref" and "JsonArray ref" ?
<autodidaddict>
JsonObject and JsonArray are both mutable. One holds a map inside the other holds an array
<autodidaddict>
the JsonXXX types each have a `data` field
<SeanTAllen>
something something i really dislike this API
<autodidaddict>
and the data field is either a map or the array
<autodidaddict>
I can't recover a JsonType into a val in that function... so I don't know how to set that output field
<SeanTAllen>
so looking at this api
<SeanTAllen>
it seems like this was done entirely to build up json
<jemc>
SeanTAllen: I'm on the same page with you - the API is inconvenient in practice
<SeanTAllen>
autodidaddict: i think you are mostly experiencing pain with an API that doesnt meet your needs
<SeanTAllen>
im looking at this and going "wtf"
<SeanTAllen>
so ok,
<SeanTAllen>
autodidaddict:
<SeanTAllen>
when you turn an error into a json object
<SeanTAllen>
do you really want a mutable json type for your "data" field or do you want a string?
<jemc>
when this subject has come up in the past, I've been of the opinion that in a language like Pony, JSON parsing should probably take place in a collaborative/tokenized context, rather than deeply parsing the entire structure
<autodidaddict>
it needs to be arbitrary. I don't care about mutable
<SeanTAllen>
what does "it needs to be arbitrary" mean?
<autodidaddict>
the JSON RPC 2.0 spec allows for the "data" field on the "error" object to be primitive or structured
<autodidaddict>
it can be 12, "12", "foo", or ["foo", "bar"]
<SeanTAllen>
right but...
<SeanTAllen>
by the time we are here
<SeanTAllen>
it would be the string representation of that, yes?
<autodidaddict>
someone else would've had this library written in 12 seconds
<autodidaddict>
getting an error saying I can't recover to that capability (val)
<autodidaddict>
so I can't make this Request ref a val in order to send it to the dispatcher
<endformationage>
SeanTAllen said reagarding a book: 'i would start with data sharing and concurrency'
<endformationage>
^ I've learned more about the isues/problems around sharing/concurrency from pony than from all my previous encounters in other languages.
<autodidaddict>
still can't figure out how to make this ref a val.
<Candle>
I used the json API for a recent minor task; it's pain was similar to using the basic Java json API; the org.json packages.
<autodidaddict>
again, the problem I ran into now isn't json
<autodidaddict>
trying to send an instance of my class to my actor
Matthias247 has quit [Read error: Connection reset by peer]
<SeanTAllen>
you cant make a ref a val.
<SeanTAllen>
ever.
<SeanTAllen>
that is 99% true as a statement
<SeanTAllen>
the only time you can
<SeanTAllen>
is a ref that is coming out of a recover block
<SeanTAllen>
Candle: if you have thoughts on a good pony json api, id love to hear them
<SeanTAllen>
folks who are the early explorers can hopefully drive some much needed improvements
<autodidaddict>
so the thing I want to do is physically impossible?
<endformationage>
at it's birth, so to say
<autodidaddict>
i made my Request class a val
<autodidaddict>
... which then generates a compiler error _in the stdlib_ and not in my code
<autodidaddict>
:(
<SeanTAllen>
i think you want it to be a val autodidaddict
<SeanTAllen>
thats a good thing
<autodidaddict>
yeah, but _nothing compiles_
<autodidaddict>
it doesn't even tell me what line of code is causing the problem
<endformationage>
doublec: Great new article btw, much appreciated. Helped me understand viewpoint adaptation and subtyping a bit more!
<SeanTAllen>
well taht is a bad error message
<SeanTAllen>
jfc
<SeanTAllen>
i hate the json package
<SeanTAllen>
so autodidaddict its complaining in a very poor way about the params field of Request
<SeanTAllen>
and JsonType maybe being mutable
<autodidaddict>
ugh. it never even flagged that field
<autodidaddict>
in an error message
<autodidaddict>
what's the workaround/fix?
<SeanTAllen>
my flippant answer is write a new json library
<SeanTAllen>
working on the non-flippant answer
<autodidaddict>
my flippant reply: Because this has been so much fun up until this point?
<autodidaddict>
If I thought I could do it without murder, I'd write a new JSON library myself. But, my current average is no more than 6 new lines of code per indecipherable refcap fail
<SeanTAllen>
ok non flippant answer
<SeanTAllen>
`
<SeanTAllen>
type JsonType is (F64 | I64 | Bool | None | String | JsonArray | JsonObject)
<SeanTAllen>
`
<SeanTAllen>
i don't know how to get around JsonArray and JsonObject being ref without massive amounts of trouble
<SeanTAllen>
I dont see how JsonType is useful outside of the Json package itself
<SeanTAllen>
i think
<autodidaddict>
we don't even have a serializer
<SeanTAllen>
someone could try and work around this
katafrakt[m] has quit [Quit: idle]
<SeanTAllen>
i think their time would be better spent making a better api
<SeanTAllen>
jemc has worked with this API i think
<SeanTAllen>
he might have some better suggestions than me
<SeanTAllen>
i would have to spend a good amount of time looking at this
<SeanTAllen>
at the moment i don't have that time
<SeanTAllen>
sorry autodidaddict
<autodidaddict>
not your fault
<SeanTAllen>
i know this is frustrating
<autodidaddict>
I only had my lunch hour to look at this ;)
<SeanTAllen>
i am frustrated because i know you are trying to get a language server protocol server working
<SeanTAllen>
which would be a huge boon the the community
<SeanTAllen>
jemc has put thought into how a json api could work well in Pony
<SeanTAllen>
i think we should get feedback from him and step 1 is a json librarty
<SeanTAllen>
which i can help you with
<SeanTAllen>
we can do a repo and you can make me a collaborator and i can work on it with you
<SeanTAllen>
if you are up to it (although i have many competing concerns on my time)
<jemc>
the summary is that I think that a more useful JSON parsing library would be a tokenizing "cursor" into the JSON data
<jemc>
which could be a persistent data structure, lazily loaded instead of eagerly
<jemc>
how this new parsing API would relate to a JSON *writer* is a bit more complicated of a question
<autodidaddict>
hopefully more fun than the tokenizing cursors used for XQuery/XPath traverals from back in the day
<autodidaddict>
those APIs were awful
<jemc>
I don't think a string-based path traversal like xpath would be very idiomatic in Pony - we'd want to stick to API patterns that can be statically typechecked
<autodidaddict>
of course we're all spoiled. We can just create structs in Go, annotate the fields, and serialize an entire graph
<autodidaddict>
I haven't used a low-level json object API in at least 18 months
<jemc>
this is one of the main places where I think Pony needs macros
<jemc>
but for now, those needs can be fulfilled (somewhat clumsily) with code generation
<autodidaddict>
yeah the Rust serialization macros / libraries (e.g. serde) are very powerful
<jemc>
that kind of feature is actually one of my most important goals (as I see it) with working on ponycc (the pony compiler in pony)
<SeanTAllen>
i use "while" loops so often i had to go look up the syntax just to make sure
<autodidaddict>
The cursor would have to have some kind of controller on top to allow people to refer to things as simple key-value pairs like regular JSON libraries. Forcing everyone to move the cursor forward manually would be a stretch
<autodidaddict>
and you'd have to avoid the performance hit of re-scanning from the beginning each time someone wants to pull a given key off a level in the tree
ta3ta1 has joined #ponylang
<ta3ta1>
Hi, I see your struggle about json-rpc library from public logs
<autodidaddict>
ta3ta1: thanks for all the input.. this cleared up a bunch of stuff. I still can't set the data field on an error without massive compilation failure, but that's okay
plietar has quit [Remote host closed the connection]
plietar has joined #ponylang
<SeanTAllen>
jemc: you around
<SeanTAllen>
?
<jemc>
SeanTAllen: yeah, around, though not undivided :D
<SeanTAllen>
ill try you later when you are undivided if i havent reached a conclusion by then
samuell has quit [Quit: Leaving]
<SeanTAllen>
ooo sylvan is home, im going that route for a duck/bouncer
<jemc>
okay, so the error is telling you that your lambda has the wrong signature, and it's telling you the ways in which it's wrong
<jemc>
for one part, the lambda needs to have an `iso` object cap rather than `ref` - you can accomplish this by putting `iso` after the closing `}` of the lambda
<jemc>
that's what this message is telling you: "{(Promise[Response val]): None} ref is not a subtype of Fulfill[Response val, None val] iso: ref is not a subcap of iso"
<jemc>
the other problem is that your parameter signature is wrong - you're accepting a `Promise[Response val]` param, but you should be accepting a `Response val` param
<jemc>
that's what this message is telling you: "parameter Promise[Response val] tag is not a supertype of Response val"
<jemc>
note that once I finish implementing this RFC both of those pieces could be omitted/inferred
<autodidaddict>
I can do h.fail in either the pass or fail branch of the promise and the test passes
_andre has quit [Quit: leaving]
<jemc>
are you using the `long_test` feature of the test suite, to mark that your test is not synchronous?
<jemc>
if you don't mark it as a "long test" (an asynchronous test), the test suite will count it as passed if it has no failures when the function returns
<jemc>
so you have to mark it as a "long test", and you have to mark it as "complete" when you receive fulfillment of the promise
<jemc>
otherwise the test suite has no way of knowing that you're still waiting for something
<autodidaddict>
the docs for long_test are nearly non-existent
<autodidaddict>
the testing part of the tutorial doesn't even give me the method signature
<autodidaddict>
`fun long_test(timeout: U64)`
<autodidaddict>
what unit is timeout? seconds? milliseconds?
<autodidaddict>
nanos?
<autodidaddict>
added a timeout, my test is now deterministic
<autodidaddict>
this is, imho, ugly code. And it'll very easily fail the "6 month smell" test.. (work on a different project for 6 months, come back... can you actually read the code you wrote?)
<SeanTAllen>
autodidaddict: nanos
<autodidaddict>
upside is if you want to build a json rpc 2.0 server you can
<SeanTAllen>
note the last line in the method:
<SeanTAllen>
```
<SeanTAllen>
The timeout is specified in nanseconds.
<autodidaddict>
I didn't pull up the source code
<SeanTAllen>
did that not make it into the stdlib docs?
<autodidaddict>
searching stdlib is like the "I feel lucky" button on Google
<SeanTAllen>
autodidaddict: nice on the build the server
<SeanTAllen>
if you have suggestions for improvement, a couple folks are working on those
<autodidaddict>
SeanTAllen: meh. Nobody's going to use it
<SeanTAllen>
i put a lot of work into getting them into the state that they are
<SeanTAllen>
so "i feel lucky" is somewhat insulting
<SeanTAllen>
there are other people on the end of your frustration
<SeanTAllen>
please keep that in mind
<autodidaddict>
I'm not insulting anyone. I've built docs using those template generators before, so I know how limited they are.
<autodidaddict>
and the docs are by no means a reflection of anyone here
<autodidaddict>
if there is frustration, it's at the suckiness of the overall state of static site generators
<autodidaddict>
the gitbook search is marginally better than the ones you get with stuff like hugo, etc
<autodidaddict>
the biggest issue with search is if you search for a fairly common function name, you get 500 results and cannot differentiate them - the index doesn't contain the class/trait/actor etc
<autodidaddict>
when you search Godocs for something common like "Find":