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
<endformationage> Of course the types involed can be as simple as primitives or as complex as multi-type parametrized generics.
<endformationage> codec_: Here is a very quick replication of Rust's Result type (which probably could be simplified bettered by the pros here):
<endformationage> BTW, the playground is fantastic for trying things out while learning!
_whitelogger has joined #ponylang
<codec_> thanks for the info. I am just wondering how ergonomics it is in practice
<codec_> for example, when accesing an element in an array, do I have to go through the whole try ... end thing, or can I have something like myArray(index).or_none()
<codec_> which will give back a (T | None) -where T is the type of the array- depending of the correctness of the index
jemc has joined #ponylang
<endformationage> codec_: Within the std library, and especially collections, such methods are partial and will require try blocks.
<endformationage> You can assign to a variable as a result of a try expression for something similar to your or_none() (if I understand your intention)
<endformationage> So yeah, in pratice Pony will be more verbose in dealing with partial calls, but quite clear in that such calls require error handling. Many prefering to have this clarity to succinctness.
<codec_> thanks
<codec_> but I think they are not exclusive
<endformationage> What that says about the ergonomics of the code is up to preference I suppose.
<codec_> I mean someArray(i)?.or_none() is quite a bit shorter than try someArray(i)? else None while still obivous
<codec_> and that a simple example
<codec_> Do you happen to know if this is something that address Pony in the future or it is done on purpose
<codec_> Just to be clear, I think the current solution is by itself good, but may result in quite a lot of boilerplate
<endformationage> Well, presumably there could be some sugar made available for some common/default cases such as with unions with None. Though I haven't seen it to be much an issue for myself.
<codec_> So maybe it is not that much in practice
<endformationage> I don't think so, and additional sugaring will come, but it is not a priority at this time AFAICT. Contributors to the compiler mya have more to say on this.
<codec_> about the sugar, is it possible to write generic methods that would apply on "partial type" ?
<endformationage> I am not clear on what is meant by partial type.
<codec_> let's say I have a method that return a T?
<endformationage> Sure, methods that are partial (may error) can be gereric.
<codec_> can I write functions that can apply to them (T?) ?
<endformationage> *generic
<codec_> that was what I mean
<codec_> :)
<codec_> *n't
<codec_> I mean can I treat T? has its own type ?
<codec_> for example, If I want to reproduce the common type that Rust have (Option, Result), can I create generic methods to "emulate them"
<codec_> such that it would allow me to write stuff like : myArray(i)?.or_none() or myArray(i)?with_default(3)
<codec_> Earlier I tried but ended up using lambda which was less ergonomic that the try... else... solution
<endformationage> I don't think so, because at the point that myArray(i)? errors, the or_none() and with_default(3) are not called, and the else clause of the try is invoked.
<endformationage> Like I say, there may be room for some try block sugaring.
<codec_> I see
<codec_> thanks for taking time to answer my questions
<codec_> I will wait to learn more about Pony before proposing an RFC or raising an issue though :)
<endformationage> Glad to be of some help.
_whitelogger has joined #ponylang
codec_ has quit [Ping timeout: 260 seconds]
dipin has quit [Quit: dipin]
_whitelogger has joined #ponylang
endformationage has quit [Quit: WeeChat 1.9.1]
_whitelogger has joined #ponylang
jemc has quit [Ping timeout: 255 seconds]
_whitelogger has joined #ponylang
_whitelogger has joined #ponylang
aturley has joined #ponylang
ShalokShalom_ has joined #ponylang
ShalokShalom has quit [Ping timeout: 255 seconds]
ShalokShalom_ is now known as ShalokShalom
<SeanTAllen> Howdy y'all. A new "Last Week in Pony" is out. Get it while it's hot: https://www.ponylang.org/blog/2017/10/last-week-in-pony---october-15-2017/
dipin has joined #ponylang
dipin has quit [Quit: dipin]
Praetonus has joined #ponylang
jemc has joined #ponylang
samuell has joined #ponylang
jemc has quit [Ping timeout: 246 seconds]
vaninwagen has joined #ponylang
theodus has joined #ponylang
theodus has quit [Remote host closed the connection]
theodus has joined #ponylang
vaninwagen has quit [Ping timeout: 252 seconds]
endformationage has joined #ponylang
jemc has joined #ponylang
samuell has quit [Remote host closed the connection]
jemc has quit [Ping timeout: 258 seconds]
Praetonus has quit [Quit: Leaving]
_whitelogger has joined #ponylang
endformationage has quit [Ping timeout: 240 seconds]
jemc has joined #ponylang
jemc has quit [Ping timeout: 240 seconds]
jemc has joined #ponylang
theodus has quit [Remote host closed the connection]