├── .gitignore
├── .travis.yml
├── Makefile_update
├── README.md
├── bin
└── .keeper
├── lib
└── .gitkeep
├── prelude
├── DATS
│ ├── CATS
│ │ ├── JS
│ │ │ ├── Node
│ │ │ │ ├── g_print.cats
│ │ │ │ └── g_print.dats
│ │ │ ├── basics.dats
│ │ │ ├── g_eqref.cats
│ │ │ ├── g_eqref.dats
│ │ │ ├── g_print.cats
│ │ │ ├── g_print.dats
│ │ │ ├── jsbasics.cats
│ │ │ ├── jsbasics.dats
│ │ │ ├── prelude.cats
│ │ │ ├── prelude.dats
│ │ │ ├── runtime.cats
│ │ │ └── unsafe.dats
│ │ └── Xint
│ │ │ ├── .keeper
│ │ │ ├── basics.dats
│ │ │ └── prelude.dats
│ ├── array.dats
│ ├── bool.dats
│ ├── char.dats
│ ├── gbas.dats
│ ├── gflt.dats
│ ├── gfor.dats
│ ├── gfun.dats
│ ├── gint.dats
│ ├── gios.dats
│ ├── gmap.dats
│ ├── gnum.dats
│ ├── gord.dats
│ ├── gseq.dats
│ ├── gseq_vt.dats
│ ├── gseqn.dats
│ ├── list.dats
│ ├── list_vt.dats
│ ├── optn.dats
│ ├── optn_vt.dats
│ ├── rand.dats
│ ├── stream.dats
│ ├── stream_vt.dats
│ ├── string.dats
│ ├── synougat.dats
│ ├── tuple.dats
│ └── unsafe.dats
├── SATS
│ ├── CC
│ │ ├── array.sats
│ │ └── basics.sats
│ ├── array.sats
│ ├── bool.sats
│ ├── char.sats
│ ├── gbas.sats
│ ├── gflt.sats
│ ├── gfor.sats
│ ├── gfun.sats
│ ├── gint.sats
│ ├── gintb.sats
│ ├── gmap.sats
│ ├── gnum.sats
│ ├── gord.sats
│ ├── gseq.sats
│ ├── gseq_vt.sats
│ ├── gseqn.sats
│ ├── gseqn_vt.sats
│ ├── list.sats
│ ├── list_vt.sats
│ ├── optn.sats
│ ├── optn_vt.sats
│ ├── stream.sats
│ ├── stream_vt.sats
│ ├── string.sats
│ └── unsafe.sats
├── basics.sats
├── excptn.sats
├── fixity.sats
├── xparam.hats
└── xsetup.sats
├── srcgen
├── xats
│ ├── .depend
│ ├── BUILD
│ │ └── .gitkeep
│ ├── CATS
│ │ ├── lexbuf0.cats
│ │ ├── locinfo.cats
│ │ └── parsing.cats
│ ├── DATS
│ │ ├── CONTRIB
│ │ │ ├── githwxi
│ │ │ │ ├── .keeper
│ │ │ │ ├── my_tread23_dynexp.dats
│ │ │ │ └── my_tread33_dynexp.dats
│ │ │ ├── tread23_dynexp.dats
│ │ │ └── tread33_dynexp.dats
│ │ ├── cstrnt0.dats
│ │ ├── cstrnt0_print.dats
│ │ ├── cstrnt1.dats
│ │ ├── cstrnt1_print.dats
│ │ ├── dmacro2_macdef.dats
│ │ ├── dynexp0.dats
│ │ ├── dynexp0_print.dats
│ │ ├── dynexp1.dats
│ │ ├── dynexp1_print.dats
│ │ ├── dynexp2.dats
│ │ ├── dynexp2_d2con.dats
│ │ ├── dynexp2_d2cst.dats
│ │ ├── dynexp2_d2var.dats
│ │ ├── dynexp2_print.dats
│ │ ├── dynexp3.dats
│ │ ├── dynexp3_print.dats
│ │ ├── dynexp3_util0.dats
│ │ ├── dynexp4.dats
│ │ ├── dynexp4_print.dats
│ │ ├── dynexp4_stmap.dats
│ │ ├── dynexp4_util0.dats
│ │ ├── effect0.dats
│ │ ├── filpath.dats
│ │ ├── filsrch.dats
│ │ ├── gmacro1_define.dats
│ │ ├── intrep0.dats
│ │ ├── intrep0_dynexp.dats
│ │ ├── intrep0_jsoniz.dats
│ │ ├── intrep0_print.dats
│ │ ├── intrep0_statyp.dats
│ │ ├── lexbuf0.dats
│ │ ├── lexing0_kword.dats
│ │ ├── lexing0_token.dats
│ │ ├── lexing0_util0.dats
│ │ ├── locinfo.dats
│ │ ├── nmspace.dats
│ │ ├── parsing_basics.dats
│ │ ├── parsing_dynexp.dats
│ │ ├── parsing_staexp.dats
│ │ ├── parsing_tokbuf.dats
│ │ ├── staexp0.dats
│ │ ├── staexp0_print.dats
│ │ ├── staexp1.dats
│ │ ├── staexp1_print.dats
│ │ ├── staexp2.dats
│ │ ├── staexp2_init0.dats
│ │ ├── staexp2_print.dats
│ │ ├── staexp2_s2cst.dats
│ │ ├── staexp2_util1.dats
│ │ ├── staexp2_util2.dats
│ │ ├── statyp2.dats
│ │ ├── statyp2_init0.dats
│ │ ├── statyp2_print.dats
│ │ ├── statyp2_unify.dats
│ │ ├── statyp2_util0.dats
│ │ ├── synread_basics.dats
│ │ ├── synread_dynexp.dats
│ │ ├── synread_staexp.dats
│ │ ├── tcomp30_dynexp.dats
│ │ ├── tcomp30_statyp.dats
│ │ ├── tcomp30_util0.dats
│ │ ├── trans01_basics.dats
│ │ ├── trans01_dynexp.dats
│ │ ├── trans01_envmap.dats
│ │ ├── trans01_staexp.dats
│ │ ├── trans12_basics.dats
│ │ ├── trans12_dynexp.dats
│ │ ├── trans12_envmap.dats
│ │ ├── trans12_staexp.dats
│ │ ├── trans23_dynexp.dats
│ │ ├── trans23_util0.dats
│ │ ├── trans33_dynexp.dats
│ │ ├── trans33_envmap.dats
│ │ ├── trans33_util0.dats
│ │ ├── trans34_dynexp.dats
│ │ ├── trans34_envmap.dats
│ │ ├── trans34_util1.dats
│ │ ├── trans34_util2.dats
│ │ ├── trans3t_dynexp.dats
│ │ ├── trans3t_envmap.dats
│ │ ├── trans3x_dynexp.dats
│ │ ├── trans3x_envmap.dats
│ │ ├── trans4x_dynexp.dats
│ │ ├── trans4x_envmap.dats
│ │ ├── tread01_dynexp.dats
│ │ ├── tread01_staexp.dats
│ │ ├── tread12_dynexp.dats
│ │ ├── tread12_staexp.dats
│ │ ├── tread23_dynexp.dats
│ │ ├── tread33_dynexp.dats
│ │ ├── tread34_dynexp.dats
│ │ ├── tread3x_dynexp.dats
│ │ ├── xatsopt.dats
│ │ ├── xatsopt_main0.dats
│ │ ├── xatsopt_util0.dats
│ │ ├── xbasics.dats
│ │ ├── xerrory.dats
│ │ ├── xfixity.dats
│ │ ├── xglobal.dats
│ │ ├── xlabel0.dats
│ │ ├── xstamp0.dats
│ │ ├── xsymbol.dats
│ │ ├── xsymenv.dats
│ │ └── xsymmap.dats
│ ├── HATS
│ │ └── xatsopt.hats
│ ├── Makefile
│ ├── Makefile_xatsopt
│ ├── SATS
│ │ ├── cstrnt0.sats
│ │ ├── cstrnt1.sats
│ │ ├── dynexp0.sats
│ │ ├── dynexp1.sats
│ │ ├── dynexp2.sats
│ │ ├── dynexp3.sats
│ │ ├── dynexp4.sats
│ │ ├── effect0.sats
│ │ ├── filpath.sats
│ │ ├── filsrch.sats
│ │ ├── intrep0.sats
│ │ ├── lexbuf0.sats
│ │ ├── lexing0.sats
│ │ ├── locinfo.sats
│ │ ├── nmspace.sats
│ │ ├── parsing.sats
│ │ ├── staexp0.sats
│ │ ├── staexp1.sats
│ │ ├── staexp2.sats
│ │ ├── statyp2.sats
│ │ ├── synread.sats
│ │ ├── tcomp30.sats
│ │ ├── trans01.sats
│ │ ├── trans12.sats
│ │ ├── trans23.sats
│ │ ├── trans33.sats
│ │ ├── trans34.sats
│ │ ├── trans3t.sats
│ │ ├── trans3x.sats
│ │ ├── trans4x.sats
│ │ ├── tread01.sats
│ │ ├── tread12.sats
│ │ ├── tread23.sats
│ │ ├── tread33.sats
│ │ ├── tread34.sats
│ │ ├── tread3t.sats
│ │ ├── tread3x.sats
│ │ ├── xatsopt.sats
│ │ ├── xbasics.sats
│ │ ├── xerrory.sats
│ │ ├── xfixity.sats
│ │ ├── xglobal.sats
│ │ ├── xlabel0.sats
│ │ ├── xstamp0.sats
│ │ ├── xsymbol.sats
│ │ ├── xsymenv.sats
│ │ └── xsymmap.sats
│ └── TEST
│ │ ├── Makefile_prelude
│ │ ├── Makefile_test
│ │ └── Makefile_xatslib
└── xutl
│ ├── DATS
│ ├── Posix
│ │ ├── cblist.dats
│ │ └── mylibc.dats
│ ├── Windows
│ │ └── .gitkeep
│ └── cblist.dats
│ ├── SATS
│ ├── Posix
│ │ └── cblist.sats
│ ├── Windows
│ │ └── cblist.sats
│ ├── cblist.sats
│ └── mylibc.sats
│ └── TEST
│ ├── Makefile
│ ├── Posix
│ ├── DATA
│ │ └── test_cblist.txt
│ ├── Makefile
│ ├── test_cblist.dats
│ └── test_mylibc.dats
│ └── cblist.dats
├── travis-ci
├── install-ats2.sh
└── travis.yml
└── xatslib
├── githwxi
├── DATS
│ ├── dvdcnq.dats
│ ├── gtree1.dats
│ ├── mygist.dats
│ ├── mytest.dats
│ ├── parcmbr1.dats
│ └── xdebug.dats
├── SATS
│ └── githwxi.sats
└── TEST
│ └── test-2020-03-21.dats
└── libc
├── DATS
├── CATS
│ ├── JS
│ │ └── Node
│ │ │ ├── basics.dats
│ │ │ └── prelude.cats
│ └── Xint
│ │ └── basics.dats
├── fpath.dats
├── gios.dats
├── rand.dats
└── stdio.dats
└── SATS
└── libc.sats
/.gitignore:
--------------------------------------------------------------------------------
1 | #
2 | # ignoring generated files
3 | #
4 | bin/xatsopt
5 | srcgen/xats/xatsopt
6 |
7 | ###### end of [.gitignore] ######
8 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | ---
2 | os:
3 | - linux
4 |
5 | language: c
6 |
7 | node_js:
8 | - "5.10.1"
9 |
10 | env:
11 | - export NODE_VERSION="5.10.1"
12 |
13 | addons:
14 | apt:
15 | packages:
16 | - libgc-dev
17 | - libgmp-dev
18 |
19 | before_install:
20 | - date
21 | - export PATSHOME=${HOME}/ATS2
22 | - export PATH=${PATH}:${PATSHOME}/bin
23 | - export XATSHOME=${TRAVIS_BUILD_DIR}
24 | - export GCC=gcc
25 | - export CLANG=clang
26 |
27 | install:
28 | # $XATSHOME/travis-ci/install-ats2.sh 0.4.0
29 | # $XATSHOME/travis-ci/install-ats2.sh 0.4.1
30 | - $XATSHOME/travis-ci/install-ats2.sh 0.4.2
31 |
32 | after_install:
33 | - date
34 |
35 | before_script:
36 | - date
37 |
38 | script:
39 | # Building ATS2
40 | - cd ${PATSHOME}
41 | - ./configure&&make CC=${GCC} all
42 | # Building Xanadu
43 | - cd ${XATSHOME}/srcgen
44 | - echo 'building ATS-Xanadu...'
45 | - (cd xats && make all)
46 | - echo 'running xutl unit-tests...'
47 | - (cd xutl/TEST && make testall)
48 | - (cd xutl/TEST/Posix && make testall)
49 | - echo 'running xats unit-tests...'
50 | - (cd xats/TEST && make XATSOPT=./../xatsopt -f Makefile_test all)
51 |
52 | after_script:
53 | - date
54 |
--------------------------------------------------------------------------------
/Makefile_update:
--------------------------------------------------------------------------------
1 | ######
2 | #
3 | # HX-2019-12-18:
4 | # All the files in xanadu-lang/xanadu
5 | # are supposed to be copied for ATS-Xanadu
6 | #
7 | ######
8 |
9 | CPF=cp -f
10 | CPFR=cp -f -r
11 |
12 | ######
13 |
14 | all:: update
15 |
16 | ######
17 |
18 | update:: MISC
19 | update:: SATS
20 | update:: DATS
21 | update:: CATS
22 | update:: HATS
23 | update:: CONTRIB
24 |
25 | ######
26 |
27 | update:: PRETOP
28 | update:: PRESATS
29 | update:: PREDATS
30 | update:: PREDATSCATS
31 | update:: XATSLIB
32 |
33 | ######
34 |
35 | MISC:: ; \
36 | $(CPF) \
37 | $(XATSHOME)/srcgen/xats/Makefile_xatsopt ./srcgen/xats/.
38 | MISC:: ; \
39 | $(CPF) \
40 | $(XATSHOME)/srcgen/xats/TEST/Makefile_prelude ./srcgen/xats/TEST/.
41 | MISC:: ; \
42 | $(CPF) \
43 | $(XATSHOME)/srcgen/xats/TEST/Makefile_xatslib ./srcgen/xats/TEST/.
44 |
45 | ######
46 |
47 | SATS:: ; \
48 | $(CPF) $(XATSHOME)/srcgen/xats/SATS/*.sats ./srcgen/xats/SATS/.
49 |
50 | DATS:: ; \
51 | $(CPF) $(XATSHOME)/srcgen/xats/DATS/*.dats ./srcgen/xats/DATS/.
52 |
53 | CATS:: ; \
54 | $(CPF) $(XATSHOME)/srcgen/xats/CATS/*.cats ./srcgen/xats/CATS/.
55 |
56 | HATS:: ; \
57 | $(CPF) $(XATSHOME)/srcgen/xats/HATS/*.hats ./srcgen/xats/HATS/.
58 |
59 | CONTRIB:: ; \
60 | $(CPFR) $(XATSHOME)/srcgen/xats/DATS/CONTRIB ./srcgen/xats/DATS/.
61 |
62 | ######
63 | #
64 | PRETOP:: ; $(CPF) $(XATSHOME)/prelude/*.?ats ./prelude/.
65 | #
66 | PRESATS:: ; $(CPF) $(XATSHOME)/prelude/SATS/*.sats ./prelude/SATS/.
67 | PRESATS:: ; $(CPF) $(XATSHOME)/prelude/SATS/CC/*.sats ./prelude/SATS/CC/.
68 | #
69 | PREDATS:: ; $(CPF) $(XATSHOME)/prelude/DATS/*.dats ./prelude/DATS/.
70 | #
71 | PREDATSCATS:: \
72 | PREDATSCATS_JS
73 | PREDATSCATS_JS:: ; \
74 | $(CPF) $(XATSHOME)/prelude/DATS/CATS/JS/*.?ats ./prelude/DATS/CATS/JS/.
75 | PREDATSCATS_JS:: ; \
76 | $(CPF) \
77 | $(XATSHOME)/prelude/DATS/CATS/JS/Node/*.?ats ./prelude/DATS/CATS/JS/Node/.
78 | #
79 | PREDATSCATS:: \
80 | PREDATSCATS_Xint
81 | PREDATSCATS_Xint:: ; \
82 | $(CPF) $(XATSHOME)/prelude/DATS/CATS/Xint/*.dats ./prelude/DATS/CATS/Xint/.
83 | #
84 | ######
85 | #
86 | XATSLIB:: \
87 | XATSLIB_libc
88 | XATSLIB_libc:: ; \
89 | $(CPF) $(XATSHOME)/xatslib/libc/SATS/*.sats ./xatslib/libc/SATS/.
90 | XATSLIB_libc:: ; \
91 | $(CPF) $(XATSHOME)/xatslib/libc/DATS/*.dats ./xatslib/libc/DATS/.
92 | #
93 | XATSLIB_libc:: ; \
94 | $(CPF) $(XATSHOME)/xatslib/libc/DATS/CATS/Xint/*.?ats ./xatslib/libc/DATS/CATS/Xint/.
95 | #
96 | XATSLIB_libc:: ; \
97 | $(CPF) $(XATSHOME)/xatslib/libc/DATS/CATS/JS/Node/*.?ats ./xatslib/libc/DATS/CATS/JS/Node/.
98 | #
99 | ######
100 |
101 | XATSLIB:: \
102 | XATSLIB_githwxi
103 | XATSLIB_githwxi:: ; \
104 | $(CPF) $(XATSHOME)/xatslib/githwxi/SATS/*.sats ./xatslib/githwxi/SATS/.
105 | XATSLIB_githwxi:: ; \
106 | $(CPF) $(XATSHOME)/xatslib/githwxi/DATS/*.dats ./xatslib/githwxi/DATS/.
107 | XATSLIB_githwxi:: ; \
108 | $(CPF) $(XATSHOME)/xatslib/githwxi/TEST/*.dats ./xatslib/githwxi/TEST/.
109 |
110 | ###### end of [Makefile] ######
111 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # [ATS3](http://www.ats-lang.org/) - ATS/Xanadu
2 |
3 | A Programming Language System to Unleash the Potentials
4 | of Types and Templates
5 |
6 | ## Build Status
7 |
8 | * [](https://travis-ci.org/xanadu-lang/xanadu) Ubuntu
9 |
10 | ## Project Description
11 |
12 | ATS3 is an attempt to greatly improve upon ATS2. The version of ATS3
13 | in this repository is supposed to be used to generate *libxatsopt* for
14 | developing ATS3 tool support of all sorts.
15 |
16 | Probably the biggest problem with ATS2 is the *very* steep learning
17 | curve associated with it. Very few programmers were able to ever
18 | overcome it to reach the point where they could truly start enjoying
19 | the tremendous power of (advanced) type-checking and (embeddable)
20 | templates.
21 |
22 | When DML (the predecessor of ATS) was designed nearly 20 years ago, a
23 | two-layered approach to type-checking was taken: ML-like type-checking
24 | first and dependent type-checking second. This approach was later
25 | abandoned in the design of ATS. Instead, there is only dependent
26 | type-checking in ATS1 and ATS2. In ATS3, DML's two-layered approach is
27 | to be adopted. In particular, a program in ATS3 that passes ML-like
28 | type-checking can be compiled and executed. So one can skip dependent
29 | type-checking in ATS3 if one so chooses. In this way, the learning
30 | curve is expected to be greatly leveled. But there is much more than
31 | just leveling the learning curve.
32 |
33 | ML-like types are algebraic (involving no explicit quantifiers). Such
34 | types are so much friendlier than dependent types (which often involve
35 | explicit quantifiers) for supporting type-based meta-programming. It
36 | seems that a chance has finally arrived to properly address the
37 | problem of template instance resolution that causes so much annoyance
38 | in ATS2 (due to the very use of dependent types for template selection).
39 |
40 | In short, ATS3 adds an extra layer to ATS2 for supporting ML-like
41 | algebraic type-checking. Type-based meta-programming in ATS3 solely
42 | uses algebraic types (while ATS2 uses dependent types).
43 |
44 | ## Installing ATS3
45 |
46 | ATS3 is not ready for release yet.
47 |
48 | Please see
49 | [http://www.ats-lang.org/Downloads.html](http://www.ats-lang.org/Downloads.html) for
50 | instructions after it is officially released.
51 |
52 | ## Developing ATS3
53 |
54 | ## Documenting ATS3
55 |
56 | ## Licenses for ATS/Xanadu
57 |
58 | * The Compiler (ATS/Xanadu):
59 | [GPLv3](https://github.com/githwxi/ATS-Xanadu/blob/master/COPYING-gpl-3.0.txt)
60 | * The ATS source for the Libraries (ATSLIB/{prelude,libats}):
61 | [LGPLv3](https://github.com/githwxi/ATS-Xanadu/blob/master/COPYING-lgpl-3.0.txt).
62 | * As a special exception, any C code generated by the Compiler based on the Libraries
63 | source is not considered by default to be licensed under GPLv3/LGPLv3. If you use such
64 | C code together with other code to create an executable, then the C code by itself does
65 | not cause the executable to be covered by GPLv3/LGPLv3. However, there may be reasons
66 | unrelated to using ATS that can result in the executable being covered by GPLv3/LGPLv3.
67 | * The contributed portion (ATS/Xanadu/contrib) is released under the MIT license.
68 | * There is also a release under the MIT license for the C header files of the Libraries,
69 | which one can, for instance, freely insert into C code generated from ATS source code.
70 |
--------------------------------------------------------------------------------
/bin/.keeper:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xanadu-lang/xanadu/ae89a3b3b63e0a8d24ac234f8f715c4fec265992/bin/.keeper
--------------------------------------------------------------------------------
/lib/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xanadu-lang/xanadu/ae89a3b3b63e0a8d24ac234f8f715c4fec265992/lib/.gitkeep
--------------------------------------------------------------------------------
/prelude/DATS/CATS/JS/Node/g_print.cats:
--------------------------------------------------------------------------------
1 | /* ****** ****** */
2 | /*
3 | G_print for Xats2js/Node
4 | */
5 | /* ****** ****** */
6 | //
7 | function
8 | XATS2JS_NODE_g_print(obj)
9 | {
10 | let
11 | rep = obj.toString();
12 | process.stdout.write(rep);
13 | return; // XATS2JS_NODE_g_print
14 | }
15 | //
16 | /* ****** ****** */
17 | function
18 | XATS2JS_NODE_bool_print
19 | (b0)
20 | {
21 | if(b0)
22 | {
23 | XATS2JS_NODE_g_print("true");
24 | }
25 | else
26 | {
27 | XATS2JS_NODE_g_print("false");
28 | }
29 | return; // XATS2JS_NODE_bool_print
30 | }
31 | /* ****** ****** */
32 | function
33 | XATS2JS_NODE_char_print
34 | (c0)
35 | {
36 | // c0: number
37 | XATS2JS_NODE_g_print
38 | (String.fromCharCode(c0));
39 | return; // XATS2JS_NODE_char_print
40 | }
41 | /* ****** ****** */
42 | function
43 | XATS2JS_NODE_gint_print_sint
44 | (x0)
45 | {
46 | XATS2JS_NODE_g_print(x0);
47 | return; // gint_print_sint<>
48 | }
49 | function
50 | XATS2JS_NODE_gint_print_uint
51 | (x0)
52 | {
53 | XATS2JS_NODE_g_print(x0);
54 | return; // gint_print_uint<>
55 | }
56 | /* ****** ****** */
57 | function
58 | XATS2JS_NODE_gflt_print_sflt
59 | (x0)
60 | {
61 | XATS2JS_NODE_g_print(x0);
62 | return; // gflt_print_sflt<>
63 | }
64 | function
65 | XATS2JS_NODE_gflt_print_dflt
66 | (x0)
67 | {
68 | XATS2JS_NODE_g_print(x0);
69 | return; // gflt_print_dflt<>
70 | }
71 | /* ****** ****** */
72 | function
73 | XATS2JS_NODE_string_print
74 | (cs)
75 | {
76 | return XATS2JS_NODE_g_print(cs);
77 | }
78 | /* ****** ****** */
79 |
80 | /* end of [XATS2JS_NODE_g_print.cats] */
81 |
--------------------------------------------------------------------------------
/prelude/DATS/CATS/JS/Node/g_print.dats:
--------------------------------------------------------------------------------
1 | (* ****** ****** *)
2 | (*
3 | Print for Xats2js/Node
4 | *)
5 | (* ****** ****** *)
6 | //
7 | impltmp
8 | bool_print<> =
9 | XATS2JS_NODE_bool_print
10 | where
11 | {
12 | #extern
13 | fun
14 | XATS2JS_NODE_bool_print
15 | (b0: bool): void = $exname()
16 | }
17 | //
18 | (* ****** ****** *)
19 | //
20 | impltmp
21 | char_print<> =
22 | XATS2JS_NODE_char_print
23 | where
24 | {
25 | #extern
26 | fun
27 | XATS2JS_NODE_char_print
28 | (b0: char): void = $exname()
29 | }
30 | //
31 | (* ****** ****** *)
32 | impltmp
33 | string_print<> =
34 | XATS2JS_NODE_string_print
35 | where
36 | {
37 | #extern
38 | fun
39 | XATS2JS_NODE_string_print
40 | (cs: string): void = $exname()
41 | }
42 | (* ****** ****** *)
43 | //
44 | local
45 | #extern
46 | fun
47 | XATS2JS_NODE_gint_print_sint
48 | (x0: sint): void = $exname()
49 | #extern
50 | fun
51 | XATS2JS_NODE_gint_print_uint
52 | (x0: uint): void = $exname()
53 | in
54 | impltmp
55 | gint_print_sint<> = XATS2JS_NODE_gint_print_sint
56 | impltmp
57 | gint_print_uint<> = XATS2JS_NODE_gint_print_uint
58 | end // end of [local]
59 | //
60 | (* ****** ****** *)
61 | //
62 | local
63 | #extern
64 | fun
65 | XATS2JS_NODE_gflt_print_sflt
66 | (x0: sflt): void = $exname()
67 | #extern
68 | fun
69 | XATS2JS_NODE_gflt_print_dflt
70 | (x0: dflt): void = $exname()
71 | in
72 | impltmp
73 | gflt_print_sflt<> = XATS2JS_NODE_gflt_print_sflt
74 | impltmp
75 | gflt_print_dflt<> = XATS2JS_NODE_gflt_print_dflt
76 | end // end of [local]
77 | //
78 | (* ****** ****** *)
79 |
80 | (* end of [XATS2JS_NODE_g_print.dats] *)
81 |
--------------------------------------------------------------------------------
/prelude/DATS/CATS/JS/g_eqref.cats:
--------------------------------------------------------------------------------
1 | /* ****** ****** */
2 | /*
3 | G_eqref for Xats2js
4 | */
5 | /* ****** ****** */
6 |
7 | function
8 | XATS2JS_g_eqref
9 | (x1, x2)
10 | {
11 | return (x1 === x2);
12 | }
13 | function
14 | XATS2JS_g_neqrf
15 | (x1, x2)
16 | {
17 | return (x1 !== x2);
18 | }
19 |
20 | /* ****** ****** */
21 |
22 | /* end of [XATS2JS_g_eqref.cats] */
23 |
--------------------------------------------------------------------------------
/prelude/DATS/CATS/JS/g_eqref.dats:
--------------------------------------------------------------------------------
1 | (* ****** ****** *)
2 | (*
3 | Eqref for Xats2js
4 | *)
5 | (* ****** ****** *)
6 | //
7 | impltmp
8 | {a:t0}
9 | g_eqref =
10 | XATS2JS_g_eqref{a}
11 | where
12 | {
13 | #extern
14 | fun
15 | XATS2JS_g_eqref
16 | {a:t0}
17 | (x1: a, x2: a): bool = $exname()
18 | }
19 | //
20 | impltmp
21 | {a:t0}
22 | g_neqrf =
23 | XATS2JS_g_neqrf{a}
24 | where
25 | {
26 | #extern
27 | fun
28 | XATS2JS_g_neqrf
29 | {a:t0}
30 | (x1: a, x2: a): bool = $exname()
31 | }
32 | //
33 | (* ****** ****** *)
34 |
35 | (* end of [XATS2JS_g_eqref.dats] *)
36 |
--------------------------------------------------------------------------------
/prelude/DATS/CATS/JS/g_print.cats:
--------------------------------------------------------------------------------
1 | /* ****** ****** */
2 | /*
3 | G_print for Xats2js
4 | */
5 | /* ****** ****** */
6 | //
7 | var
8 | XATS2JS_the_print_store = [];
9 | //
10 | /* ****** ****** */
11 |
12 | function
13 | XATS2JS_g_print(obj)
14 | {
15 | var
16 | rep = obj.toString();
17 | XATS2JS_the_print_store.push(rep);
18 | return; // XATS2JS_g_print
19 | }
20 |
21 | /* ****** ****** */
22 | function
23 | XATS2JS_bool_print
24 | (b0)
25 | {
26 | if(b0)
27 | {
28 | XATS2JS_g_print("true");
29 | }
30 | else
31 | {
32 | XATS2JS_g_print("false");
33 | }
34 | return; // XATS2JS_bool_print
35 | }
36 | /* ****** ****** */
37 | function
38 | XATS2JS_char_print
39 | (c0)
40 | {
41 | // c0: number
42 | XATS2JS_g_print
43 | (String.fromCharCode(c0));
44 | return; // XATS2JS_char_print
45 | }
46 | /* ****** ****** */
47 | function
48 | XATS2JS_gint_print_sint
49 | (x0)
50 | {
51 | XATS2JS_g_print(x0);
52 | return; // gint_print_sint
53 | }
54 | function
55 | XATS2JS_gint_print_uint
56 | (x0)
57 | {
58 | XATS2JS_g_print(x0);
59 | return; // gint_print_uint
60 | }
61 | /* ****** ****** */
62 | function
63 | XATS2JS_gflt_print_sflt
64 | (x0)
65 | {
66 | XATS2JS_g_print(x0);
67 | return; // gint_print_sflt
68 | }
69 | function
70 | XATS2JS_gflt_print_dflt
71 | (x0)
72 | {
73 | XATS2JS_g_print(x0);
74 | return; // gint_print_dflt
75 | }
76 | /* ****** ****** */
77 | function
78 | XATS2JS_string_print
79 | (cs)
80 | {
81 | return XATS2JS_g_print(cs);
82 | }
83 | /* ****** ****** */
84 |
85 | function
86 | XATS2JS_the_print_store_join()
87 | {
88 | var
89 | rep =
90 | XATS2JS_the_print_store.join("");
91 | return rep;
92 | } // XATS2JS_the_print_store_join
93 |
94 | /* ****** ****** */
95 |
96 | function
97 | XATS2JS_the_print_store_clear()
98 | {
99 | XATS2JS_the_print_store = []; return;
100 | } // XATS2JS_the_print_store_clear
101 |
102 | /* ****** ****** */
103 |
104 | /* end of [XATS2JS_g_print.cats] */
105 |
--------------------------------------------------------------------------------
/prelude/DATS/CATS/JS/g_print.dats:
--------------------------------------------------------------------------------
1 | (* ****** ****** *)
2 | (*
3 | Print for Xats2js
4 | *)
5 | (* ****** ****** *)
6 | //
7 | impltmp
8 | bool_print<> =
9 | XATS2JS_bool_print
10 | where
11 | {
12 | #extern
13 | fun
14 | XATS2JS_bool_print
15 | (b0: bool): void = $exname()
16 | }
17 | //
18 | (* ****** ****** *)
19 | //
20 | impltmp
21 | char_print<> =
22 | XATS2JS_char_print
23 | where
24 | {
25 | #extern
26 | fun
27 | XATS2JS_char_print
28 | (b0: char): void = $exname()
29 | }
30 | //
31 | (* ****** ****** *)
32 | //
33 | impltmp
34 | gint_print_sint<> =
35 | XATS2JS_gint_print_sint
36 | where
37 | {
38 | #extern
39 | fun
40 | XATS2JS_gint_print_sint
41 | ( x0: sint ): void = $exname()
42 | }
43 | //
44 | impltmp
45 | gint_print_uint<> =
46 | XATS2JS_gint_print_uint
47 | where
48 | {
49 | #extern
50 | fun
51 | XATS2JS_gint_print_uint
52 | ( x0: uint ): void = $exname()
53 | }
54 | //
55 | (* ****** ****** *)
56 | //
57 | impltmp
58 | gflt_print_sflt<> =
59 | XATS2JS_gflt_print_sflt
60 | where
61 | {
62 | #extern
63 | fun
64 | XATS2JS_gflt_print_sflt
65 | ( x0: sflt ): void = $exname()
66 | }
67 | //
68 | impltmp
69 | gflt_print_dflt<> =
70 | XATS2JS_gflt_print_dflt
71 | where
72 | {
73 | #extern
74 | fun
75 | XATS2JS_gflt_print_dflt
76 | ( x0: dflt ): void = $exname()
77 | }
78 | //
79 | (* ****** ****** *)
80 | impltmp
81 | string_print<> =
82 | XATS2JS_string_print
83 | where
84 | {
85 | #extern
86 | fun
87 | XATS2JS_string_print
88 | (cs: string): void = $exname()
89 | }
90 | (* ****** ****** *)
91 | //
92 | #extern
93 | fun
94 | XATS2JS_the_print_store_join(): string = $exname()
95 | #extern
96 | fun
97 | XATS2JS_the_print_store_clear(): (void) = $exname()
98 | //
99 | (* ****** ****** *)
100 |
101 | (* end of [XATS2JS_g_print.dats] *)
102 |
--------------------------------------------------------------------------------
/prelude/DATS/CATS/JS/jsbasics.cats:
--------------------------------------------------------------------------------
1 | /* ****** ****** */
2 | /*
3 | JSBasics for Xats2js
4 | */
5 | /* ****** ****** */
6 | function
7 | XATS2JS_jsobj_get_at
8 | (obj, key)
9 | {
10 | return obj[ key ];
11 | }
12 | function
13 | XATS2JS_jsobj_set_at
14 | (obj, key, itm)
15 | {
16 | return (obj[key] = itm);
17 | }
18 | /* ****** ****** */
19 | // HX-2020-11-09:
20 | // Native arrays for Xats2js
21 | /* ****** ****** */
22 |
23 | function
24 | XATS2JS_jsarray_size
25 | ( xs )
26 | {
27 | return ( xs.length );
28 | }
29 | function
30 | XATS2JS_jsarray_length
31 | ( xs )
32 | {
33 | return ( xs.length );
34 | }
35 |
36 | /* ****** ****** */
37 |
38 | function
39 | XATS2JS_jsarray_get_at
40 | (xs, i0)
41 | {
42 | return xs[i0];
43 | }
44 | function
45 | XATS2JS_jsarray_set_at
46 | (xs, i0, x0)
47 | {
48 | return ( xs[i0] = x0 );
49 | }
50 |
51 | /* ****** ****** */
52 | //
53 | // HX-2020-11-28:
54 | // Native objmaps for Xats2js
55 | //
56 | /* ****** ****** */
57 |
58 | function
59 | XATS2JS_jsobjmap_keys
60 | (obj)
61 | {
62 | return Object.keys(obj);
63 | } // XATS2JS_jsobjmap_keys
64 |
65 | /* ****** ****** */
66 |
67 | function
68 | XATS2JS_jsobjmap_keyq
69 | (obj, key)
70 | {
71 | return obj.hasOwnProperty(key);
72 | } // XATS2JS_jsobjmap_keyq
73 |
74 | /* ****** ****** */
75 |
76 | function
77 | XATS2JS_jsobjmap_make_nil
78 | ()
79 | {
80 | return {} ;
81 | } // XATS2JS_jsobjmap_make_nil
82 |
83 | /* ****** ****** */
84 |
85 | function
86 | XATS2JS_jsobjmap_search_opt
87 | (obj, key)
88 | {
89 | //
90 | let itm0 = obj[key];
91 | //
92 | if(itm0===undefined)
93 | {
94 | return XATS2JS_optn_vt_nil();
95 | } else {
96 | return XATS2JS_optn_vt_cons(itm0);
97 | } // end of [if]
98 | //
99 | } // [ XATS2JS_jsobjmap_search_opt ]
100 |
101 | /* ****** ****** */
102 |
103 | function
104 | XATS2JS_jsobjmap_insert_any
105 | (obj, key, itm1)
106 | {
107 | obj[key] = itm1; return;
108 | } // [XATS2JS_jsobjmap_insert_any]
109 |
110 | function
111 | XATS2JS_jsobjmap_remove_any
112 | (obj, key)
113 | {
114 | delete object[key]; return ;
115 | } // [XATS2JS_jsobjmap_remove_any]
116 |
117 | /* ****** ****** */
118 |
119 | function
120 | XATS2JS_jsobjmap_insert_opt
121 | (obj, key, itm1)
122 | {
123 | //
124 | let itm0 = obj[key];
125 | //
126 | if(itm0===undefined)
127 | {
128 | obj[key] = itm1;
129 | return XATS2JS_optn_vt_nil();
130 | } else {
131 | obj[key] = itm1;
132 | return XATS2JS_optn_vt_cons(itm0);
133 | } // end of [if]
134 | //
135 | } // [ XATS2JS_jsobjmap_insert_opt ]
136 |
137 | function
138 | XATS2JS_jsobjmap_remove_opt
139 | (obj, key)
140 | {
141 | //
142 | let itm0 = obj[key];
143 | //
144 | if(itm0===undefined)
145 | {
146 | return XATS2JS_optn_vt_nil();
147 | } else {
148 | delete object[key];
149 | return XATS2JS_optn_vt_cons(itm0);
150 | } // end of [if]
151 | //
152 | } // [ XATS2JS_jsobjmap_remove_opt ]
153 |
154 | /* ****** ****** */
155 |
156 | /* end of [XATS2JS_jsbasics.cats] */
157 |
--------------------------------------------------------------------------------
/prelude/DATS/CATS/JS/unsafe.dats:
--------------------------------------------------------------------------------
1 | (* ****** ****** *)
2 | (*
3 | ** HX-2020-09:
4 | ** xats2js:
5 | ** for unsafe functions
6 | *)
7 | (* ****** ****** *)
8 | #staload
9 | UN =
10 | "prelude/SATS/unsafe.sats"
11 | (* ****** ****** *)
12 | #extern
13 | fun
14 | XATS2JS_UN_p2tr_get
15 | {a:vt}
16 | ( p0
17 | : p2tr(a)): (a)
18 | = $exname((*self*))
19 | impltmp
20 | (*tmp*)
21 | $UN.p2tr_get = XATS2JS_UN_p2tr_get
22 | (* ****** ****** *)
23 | #extern
24 | fun
25 | XATS2JS_UN_p2tr_set
26 | {a:vt}
27 | ( p0
28 | : p2tr(a), x0: a): void
29 | = $exname((*self*))
30 | impltmp
31 | (*tmp*)
32 | $UN.p2tr_set = XATS2JS_UN_p2tr_set
33 | (* ****** ****** *)
34 |
35 | (* end of [XATS2JS_unsafe.dats] *)
36 |
--------------------------------------------------------------------------------
/prelude/DATS/CATS/Xint/.keeper:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xanadu-lang/xanadu/ae89a3b3b63e0a8d24ac234f8f715c4fec265992/prelude/DATS/CATS/Xint/.keeper
--------------------------------------------------------------------------------
/prelude/DATS/CATS/Xint/prelude.dats:
--------------------------------------------------------------------------------
1 | (* ****** ****** *)
2 | (*
3 | HX: for pure C-arrays
4 | *)
5 | (* ****** ****** *)
6 | (*
7 | #staload
8 | "./../SATS/array.sats"
9 | *)
10 | (* ****** ****** *)
11 | #staload
12 | UN =
13 | "prelude/SATS/unsafe.sats"
14 | (* ****** ****** *)
15 | //
16 | (*
17 | // prelude/array.sats
18 | // arrays of
19 | // various dimensionality
20 | *)
21 | //
22 | (* ****** ****** *)
23 | //
24 | (*
25 | HX-2020-10-25:
26 | A C-style implementation
27 | does not work in general
28 | *)
29 | //
30 | impltmp
31 |
32 | a0ptr_make(x0) =
33 | let
34 | val A0 =
35 | a0ptr_alloc()
36 | val p0 =
37 | $UN.cast10{p2tr(a)}(A0)
38 | val () =
39 | $UN.p2tr_set(p0, x0)
40 | in
41 | $UN.castlin10{a0ptr(a)}(A0)
42 | end
43 | //
44 | (* ****** ****** *)
45 | //
46 | (*
47 | HX-2010-10-25:
48 | A C-style implementation
49 | does not work in general
50 | *)
51 | //
52 | impltmp
53 |
54 | a1ref_listize
55 | {n}(A0) = let
56 | //
57 | var
58 | res:
59 | ?list_vt(a) =
60 | list_vt_nil()
61 | val p0 = $addr(res)
62 | //
63 | val n0 =
64 | a1ref_length(A0)
65 | val n1 = pred(n0)
66 | //
67 | impltmp
68 | x1forint$work(i0) =
69 | let
70 | val j0 = n1 - i0
71 | val x0 = get_at(A0, j0)
72 | in
73 | $UN.p2tr_set_list_vt_cons(p0, x0)
74 | end
75 | //
76 | in
77 | let
78 | val () =
79 | g_x1forint(n0) in $UN.castlin10(res)
80 | end
81 | end // end of [a1ref_listize]
82 | //
83 | (* ****** ****** *)
84 |
85 | (* end of [XINTERP_prelude.dats] *)
86 |
--------------------------------------------------------------------------------
/prelude/DATS/bool.dats:
--------------------------------------------------------------------------------
1 | (***********************************************************************)
2 | (* *)
3 | (* Applied Type System *)
4 | (* *)
5 | (***********************************************************************)
6 |
7 | (*
8 | ** ATS/Xanadu - Unleashing the Potential of Types!
9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc.
10 | ** All rights reserved
11 | **
12 | ** ATS is free software; you can redistribute it and/or modify it under
13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
14 | ** Free Software Foundation; either version 3, or (at your option) any
15 | ** later version.
16 | **
17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 | ** for more details.
21 | **
22 | ** You should have received a copy of the GNU General Public License
23 | ** along with ATS; see the file COPYING. If not, please write to the
24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
25 | ** 02110-1301, USA.
26 | *)
27 |
28 | (* ****** ****** *)
29 | //
30 | // Author: Hongwei Xi
31 | // Start Time: March, 2020
32 | // Authoremail: gmhwxiATgmailDOTcom
33 | //
34 | (* ****** ****** *)
35 | //
36 | impltmp
37 | bool_print<>(b0) =
38 | if b0
39 | then g_print("true")
40 | else g_print("false")
41 | //
42 | (* ****** ****** *)
43 | //
44 | impltmp
45 | bool_parse<>(rep) =
46 | (
47 | case+ rep of
48 | | "false" => false
49 | (*
50 | | "False" => false
51 | | "FALSE" => false
52 | | "" => false | "0" => false
53 | | "ff" => false | "Ff" => false | "FF" => false
54 | | "nil" => false | "Nil" => false | "NIL" => false
55 | | "none" => false | "None" => false | "NONE" => false
56 | | "null" => false | "Null" => false | "NULL" => false
57 | *)
58 | | _ (* else *) => true
59 | )
60 | //
61 | (* ****** ****** *)
62 | //
63 | impltmp
64 | (*tmp*)
65 | bool_ifval
66 | (b, x, y) = if b then x else y
67 | //
68 | (* ****** ****** *)
69 | //
70 | // HX:
71 | // For implementing
72 | // some g-operations
73 | //
74 | (* ****** ****** *)
75 | impltmp
76 | g_eqref = g_equal
77 | impltmp
78 | g_neqrf = g_noteq
79 | (* ****** ****** *)
80 | impltmp
81 | g_print = bool_print< >
82 | (* ****** ****** *)
83 |
84 | (* end of [bool.dats] *)
85 |
--------------------------------------------------------------------------------
/prelude/DATS/char.dats:
--------------------------------------------------------------------------------
1 | (***********************************************************************)
2 | (* *)
3 | (* Applied Type System *)
4 | (* *)
5 | (***********************************************************************)
6 |
7 | (*
8 | ** ATS/Xanadu - Unleashing the Potential of Types!
9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc.
10 | ** All rights reserved
11 | **
12 | ** ATS is free software; you can redistribute it and/or modify it under
13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
14 | ** Free Software Foundation; either version 3, or (at your option) any
15 | ** later version.
16 | **
17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 | ** for more details.
21 | **
22 | ** You should have received a copy of the GNU General Public License
23 | ** along with ATS; see the file COPYING. If not, please write to the
24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
25 | ** 02110-1301, USA.
26 | *)
27 |
28 | (* ****** ****** *)
29 | //
30 | // Author: Hongwei Xi
31 | // Start Time: March, 2020
32 | // Authoremail: gmhwxiATgmailDOTcom
33 | //
34 | (* ****** ****** *)
35 | //
36 | impltmp
37 | <>(*tmp*)
38 | char_noteq
39 | (c1, c2) =
40 | (
41 | not(char_equal(c1, c2))
42 | )
43 | //
44 | (* ****** ****** *)
45 | //
46 | impltmp
47 | <>(*tmp*)
48 | sub_char_char
49 | (c1, c2) =
50 | ( sint(c1) - sint(c2) )
51 | //
52 | (* ****** ****** *)
53 |
54 | impltmp
55 | <>(*tmp*)
56 | char_lower
57 | (c0) =
58 | (
59 | if
60 | (c0 < 'A')
61 | then c0 else
62 | (
63 | if
64 | (c0 > 'Z')
65 | then c0 else
66 | char(sint('a')+(sint(c0)-sint('A')))
67 | )
68 | ) (* end of [char_lower] *)
69 |
70 | impltmp
71 | <>(*tmp*)
72 | char_upper
73 | (c0) =
74 | (
75 | if
76 | (c0 < 'a')
77 | then c0 else
78 | (
79 | if
80 | (c0 > 'z')
81 | then c0 else
82 | char(sint('A')+(sint(c0)-sint('a')))
83 | )
84 | ) (* end of [char_upper] *)
85 |
86 | (* ****** ****** *)
87 | //
88 | // HX:
89 | // For implementing
90 | // some g-operations
91 | //
92 | (* ****** ****** *)
93 |
94 | impltmp
95 | g_cmp = char_cmp<>
96 |
97 | (* ****** ****** *)
98 |
99 | impltmp
100 | g_equal = char_equal<>
101 | impltmp
102 | g_noteq = char_noteq<>
103 |
104 | (* ****** ****** *)
105 | impltmp
106 | g_eqref = g_equal
107 | impltmp
108 | g_neqrf = g_noteq
109 | (* ****** ****** *)
110 |
111 | impltmp
112 | g_print = char_print< >
113 |
114 | (* ****** ****** *)
115 |
116 | (* end of [char.dats] *)
117 |
--------------------------------------------------------------------------------
/prelude/DATS/gbas.dats:
--------------------------------------------------------------------------------
1 | (* ****** ****** *)
2 | (*
3 | ** for generics
4 | *)
5 | (* ****** ****** *)
6 | (*
7 | #staload
8 | "./../SATS/gbas.sats"
9 | *)
10 | (* ****** ****** *)
11 |
12 | impltmp
13 | {a:vt}
14 | g_self(x) = x
15 |
16 | (* ****** ****** *)
17 |
18 | impltmp
19 | {a:t0}
20 | g_free(x) = ()
21 |
22 | (* ****** ****** *)
23 |
24 | impltmp
25 | {a:t0}
26 | g_copy(x) = (x)
27 |
28 | (* ****** ****** *)
29 | //
30 | (*
31 | HX-2020-06-06:
32 | Please do see
33 | the circular beauty :)
34 | *)
35 | //
36 | (*
37 | impltmp
38 | {a:t0}
39 | g_equal
40 | (x, y) =
41 | (
42 | not(g_noteq(x, y))
43 | )
44 | *)
45 | //
46 | impltmp
47 | {a:t0}
48 | g_noteq
49 | (x, y) =
50 | (
51 | not(g_equal(x, y))
52 | )
53 | //
54 | (* ****** ****** *)
55 | //
56 | impltmp
57 | {a:t0}
58 | g_equal = g_eq
59 | (*
60 | impltmp
61 | {a:t0}
62 | g_noteq = g_neq
63 | *)
64 | //
65 | (* ****** ****** *)
66 | //
67 | (*
68 | impltmp
69 | {a:t0}
70 | g_eqref
71 | (x, y) =
72 | (
73 | not(g_neqrf(x, y))
74 | )
75 | *)
76 | //
77 | impltmp
78 | {a:t0}
79 | g_neqrf
80 | (x, y) =
81 | (
82 | not(g_eqref(x, y))
83 | )
84 | //
85 | (* ****** ****** *)
86 | //
87 | impltmp
88 | {a:vt}
89 | gl_print0(x) =
90 | ( g_free(x) ) where
91 | {
92 | val () = gl_print1(x)
93 | } (* end of [gl_print0] *)
94 | //
95 | impltmp
96 | {a:t0}
97 | gl_print1 = g_print
98 | //
99 | (* ****** ****** *)
100 | //
101 | impltmp
102 |
103 | mapoptn$fopr(x0) =
104 | if
105 | filter$test(x0)
106 | then
107 | (
108 | optn_vt_cons(y0)
109 | ) where
110 | {
111 | val y0 =
112 | map$fopr(x0)
113 | }
114 | else
115 | (
116 | optn_vt_nil((*void*))
117 | )
118 | //
119 | (* ****** ****** *)
120 | //
121 | impltmp
122 |
123 | mapoptn0$fopr(x0) =
124 | if
125 | filter1$test(x0)
126 | then
127 | (
128 | optn_vt_cons(y0)
129 | ) where
130 | {
131 | val y0 =
132 | map0$fopr(x0)
133 | }
134 | else
135 | (
136 | optn_vt_nil((*void*))
137 | ) where
138 | {
139 | val () = g_free(x0)
140 | } (* end of [mapoptn0$fopr] *)
141 | //
142 | impltmp
143 |
144 | mapoptn1$fopr(x0) =
145 | if
146 | filter1$test(x0)
147 | then
148 | (
149 | optn_vt_cons(y0)
150 | ) where
151 | {
152 | val y0 =
153 | map1$fopr(x0)
154 | }
155 | else
156 | (
157 | optn_vt_nil((*void*))
158 | ) (* end of [mapoptn1$fopr] *)
159 |
160 | (* ****** ****** *)
161 | (*
162 | imptmp
163 | {x0:t0}
164 | group0$test = group$test
165 | *)
166 | (* ****** ****** *)
167 | //
168 | impltmp
169 | <>(*tmp*)
170 | x2foreach_row$beg() = ((*void*))
171 | impltmp
172 | <>(*tmp*)
173 | x2foreach_row$end() = ((*void*))
174 | //
175 | impltmp
176 | <>(*tmp*)
177 | x2foreach_col$beg() = ((*void*))
178 | impltmp
179 | <>(*tmp*)
180 | x2foreach_col$end() = ((*void*))
181 | //
182 | (* ****** ****** *)
183 |
184 | (* end of [gbas.dats] *)
185 |
--------------------------------------------------------------------------------
/prelude/DATS/gfor.dats:
--------------------------------------------------------------------------------
1 | (* ****** ****** *)
2 | (*
3 | ** For forint-loops
4 | *)
5 | (* ****** ****** *)
6 | //
7 | (*
8 | #staload
9 | "./../SATS/xfor.sats"
10 | *)
11 | //
12 | (* ****** ****** *)
13 |
14 | impltmp
15 | (*tmp*)
16 | g_x1forint
17 | ( n1 ) =
18 | loop(0, n1) where
19 | {
20 | fun
21 | loop
22 | {n1:int
23 | ;i1:nat
24 | |i1<=n1}..
25 | ( i1:int(i1)
26 | , n1:int(n1)): void =
27 | if
28 | (i1 < n1)
29 | then
30 | (
31 | loop(succ(i1), n1)
32 | ) where
33 | {
34 | val () = x1forint$work(i1)
35 | }
36 | else ( (* else *) )
37 | } (* end of [g_x1forint] *)
38 |
39 | (* ****** ****** *)
40 |
41 | impltmp
42 |
43 | g_x2forint
44 | ( n1, n2 ) =
45 | let
46 | fun
47 | loop1
48 | ( i1
49 | : nintlt(n1)) =
50 | (
51 | g_x1forint( n2 )
52 | ) where
53 | {
54 | impltmp
55 | x1forint$work
56 | (i2) =
57 | (
58 | x2forint$work(i1, i2)
59 | )
60 | }
61 | in
62 | (
63 | g_x1forint( n1 )
64 | ) where
65 | {
66 | impltmp x1forint$work = loop1
67 | }
68 | end (* end of [x2forint] *)
69 |
70 | (* ****** ****** *)
71 |
72 | impltmp
73 |
74 | g_x3forint(n1,n2,n3) =
75 | let
76 | fun
77 | loop1
78 | ( i1
79 | : nintlt(n1)) =
80 | (
81 | g_x2forint(n2,n3)
82 | ) where
83 | {
84 | impltmp
85 | x2forint$work
86 | (i2, i3) =
87 | (
88 | x3forint$work(i1, i2, i3)
89 | )
90 | }
91 | in
92 | (
93 | g_x1forint( n1 )
94 | ) where
95 | {
96 | impltmp x1forint$work = loop1
97 | }
98 | end (* end of [x3forint] *)
99 |
100 | (* ****** ****** *)
101 |
102 | (* end of [gfor.dats] *)
103 |
--------------------------------------------------------------------------------
/prelude/DATS/gfun.dats:
--------------------------------------------------------------------------------
1 | (* ****** ****** *)
2 | (*
3 | ** For function ops
4 | *)
5 | (* ****** ****** *)
6 | //
7 | (*
8 | #staload
9 | "./../SATS/gfun.sats"
10 | *)
11 | //
12 | (* ****** ****** *)
13 | //
14 | impltmp
15 |
16 | gfun_not_fnp1
17 | (f0) =
18 | lam(x1) => not(f0(x1))
19 | impltmp
20 |
21 | gfun_not_cfr1
22 | (f0) =
23 | lam(x1) => not(f0(x1))
24 | //
25 | (* ****** ****** *)
26 |
27 | impltmp
28 |
29 | gfun_memq_gseq(xs) =
30 | lam(x0) =>
31 | gseq_memberq(xs, x0)
32 |
33 | (* ****** ****** *)
34 |
35 | (* end of [gfun.dats] *)
36 |
--------------------------------------------------------------------------------
/prelude/DATS/gios.dats:
--------------------------------------------------------------------------------
1 | (***********************************************************************)
2 | (* *)
3 | (* Applied Type System *)
4 | (* *)
5 | (***********************************************************************)
6 |
7 | (*
8 | ** ATS/Xanadu - Unleashing the Potential of Types!
9 | ** Copyright (C) 2020 Hongwei Xi, ATS Trustful Software, Inc.
10 | ** All rights reserved
11 | **
12 | ** ATS is free software; you can redistribute it and/or modify it under
13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
14 | ** Free Software Foundation; either version 3, or (at your option) any
15 | ** later version.
16 | **
17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 | ** for more details.
21 | **
22 | ** You should have received a copy of the GNU General Public License
23 | ** along with ATS; see the file COPYING. If not, please write to the
24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
25 | ** 02110-1301, USA.
26 | *)
27 |
28 | (* ****** ****** *)
29 | //
30 | // For generic ordering
31 | //
32 | (* ****** ****** *)
33 | //
34 | // Author: Hongwei Xi
35 | // Start Time: April, 2020
36 | // Authoremail: gmhwxiATgmailDOTcom
37 | //
38 | (* ****** ****** *)
39 | //
40 | (*
41 | #staload
42 | "./../SATS/gios.sats"
43 | *)
44 | //
45 | (* ****** ****** *)
46 | //
47 | #staload
48 | "xatslib\
49 | /libc/DATS/stdio.dats"
50 | //
51 | (* ****** ****** *)
52 |
53 | impltmp
54 | <>(*tmp*)
55 | g_inp_char() =
56 | fgetc_ref(g_stdin<>())
57 |
58 | (* ****** ****** *)
59 |
60 | impltmp
61 | <>(*tmp*)
62 | g_inp_cstream() =
63 | (
64 | auxmain(g_stdin<>())
65 | ) where
66 | {
67 | //
68 | fun
69 | auxmain
70 | (
71 | fr: FILEref
72 | ) : stream_vt(int) =
73 | $llazy
74 | (
75 | let
76 | val c0 = fgetc_ref(fr)
77 | in
78 | if
79 | (c0 < 0) // EOF
80 | then
81 | strmcon_vt_nil((*void*))
82 | else
83 | strmcon_vt_cons(c0, auxmain(fr))
84 | end // end of [let]
85 | )
86 | //
87 | } (* end of [g_inp_chars] *)
88 |
89 | (* ****** ****** *)
90 | //
91 | impltmp
92 | <>(*tmp*)
93 | g_inp_line_list() =
94 | list_vt2t{char}(g_inp_lline_list<>())
95 | //
96 | (* ****** ****** *)
97 |
98 | impltmp
99 | <>(*tmp*)
100 | g_inp_lline_list() =
101 | let
102 | //
103 | val EOL = '\n'
104 | //
105 | fun
106 | loop
107 | ( cs
108 | : list_vt(char)): list_vt(char) =
109 | let
110 | val c0 = g_inp_char<>()
111 | in
112 | if
113 | (c0 >= 0)
114 | then
115 | let
116 | val c0 = char(c0)
117 | in
118 | if
119 | (c0 = EOL)
120 | then cs else loop(list_vt_cons(c0, cs))
121 | end
122 | else cs // end of [else]
123 | end
124 | //
125 | in
126 | list_vt_reverse(loop(list_vt_nil()))
127 | end // end of [g_inp_lline_list]
128 |
129 | (* ****** ****** *)
130 |
131 | (* end of [gios.dats] *)
132 |
--------------------------------------------------------------------------------
/prelude/DATS/gmap.dats:
--------------------------------------------------------------------------------
1 | (* ****** ****** *)
2 | (*
3 | //
4 | // HX-2020-12-04:
5 | // For gmap-operations
6 | //
7 | *)
8 | (* ****** ****** *)
9 |
10 | #staload
11 | UN =
12 | "prelude/SATS/unsafe.sats"
13 |
14 | (* ****** ****** *)
15 |
16 | (*
17 | impltmp
18 |