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 | Please consider participating in our mailing lists => https://pony.groups.io/g/pony
maarek has joined #ponylang
maarek has quit [Remote host closed the connection]
maarek has joined #ponylang
<maarek> Does a union type not satisfy equitable/hashable for collections.Set?
<SeanTAllen> I'm not sure I understand
<SeanTAllen> Do all the members of the union in question satisfy equatable?
<SeanTAllen> Do you have a small example you can supply?
<maarek> use mut = "collections"
<maarek> use "collections/persistent"
<maarek> type MyType is (I64 | F64 | Bool)
<maarek> actor Main
<maarek> new create(env: Env) =>
<maarek> let set: mut.Set[MyType] = mut.Set[MyType]
<maarek> set.set(I64(123))
<maarek> set.set(true)
<maarek> if set.contains(I64(123)) then
<maarek> env.out.print("true")
<maarek> else
<maarek> env.out.print("false")
<maarek> end
<maarek> Sorry if that pasted horribly. Been a while since I've been on IRC>
<SeanTAllen> sorry that is hard to follow, can you use the playground? https://playground.ponylang.io/
<maarek> Yep
<SeanTAllen> then send a link to your particular one
<SeanTAllen> thanks
<maarek> Opps
<maarek> I am just off today it seems.
<SeanTAllen> you need to do share
<SeanTAllen> then "permalink link"
<SeanTAllen> a right so, the error you are getting is that not all members of that union are equatable to each other
<SeanTAllen> therefore its an error
<SeanTAllen> because you are saying that it could be I64 and F64 both
<SeanTAllen> (for example)
<SeanTAllen> and you can't compare then to one another
<maarek> Oh, I guess that makes sense.
<maarek> Would SetIs work in this case?
<maarek> I can just try it.
<maarek> What does the Is stand for in SetIs?
<SeanTAllen> you'll have the same problem
<SeanTAllen> SetIs is doing a comparison based on identity rather than value
<SeanTAllen> So for example if you created two instances of String that where Fred
<SeanTAllen> if you did SetIs, both could be in the set because its identity based
<SeanTAllen> whereas with a normal Set, you'd only have 1 because both Strings have the same value
<maarek> Ahh
<SeanTAllen> hashable.pony in the stdlib has HashIs primitive that it all boils down to, you can have a look at it if you want.
<SeanTAllen> that's the eq method for HashIs
<SeanTAllen> and SetIs uses HashIs for its HashFunction
<maarek> I was digging through it. I was caught up more on Hashable than Equitable. But it all makes sense now.
<maarek> When I look at I64 in the builtins, it doesn't look like it's explicity Hashable. But it does have the hash function. Is Hashable inferred then?
<SeanTAllen> Its using structural typing for that
<SeanTAllen> So...
<SeanTAllen> to be Hashable, you have to implement that interface
<maarek> Ahh okay. Awesome.
<SeanTAllen> right now Pony has Traits that are nominal subtyping and Interfaces that are structural. Sylvan and I have reached the point where we think that was a mistake to have both and one of us will be opening an RFC eventually to switch only to Interfaces and structural.
<SeanTAllen> It's a point of confusion for people learning Pony.
<maarek> Well it makes sense now.
<SeanTAllen> Good good
<SeanTAllen> Feel free to ask any other questions you have as they come about
<maarek> Yeah, I'm learning by implementing an EDN (https://github.com/edn-format/edn) parser in Pony based on the current json parser. Just sort of deconstucting and fitting the pieces together as a small project.
<maarek> I'll need to dig into how to handle Sets with uncomparable types. I wonder how OCaml does it.
<SeanTAllen> Cool
<SeanTAllen> The Pony json parser isn't the best. Feel free to deviate from it.
<SeanTAllen> There's a couple Peg parser libraries if that is more your thing.
<maarek> I'll check them out. Since I was just picking this up, the json library was easy enough to understand and take each piece one at a time, see what I hit.
<SeanTAllen> ya
<SeanTAllen> that makes sense
<maarek> I was trying to figure out how best to print out a map in lldb the other day if you had a snippet.
<maarek> I've been spoiled when it comes to debugging for a long time now.
maarek has quit [Remote host closed the connection]
<SeanTAllen> have you seen the lldb cheatsheet maarek?
acarrico has quit [Ping timeout: 272 seconds]
acarrico has joined #ponylang
acarrico has quit [Ping timeout: 240 seconds]
dx_ob has joined #ponylang
Nawab has quit [Ping timeout: 250 seconds]
acarrico has joined #ponylang
svdvonde has joined #ponylang
<svdvonde> Hi. I have a question about traits. Consider the situation described in this code snippet: https://playground.ponylang.io/?gist=bc2af6d2fa6e6e87514d41cb9050abb2 ;; Here T1 requires a behaviour but does not implement it. Instead the default implementation of a behaviour should be given by T2. How would I implement this correctly? Is it possible?
<vaninwagen> svdvonde This could be considered a bug, i am not 100% sure, though
<vaninwagen> What about: trait T2 is T1 ?
<vaninwagen> Is that possible in your case, because that compiles
<vaninwagen> And then you do: actor Example is T2
<svdvonde> That is indeed a practical solution, but I'm more interested in the the trait mechanism adopted by pony (and other actor-based languages). Later today I will open an issue on Github, because considering the literature on traits this does not seem like expected behaviour (unless there is a reason specific to Pony)
<SeanTAllen> svdvonde, just a note on that. Sylvan and I are going to be opening an RFC to remove traits from the language and only have structural typing via interfaces. However, the two are almost identical in most respects at the moment except for the structural vs nominal typing differences so any issue with one would probably be an issue with another
<vaninwagen> SeanTAllen: max i ask why you wanna remove traits?
<SeanTAllen> @vaninwagen i dont think that is a bug.
<vaninwagen> svdvonde: do you get the same error with fun instead of be?
<SeanTAllen> there are two definitons of collect, saying "o we should use the one with the default implementation is in my mind wrong."
<SeanTAllen> vaninwagen: because they are almost identical. nominal typing provides little value (you can get most of that from using `is` with an interface) and the existence of both is very confusing to people just starting out
<SeanTAllen> anyway
<SeanTAllen> im off to do stuff with my family
<vaninwagen> Have fun
svdvonde has quit [Ping timeout: 256 seconds]
maarek has joined #ponylang
maarek has quit [Remote host closed the connection]
svdvonde has joined #ponylang
<svdvonde> SeanTAllen That's very interesting to know, and it is honestly not that surprising. As far as I can tell traits in Pony lack some of the essential features of traits (off the top of my head, method exclusion and renaming), so I was wondering if these features were simply not documented, or missing entirely.
<SeanTAllen> Sylvan and I have been discussing something like mixins which there will probably be an RFC for once we work out more details
<vaninwagen> SeanTAllen: very much looking forward to it
<vaninwagen> svdvonde: can you elaborate on what you expect from traits or what the canonical understanding of traits is (asking for a friend)
<SeanTAllen> vaninwagen: it's part of the "extending actors" problem that Sylvan and I have been working on
<vaninwagen> The state machine thingy?
<SeanTAllen> There's a few papers vaninwagen. Here's one traits paper (pdf)
<SeanTAllen> vaninwagen: that's different
<SeanTAllen> Damn it
<SeanTAllen> And
<SeanTAllen> Amongst others
<svdvonde> I concur.
<svdvonde> SeanTAllen: can you elaborate a bit on the "extending actors" you mentioned? I presume you are talking about code reusability mechanisms that are suitable for specifying actors
<SeanTAllen> svdvonde: yes
<SeanTAllen> So...m
<svdvonde> Or if you can recall any particular moment in the IRC logs that you can point me to :-)
<vaninwagen> Thanks for the pointers SeanTAllen !
<SeanTAllen> There's no way to take something like TCPConnection and add additional functionality. More important, there's no way to take the notify class that specializes it and send it messages which is very limiting. Sylvan and I have been trying out solutions to that and have the basic idea for one that looks a bit like mixins and a bit like a feature we removed from pony a couple years back called delegates.
<SeanTAllen> There's still some issues to work out though
<SeanTAllen> There's a few bigger, deeper issues that Sylvan and I have been discussing a lot. That's one of them.
<svdvonde> Interesting you say that. I happen to be interested in the same problem, but from an entirely different angle and context. Hence my interest in how pony handles traits. An idea I'm currently exploring is based on delegation (as in, delegation in prototype-based OO languages)
<SeanTAllen> I'd love to hear your thoughts. Got anything written up?
<svdvonde> Although I think we are thinking about different problems. I am thinking about specifying the interface or behaviour of an actor out of many individual parts (like traits), whereas I think you are talking about delegating messages from 1 actor to another -- which might be a good approach when the overhead of creating new actors is negligible
<svdvonde> Unfortunately nothing written up
svdvonde has quit [Quit: Page closed]
<_andre> so, there are methods like insert_if_absent() in HashMap that can't actually fail, but are forced to be marked with '?'
<_andre> are there any ideas for a way to prevent this?
<_andre> in the case of insert_if_absent it's because it calls apply(), which can fail, but it's called only for a key that is know to be present in the map
<SeanTAllen> No. There's no way to prove that to the compiler at this time.
acarrico has quit [Ping timeout: 260 seconds]
alxs has joined #ponylang
alxs has quit [Read error: Connection reset by peer]
alxs has joined #ponylang
alxs has quit [Quit: Computer's gone to sleep. ZZZzzz…]
dx_ob has quit [Read error: Connection reset by peer]