I trying to understand the stream_vt datatype by writing a function that 
merges two streams in a stream of tuples but not having much luck, the 
following:

fun merge
  {a: t@ype}
  {b: t@ype}
  (
    s1: stream_vt a,
    s2: stream_vt b
  ) : stream_vt(@(a,b)) =
  let
    val _s1 = !s1
    val _s2 = !s2
  in
    $ldelay
     (
      case+ (_s1,_s2) of
      | (~stream_vt_cons(_s1, _s1s),
         ~stream_vt_cons(_s2, _s2s)) =>
             stream_vt_cons((_s1,_s2), merge(_s1s,_s2s))
      | (_,_) => stream_vt_nil()
     )
  end

gives me the errors:

...: 465(line=27, offs=9) -- 590(line=29, offs=57): error(3): the dynamic 
variable [_s2$4720(-1)] is consumed but it should be retained with the type 
[S2Eapp(S2Ecst(stream_vt_con); S2Evar(b(8451)))] instead.
...: 465(line=27, offs=9) -- 590(line=29, offs=57): error(3): the dynamic 
variable [_s1$4719(-1)] is consumed but it should be retained with the type 
[S2Eapp(S2Ecst(stream_vt_con); S2Evar(a(8450)))] instead.
...: 368(line=20, offs=3) -- 636(line=32, offs=6): error(3): the linear 
dynamic variable [_s1$4719(-1)] needs to be consumed but it is preserved 
with the type [S2Eapp(S2Ecst(stream_vt_con); S2Evar(a(8450)))] instead.
...: 368(line=20, offs=3) -- 636(line=32, offs=6): error(3): the linear 
dynamic variable [_s2$4720(-1)] needs to be consumed but it is preserved 
with the type [S2Eapp(S2Ecst(stream_vt_con); S2Evar(b(8451)))] instead.
patsopt(TRANS3): there are [4] errors in total.
exit(ATS): uncaught exception: 
_2home_2deech_2ATS_2triples_2dats_2ATS_2ATS2_2src_2pats_error_2esats__FatalErrorExn
(1025)

Any help is appreciated.

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ats-lang-users+unsubscr...@googlegroups.com.
To post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/21f9263f-e0be-4dcb-8bf6-45031eaea85a%40googlegroups.com.

Reply via email to