I think I've been able to break down a problem I've been having with ATS' templates into a simple example provided below. The following code type-checks, and can easily tested using Try-ATS-on-line.
datavtype maybe(a:vt@ype) =
| NAH of ()
| YAH of (a)
fn{a:vt@ype} maybe_nah () : maybe(a) = NAH()
fn{a:vt@ype} maybe_yah ( x: a ) : maybe(a) = YAH(x)
implement main0 () = let
var m1 = maybe_nah<int>()
var m2 = maybe_yah<int>(6)
val-~NAH() = m1
val-~YAH(int) = m2
in
end
Running the above sample produces the following error:
ParsingErrors:
/tmp/patsopt_ccats_Ht1nNp: 9732(line=454, offs=1) -- 9735(line=454, offs=4): error(parsing): the keyword [EOF] is needed.
exit(ATS): uncaught exception at run-time:
/var/lib/openshift/5419477be0b8cddd09000122/app-root/runtime/repo/ats2-lang/contrib/CATS-parsemit/SATS/catsparse.sats:FatalErrorExn(1024)
My question is, why is this simple example failing, and how should I fix it? I know the problem is related to metaprogramming in some way, but I don't understand the low-level details enough to get why this isn't working. Please let me know if you have any further questions.