ImagineHaxing
unread,Aug 10, 2026, 5:25:54 AM (2 days ago) Aug 10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ats-lang-users
I am following the book "Introduction to Programming in ATS" and I am trying to compile the following code
#include "share/atspre_define.hats"
#include "share/atspre_staload.hats"
datatype list(a:t@ype+, int) =
| list_nil (a,0) of ()
| {n:nat} list_cons (a, n+1) of (a, list(a, n))
fun {a:t@ype}
list_length {n:nat} .<n>. (xs: list(a,n)): int n =
case+ xs of
| list_nil () => 0
| list_cons (_, xs1) => 1 + list_length(xs1)
val list_test = list_cons("hello", list_cons("world", list_nil()))
val () = print(list_length(list_test))
implement main0() = ()
with this command line
patscc -D_GNU_SOURCE -DATS_MEMALLOC_LIBC -I${PATSHOME} -I${PATSHOME}/ccomp/runtime -O2 -o main main.dats -latslib && ./main
and it is printing out "1" instead of "2". What am I doing wrong here?