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
alxs has joined #ponylang
alxs has quit [Quit: Computer's gone to sleep. ZZZzzz…]
rkallos has joined #ponylang
_whitelogger has joined #ponylang
Summertime has quit [Quit: Sunsetting.]
Summertime has joined #ponylang
endformationage has quit [Quit: WeeChat 2.3]
_whitelogger has joined #ponylang
_whitelogger has joined #ponylang
brainproxy has quit [Ping timeout: 246 seconds]
brainproxy has joined #ponylang
<vaninwagen> ^5 jdhorwitz
ensrettet has joined #ponylang
ensrettet has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ExtraCrispy has joined #ponylang
endformationage has joined #ponylang
brainproxy has quit [Ping timeout: 245 seconds]
erip has joined #ponylang
<erip> Hey all.
<erip> Is there a bottom type in pony?
<erip> I'm trying to create a `Maybe[A]` implementation. I have something like this:
<erip> ```interface Maybe[A] fun map[B](f: {(A): B}): Maybe[B]```
<erip> (Sorry, I don't know formatting in IRC)
<erip> The problem with this is when I implement `class Nothing is Maybe[???]`, I don't know what ??? should be.
<erip> I've tried `Maybe[Any]`, but when I make my `map` impl return `Nothing`, I get `function body isn't the result type fun map[B](f: {(None): B}): Maybe[B] => Nothing`
erip has quit [Ping timeout: 256 seconds]
brainproxy has joined #ponylang
<vaninwagen> A maybe that you might know from scala or haskell is best implemented as a union type in pony:
<vaninwagen> type Maybe[T] is (T | None)
<vaninwagen> you could also do primitive Nothing[T] is Maybe[T]
<vaninwagen> erip: ^
<vaninwagen> Afaik there is no such thing as a Nothing (like in scala) in pony
<vaninwagen> Nothing in scala i think is a subtype of every other type (please correct me if i'm wrong)
<vaninwagen> I once did something similar to work with optional thingies: https://github.com/mfelsche/pony-kv/blob/master/pony-kv/optional/optional.pony
erip has joined #ponylang
<erip> @vaninwagen Yeah, I've seen the union type with the `|` notation.
<vaninwagen> I do miss proper union types when doing scala
<erip> To me, the use of subclassing for ADTs seems more natural since you can embed the variant behaviors in the appropriate class.
<erip> But I've almost primarily focused on scala for FP, so maybe that's why it's so familiar.
<vaninwagen> If you wanna go the scala way, you might wanna go with:
<vaninwagen> primitive Nothing[T] is Maybe[T] ...
<vaninwagen> And then implement the variant methods in there
<vaninwagen> primitive is like object in scala
<vaninwagen> But there is no concept of companion objects in pony
<erip> Excellent.
<vaninwagen> You will soon see that pony definitely needs type inference for generics
<erip> I've already found the generics to be kind of difficult to work with as-is
<vaninwagen> I think apart from having a bit more to type, i think it is ok
<vaninwagen> It is like java before the diamond operator :p
<plietar> There isn’t a bottom type, but it’s been mentioned a few times before and I think it would be a good idea
<plietar> *probably* not that hard to implement either
<vaninwagen> plietar: ^5
<erip> I think the confusing part about generics in pony is that I'm never quite sure when things need to be constrained
<erip> like, if I have a primitive Nothing[A]
<erip> like, if I have a primitive Nothing[A] is Maybe[A]
<erip> fun map[B](f: {(A): B}): Maybe[B] => Nothing[B]
<erip> this doesn't compile. I think it's become something needs to be contrained
<erip> Nothing[B] allegedly doesn't conform to the expected result type, but by definition, Nothing[A] is a Maybe[A]
<vaninwagen> Can you paste a playground link with your example?
<vaninwagen> playground.ponylang.io
<vaninwagen> It could be you are hitting a known bug here
<vaninwagen> It could be the one that plietar created a PR for: https://github.com/ponylang/ponyc/pull/1888
<vaninwagen> Which i then messed up
<erip> heh
<vaninwagen> plietar: sorry for dat. Didnt find the time to unclutter this one.
<erip> oh, it's nbd
<erip> I'm just futzing around
<erip> @vaninwagen, should I post this minimal gist in the issue?
<erip> Sorry, the PR.
<plietar> Hmm, that error does look legit
<plietar> Nothing is a primitive, so it has capability val
<plietar> But Maybe is an interface, so it has a default capability of ref
<plietar> Hence the val isn’t a subcap of ref error
<plietar> vaninwagen: that’s on me, I’ve been neglecting those PRs while I was working
<plietar> And I haven’t gotten back to them yet
<plietar> erip: you could make Maybe use val
<plietar> Then it’d probably work
<plietar> But this snippet is an interesting problem, I’ll have to think more about it when i get home
<erip> By "use val", does this mean qualify the interface with val? i.e., `interface val Maybe[A]`?
<erip> I converted the primitive to a `class val` and still found the error.
<vaninwagen> I did the same in this playground: https://playground.ponylang.io/?gist=a569c4cb5b360ca9bac5d73468b7ede3 and it gives me:
<vaninwagen> B #any is not a subtype of B #any: the subtype has no constraint
<vaninwagen> Thats why i thought it is the same issue as is fixed with your PR, plietar
<erip> Maybe it's just the capabilities which are confusing, heh.
<erip> Not the generics.
<plietar> Hmm yes I think you’re right
<plietar> The original snippet had one more error about val, which is what I was looking at
<erip> So the error is legit?
<plietar> No, I meant it’s the same bug vaninwagen linked to
<erip> Ah, understood.
erip has quit [Ping timeout: 256 seconds]
TwoNotes has joined #ponylang
TwoNotes has left #ponylang [#ponylang]