This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* ****** ****** *) | |
// Monads in ATS2 using templates | |
#include | |
"share/atspre_define.hats" | |
(* ****** ****** *) | |
// the interface | |
abst@ype M (t@ype) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include | |
"share/atspre_staload.hats" | |
staload UN = "prelude/SATS/unsafe.sats" | |
#define N 5 | |
extern | |
fun{env:vt@ype} | |
loop$fwork (natLt(N), &(env) >> _): void |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// License: BSD 3-clause | |
// Author: Artyom Shalkhakov | |
// Date: Sep 22, 2015 | |
// | |
// About: this is a POC of n-tuples and row types implemented | |
// using Reflection.Emit. The mutation interface (get/set methods) | |
// involves no boxing, but the caller has to supply the type parameter | |
// that matches the type of the value at the given position. Position | |
// is resolved using a jump table (TODO: does it translate to threaded | |
// code?). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// compile with atscc, compiler for ATS, an ML dialect | |
// see <www.ats-lang.org> | |
staload _ = "prelude/DATS/list.dats" | |
staload _ = "prelude/DATS/string.dats" | |
// the type of dynamic terms | |
// NOTE: using an abstract type here would be true | |
// to the spirit of dynamically typed languages | |
datatype DT = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
** Hello, world! | |
** | |
** Q: how to extract substring of input string ending at the first unclosed parens? | |
** ex. sldfkjsf(sldfkj)lskdjff(sdfsdf) -- this is balanced, return as-is | |
** ex. (sldfkj(sdfsdf(sdfsdf(sdfsdf)sdf)sdf)sdfsdf -- this is NOT balanced, first paren is unclosed (result should be empty) | |
** ex. esdfd((esdf)(esdf -- first paren is unclosed, should give esdfd | |
** A: see below | |
*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
** Hello, world! | |
** Q: what's a good way to *not* mix up = and == operators in a conditional? | |
** A: a good way is via typed programming | |
*) | |
(* ****** ****** *) | |
#include | |
"share/atspre_define.hats" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// A simple example of C-union | |
// | |
(* ****** ****** *) | |
// | |
// Author: Hongwei Xi | |
// Authoremail: gmhwxiATgmailDOTcom | |
// Start time: November, 2013 | |
// | |
(* ****** ****** *) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include | |
"share/atspre_staload.hats" | |
(* ****** ****** *) | |
(* operator interface *) | |
datatype assoc = ASSOCnone | ASSOCleft | ASSOCright | |
extern | |
fun | |
eq_assoc_assoc (assoc, assoc):<> bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// see: https://microsoft.github.io/monaco-editor/monarch.html | |
// ATS/Postiats lexical syntax definition | |
// Written by Artyom Shalkhakov over the week of 20th - 27th of June, 2016. | |
// License: BSD v3 (but probably GPL, since ATS/Postiats lexer is GPL? not a lawyer!) | |
// TODO: staload and dynload are followed by a special kind of string literals | |
// with {$IDENTIFER} variables, and it also may make sense to highlight | |
// the punctuation (. and / and \) differently. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
** Hello, monadic world! | |
** | |
** Author: Artyom Shalkhakov | |
** artyom DOT shalkhakov AT gmail DOT com | |
** | |
** Can be run using: | |
** http://www.ats-lang.org/SERVER/MYCODE/Patsoptaas_serve.php | |
*) |
OlderNewer