03:29
acarrico has joined #ponylang
03:43
_whitelogger has joined #ponylang
06:34
profetes has joined #ponylang
06:40
<
biscarch >
How do I figure out the default capability of something like: `var common_letters: Array[U8] = []`
06:40
<
biscarch >
I solved my problem by annotating it with iso: `var common_letters: Array[U8] iso = []`
06:41
<
biscarch >
but I don't yet understand how to figure out what the "default" capability is
06:47
endformationage has quit [Ping timeout: 250 seconds]
06:49
srenatus has joined #ponylang
06:55
<
vaninwagen >
You find out by looking at the class definition
06:55
<
vaninwagen >
If it says: class iso Thingy, the default capability is iso
06:56
<
vaninwagen >
If it just says class Thingy, it is ref
06:56
<
vaninwagen >
If nothingnis explicitly added, like in the second case above, you get ref for classes, val for primitives and tag for actors
07:26
<
biscarch >
thanks :)
09:54
profetes_ has joined #ponylang
09:57
profetes has quit [Ping timeout: 252 seconds]
11:35
profetes_ has quit [Quit: Leaving]
13:00
erip has joined #ponylang
13:00
<
erip >
Good morning, folks
13:00
<
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:
13:01
<
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?
13:01
<
erip >
...and of course I typo'd my Maybe defn. :)
13:13
<
vaninwagen >
erip: what does patmat mean?
13:14
<
erip >
pattern matching
13:16
<
vaninwagen >
You can use: let a: A => and let n: None => in your patmat cases
13:17
<
vaninwagen >
I think then it should detect that you covered all cases
13:17
<
erip >
Sure, I can make it work, but that's not my question. :)
13:18
<
vaninwagen >
But this is how you patmat on just the type, no?
13:19
<
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
13:20
<
freza >
erip: seems to work if you tell it return type of `f[...](...)` is String..?
13:20
<
erip >
Ah, I was misreading the docs.
13:20
<
vaninwagen >
For this, you need A to be equatable, for the other case not
13:20
<
erip >
In the "Matching on type and value" section
13:20
<
erip >
I didn't see that `Foo` was a class here
13:20
<
erip >
and, as such, has a create
13:21
<
vaninwagen >
What you need is a Capture
13:21
<
erip >
Yep. that's how I was dealing with it
13:23
<
_andre >
i believe the 'let n' is unnecessary, you can just use None in that case
13:24
<
vaninwagen >
Yeah, None is a concrete primitive and thus has .eq()
13:25
<
erip >
Turning my question on its head, let's say I want to define a type alias with some constraint
13:26
<
erip >
Like a `MaybeWithEquatable[A] is (A is Equatable[A] | None)` -- is this possible?
13:26
<
erip >
I'm coming from scala where you can do this like `MaybeWithEquatable[A: Equatable]` or similar
13:27
<
_andre >
this works for me: 8) = '-'
13:27
<
_andre >
s(13) = '-'
13:27
<
_andre >
s(18) = '-'
13:28
<
_andre >
type Maybe[A: Equatable[A] #read] is (A | None)
13:30
<
erip >
heh. the reference capabilities and the #xyz things are very tricky. :)
13:32
<
_andre >
indeed... i was guided by the error message when i tried it without it though
13:33
<
_andre >
"Equatable[A #any] #any is not in constraint Equatable[A #any] #read: #any is not in constraint #read"
13:36
<
vaninwagen >
Yeah, you need the #read because the Equatable needs read from its instances fields to obtain info about identity
13:36
<
vaninwagen >
Generics are hard, generic refcaps even a little more
13:44
erip has quit [Quit: Page closed]
15:11
endformationage has joined #ponylang
18:23
malyn has quit [Quit: ""]
18:24
malyn has joined #ponylang
19:39
srenatus has quit [Quit: Connection closed for inactivity]