I see. A pattern like '~xs' is problematic as not every linear value can be
freed.
On Wednesday, May 16, 2018 at 11:54:38 AM UTC-4, aditya siram wrote:
>
> I meant why couldn't you still a '~' on the 'xs' like
> | (~Some_vt(~nested(~Some_vt(~list_vt_cons(x,~xs, ... =>
>
>
>
> On Wednesday, M
I meant why couldn't you still a '~' on the 'xs' like
| (~Some_vt(~nested(~Some_vt(~list_vt_cons(x,~xs, ... =>
On Wednesday, May 16, 2018 at 8:59:48 AM UTC-5, gmhwxi wrote:
>
> The pattern ~list_vt_cons(x, xs) means the list constructor/node (that
> matches it) is freed;
> the head of the
The pattern ~list_vt_cons(x, xs) means the list constructor/node (that
matches it) is freed;
the head of the list is stored in 'x' and the tail in 'xs'.
On Wed, May 16, 2018 at 9:56 AM, aditya siram
wrote:
> Awesome, thanks! I think my confusion was mostly that the error messages
> complained ab
Awesome, thanks! I think my confusion was mostly that the error messages
complained about needing to retain a linear variable instead of consuming
it so I never tried to free them. Also why did 'xs' have to freed
explicitly with 'free(xs)' instead of using the '~' syntax in the pattern
match?
Here is some code that typechecks:
implement add_heads(a,b) =
case (a,b) of
| (~None_vt(),g) => g
| (l, ~None_vt()) => l
| (~Some_vt(~nested(~Some_vt(~list_vt_cons(x,xs,
~Some_vt(~nested(~Some_vt(~list_vt_cons(y,ys) =>
(free(xs); Some_vt(nested(Some_vt(list_vt_cons(x+y,ys)
#include "share/atspre_staload.hats"
datavtype nested = nested of (Option_vt(List_vt(int)))
extern fun add_heads(
a : Option_vt(nested),
b : Option_vt(nested)
): Option_vt(nested)
implement add_heads(a,b) =
case (a,b) of
| (~None_vt(),g) => g
| (l, ~None_vt()) => l
| (Some_vt(
Oops. I am NOT so clear ...
On Tue, May 15, 2018 at 9:27 PM, Hongwei Xi wrote:
> I am so clear as to what you need precisely.
>
> Could you show me how to do it using pattern matching repeatly?
> Then I may be able to do it using a nested pattern.
>
> Here is an example that may be useful:
>
> |
I am so clear as to what you need precisely.
Could you show me how to do it using pattern matching repeatly?
Then I may be able to do it using a nested pattern.
Here is an example that may be useful:
| ~Some_vt(~Some_vt(xs as list_vt_cons _)) => // using xs here
The two Some_vt constructors are
Hi all,
I'm sure there's an easy answer to this but I'm not having much luck. How
do I destructure into a view type that nested in another viewtype? For
example, I'd to pattern match on something of type
'Option_vt(Option_vt(list_vt int))'. I'm not having much luck doing it in
one fell swoop li