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
acarrico has joined #ponylang
_whitelogger has joined #ponylang
profetes has joined #ponylang
<biscarch> How do I figure out the default capability of something like: `var common_letters: Array[U8] = []`
<biscarch> I solved my problem by annotating it with iso: `var common_letters: Array[U8] iso = []`
<biscarch> but I don't yet understand how to figure out what the "default" capability is
endformationage has quit [Ping timeout: 250 seconds]
srenatus has joined #ponylang
<vaninwagen> You find out by looking at the class definition
<vaninwagen> If it says: class iso Thingy, the default capability is iso
<vaninwagen> If it just says class Thingy, it is ref
<vaninwagen> If nothingnis explicitly added, like in the second case above, you get ref for classes, val for primitives and tag for actors
<biscarch> thanks :)
profetes_ has joined #ponylang
profetes has quit [Ping timeout: 252 seconds]
profetes_ has quit [Quit: Leaving]
erip has joined #ponylang
<erip> Good morning, folks
<erip> I have a silly question... I have defined `Maybe[A] = (A | None)`, but I want to be able to patmat on just the type:
<erip> I think I need `A` to be `Equatable[A]` for this -- is that right? if so, how do I enforce that in the type alias?
<erip> ...and of course I typo'd my Maybe defn. :)
<vaninwagen> erip: what does patmat mean?
<erip> pattern matching
<vaninwagen> Aye
<vaninwagen> You can use: let a: A => and let n: None => in your patmat cases
<vaninwagen> I think then it should detect that you covered all cases
<erip> Sure, I can make it work, but that's not my question. :)
<vaninwagen> But this is how you patmat on just the type, no?
<vaninwagen> If you use just | A => as the patmat case, it desugars this to | A.create() => and will take this created A and compare it using .eq against your match pattern
<freza> erip: seems to work if you tell it return type of `f[...](...)` is String..?
<erip> Ah, I was misreading the docs.
<vaninwagen> For this, you need A to be equatable, for the other case not
<erip> In the "Matching on type and value" section
<erip> I didn't see that `Foo` was a class here
<erip> and, as such, has a create
<vaninwagen> What you need is a Capture
<erip> Yep. that's how I was dealing with it
<freza> this seems to work https://playground.ponylang.io/?gist=912d7a45d4e64ae5e7f92b6d73a0d27f if it does what was wanted
<_andre> i believe the 'let n' is unnecessary, you can just use None in that case
<vaninwagen> Yeah, None is a concrete primitive and thus has .eq()
<erip> Turning my question on its head, let's say I want to define a type alias with some constraint
<erip> Like a `MaybeWithEquatable[A] is (A is Equatable[A] | None)` -- is this possible?
<erip> I'm coming from scala where you can do this like `MaybeWithEquatable[A: Equatable]` or similar
<_andre> this works for me: 8) = '-'
<_andre> s(13) = '-'
<_andre> s(18) = '-'
<_andre> erm
<_andre> sorry
<_andre> type Maybe[A: Equatable[A] #read] is (A | None)
<erip> heh. the reference capabilities and the #xyz things are very tricky. :)
<_andre> indeed... i was guided by the error message when i tried it without it though
<_andre> "Equatable[A #any] #any is not in constraint Equatable[A #any] #read: #any is not in constraint #read"
<vaninwagen> Yeah, you need the #read because the Equatable needs read from its instances fields to obtain info about identity
<vaninwagen> Generics are hard, generic refcaps even a little more
erip has quit [Quit: Page closed]
endformationage has joined #ponylang
malyn has quit [Quit: ""]
malyn has joined #ponylang
srenatus has quit [Quit: Connection closed for inactivity]