There are two issues here.
- Syntax. The following declaration is what you want:
dataview partial_buf ( t: t@ype, int, int, addr ) =
| { fill, total: nat | fill <= total }{ buf : addr }
partial_buf ( t
, fill
, total
, buf
) of ( @[ t ][ fill ] @ buf
, @[ t? ][ total - fill ] @ ( buf + fill )
)
If a parameter is given a name in a dataview declaration, then a universal
quantifier is implicitly introduced for that parameter. So your original
declaration
has duplicated quantifiers.
- Logic.
implement main () = let
var buf = @[byte]10
prval empty = array_v_nil{byte}()
prval partial = partial_buf(empty, view@(buf))
prval partial_buf(empty, l) = partial
prval _ = array_v_unnil(empty)
prval _ = view@(buf) := l
in 0 end
prval partial_buf(empty, l) = partial
The system does not know that ‘empty’ is a proof of an empty array-view;
it only knows that ‘empty’ is a prefix of the given buffer.On Tue, Apr 14, 2015 at 9:14 PM, Shea Levy sh...@shealevy.com wrote:
Hi all,
With the following code:
dataview partial_buf ( t: t@ype, fill: int, total: int, buf: addr ) =
| { t: t@ype }{ fill, total: nat | fill <= total }{ buf : addr }
partial_buf ( t
, fill
, total
, buf
) of ( @[ t ][ fill ] @ buf
, @[ t? ][ total - fill ] @ ( buf + fill )
)
implement main () = let
var buf = @[byte]10
prval empty = array_v_nil{byte}()
prval partial = partial_buf(empty, view@(buf))
prval partial_buf(empty, l) = partial
prval _ = array_v_unnil(empty)
prval _ = view@(buf) := l
in 0 end
I get this error:
/home/shlevy/src/elvysh-main/test2.dats: 593(line=17, offs=13) –
608(line=17, offs=28): error(3): viewat-restoration cannot be performed:
mismatch of bef/aft locations of atviews:
bef: [S2Evar(buf(3864))]
aft: [S2Eapp(S2Ecst(add_addr_int); S2Evar(buf$854(3872)),
S2Evar(fill$852(3870)))]
patsopt(TRANS3): there are [1] errors in total.
exit(ATS): uncaught exception:
_2home_2hwxi_2research_2Postiats_2git_2src_2pats_error_2esats__FatalErrorExn(1025)
How am I meant to do viewat-restoration?
Thanks,
Shea
–
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-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/EC973B28-C1E1-441A-8771-7B60639DD046%40shealevy.com
.