mirror of https://github.com/Wilfred/difftastic/
Remove old vendored haskell parser
parent
bbe4890cfd
commit
79bdf87c97
@ -1 +0,0 @@
|
||||
../tree-sitter-haskell/queries/highlights.scm
|
||||
@ -1 +0,0 @@
|
||||
tree-sitter-haskell/src
|
||||
@ -1,2 +0,0 @@
|
||||
/src/** linguist-vendored
|
||||
/examples/* linguist-vendored
|
||||
@ -1,46 +0,0 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "**"
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: test / ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macOS-latest, ubuntu-latest]
|
||||
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '14'
|
||||
|
||||
# - name: Install emscripten
|
||||
# uses: mymindstorm/setup-emsdk@v10
|
||||
# with:
|
||||
# version: '2.0.24'
|
||||
|
||||
- name: Build tree-sitter-haskell
|
||||
run: npm install
|
||||
|
||||
- name: Run tests
|
||||
run: npm test
|
||||
|
||||
- name: Parse examples
|
||||
run: npm run examples
|
||||
|
||||
# - name: Parse examples with web binding
|
||||
# run: npm run examples-wasm
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
node_modules
|
||||
build
|
||||
*.log
|
||||
package-lock.json
|
||||
repos
|
||||
examples/*
|
||||
!examples/.gitkeep
|
||||
.gdb_history
|
||||
*.o
|
||||
*.so
|
||||
@ -1,6 +0,0 @@
|
||||
corpus
|
||||
examples
|
||||
build
|
||||
script
|
||||
.travis.yml
|
||||
.gitattributes
|
||||
@ -1,59 +0,0 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.7.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.73"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64"
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter"
|
||||
version = "0.20.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09b3b781640108d29892e8b9684642d2cda5ea05951fd58f0fea1db9edeb9b71"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter-haskell"
|
||||
version = "0.14.0"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"tree-sitter",
|
||||
]
|
||||
@ -1,25 +0,0 @@
|
||||
[package]
|
||||
name = "tree-sitter-haskell"
|
||||
description = "haskell grammar for the tree-sitter parsing library"
|
||||
version = "0.14.0"
|
||||
keywords = ["incremental", "parsing", "haskell"]
|
||||
categories = ["parsing", "text-editors"]
|
||||
repository = "https://github.com/tree-sitter/tree-sitter-haskell"
|
||||
edition = "2018"
|
||||
|
||||
build = "bindings/rust/build.rs"
|
||||
include = [
|
||||
"bindings/rust/*",
|
||||
"grammar.js",
|
||||
"queries/*",
|
||||
"src/*",
|
||||
]
|
||||
|
||||
[lib]
|
||||
path = "bindings/rust/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
tree-sitter = "0.20"
|
||||
|
||||
[build-dependencies]
|
||||
cc = "1.0"
|
||||
@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Max Brunsfeld
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@ -1,47 +0,0 @@
|
||||
WEB_TREE_SITTER_FILES=README.md package.json tree-sitter-web.d.ts tree-sitter.js tree-sitter.wasm
|
||||
TREE_SITTER_VERSION=v0.20.1
|
||||
|
||||
all: node_modules/web-tree-sitter tree-sitter-haskell.wasm
|
||||
|
||||
# build parser.c
|
||||
src/parser.c: grammar.js
|
||||
npx tree-sitter generate
|
||||
|
||||
# build patched version of web-tree-sitter
|
||||
node_modules/web-tree-sitter:
|
||||
@rm -rf tmp/tree-sitter
|
||||
@git clone \
|
||||
-c advice.detachedHead=false --quiet \
|
||||
--depth=1 --branch=$(TREE_SITTER_VERSION) \
|
||||
https://github.com/tree-sitter/tree-sitter.git \
|
||||
tmp/tree-sitter
|
||||
@cp tree-sitter.patch tmp/tree-sitter/
|
||||
@>/dev/null \
|
||||
&& cd tmp/tree-sitter \
|
||||
&& git apply tree-sitter.patch \
|
||||
&& ./script/build-wasm --debug
|
||||
@mkdir -p node_modules/web-tree-sitter
|
||||
@cp tmp/tree-sitter/LICENSE node_modules/web-tree-sitter
|
||||
@cp $(addprefix tmp/tree-sitter/lib/binding_web/,$(WEB_TREE_SITTER_FILES)) node_modules/web-tree-sitter
|
||||
@rm -rf tmp/tree-sitter
|
||||
|
||||
# build web version of tree-sitter-haskell
|
||||
# NOTE: requires patched version of web-tree-sitter
|
||||
tree-sitter-haskell.wasm: src/parser.c src/scanner.c
|
||||
npx tree-sitter build-wasm
|
||||
|
||||
CC := cc
|
||||
OURCFLAGS := -shared -fPIC -g -O0 -I src
|
||||
|
||||
clean:
|
||||
rm -f debug *.o *.a
|
||||
|
||||
debug.so: src/parser.c src/scanner.c
|
||||
$(CC) $(OURCFLAGS) $(CFLAGS) -o parser.o src/parser.c
|
||||
$(CC) $(OURCFLAGS) $(CFLAGS) -o scanner.o src/scanner.c
|
||||
$(CC) $(OURCFLAGS) $(CFLAGS) -o debug.so $(PWD)/scanner.o $(PWD)/parser.o
|
||||
@echo ""
|
||||
@echo "-----------"
|
||||
@echo ""
|
||||
@echo "To use the debug build with tree-sitter on linux, run:"
|
||||
@echo "cp debug.so $HOME/.cache/tree-sitter/lib/haskell.so"
|
||||
@ -1,19 +0,0 @@
|
||||
{
|
||||
"targets": [
|
||||
{
|
||||
"target_name": "tree_sitter_haskell_binding",
|
||||
"include_dirs": [
|
||||
"<!(node -e \"require('nan')\")",
|
||||
"src"
|
||||
],
|
||||
"sources": [
|
||||
"src/parser.c",
|
||||
"bindings/node/binding.cc",
|
||||
"src/scanner.cc",
|
||||
],
|
||||
"cflags_c": [
|
||||
"-std=c99",
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
#include "tree_sitter/parser.h"
|
||||
#include <node.h>
|
||||
#include "nan.h"
|
||||
|
||||
using namespace v8;
|
||||
|
||||
extern "C" TSLanguage * tree_sitter_haskell();
|
||||
|
||||
namespace {
|
||||
|
||||
NAN_METHOD(New) {}
|
||||
|
||||
void Init(Local<Object> exports, Local<Object> module) {
|
||||
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
|
||||
tpl->SetClassName(Nan::New("Language").ToLocalChecked());
|
||||
tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
|
||||
Local<Function> constructor = Nan::GetFunction(tpl).ToLocalChecked();
|
||||
Local<Object> instance = constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked();
|
||||
Nan::SetInternalFieldPointer(instance, 0, tree_sitter_haskell());
|
||||
|
||||
Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("haskell").ToLocalChecked());
|
||||
Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance);
|
||||
}
|
||||
|
||||
NODE_MODULE(tree_sitter_haskell_binding, Init)
|
||||
|
||||
} // namespace
|
||||
@ -1,19 +0,0 @@
|
||||
try {
|
||||
module.exports = require("../../build/Release/tree_sitter_haskell_binding");
|
||||
} catch (error1) {
|
||||
if (error1.code !== 'MODULE_NOT_FOUND') {
|
||||
throw error1;
|
||||
}
|
||||
try {
|
||||
module.exports = require("../../build/Debug/tree_sitter_haskell_binding");
|
||||
} catch (error2) {
|
||||
if (error2.code !== 'MODULE_NOT_FOUND') {
|
||||
throw error2;
|
||||
}
|
||||
throw error1
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
module.exports.nodeTypeInfo = require("../../src/node-types.json");
|
||||
} catch (_) {}
|
||||
@ -1,38 +0,0 @@
|
||||
fn main() {
|
||||
let src_dir = std::path::Path::new("src");
|
||||
|
||||
let mut c_config = cc::Build::new();
|
||||
c_config.include(&src_dir);
|
||||
c_config
|
||||
.flag_if_supported("-Wno-unused-parameter")
|
||||
.flag_if_supported("-Wno-unused-but-set-variable")
|
||||
.flag_if_supported("-Wno-trigraphs");
|
||||
let parser_path = src_dir.join("parser.c");
|
||||
c_config.file(&parser_path);
|
||||
|
||||
// If your language uses an external scanner written in C,
|
||||
// then include this block of code:
|
||||
|
||||
let scanner_path = src_dir.join("scanner.c");
|
||||
c_config.file(&scanner_path);
|
||||
println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
|
||||
|
||||
c_config.compile("parser");
|
||||
println!("cargo:rerun-if-changed={}", parser_path.to_str().unwrap());
|
||||
|
||||
// If your language uses an external scanner written in C++,
|
||||
// then include this block of code:
|
||||
|
||||
/*
|
||||
let mut cpp_config = cc::Build::new();
|
||||
cpp_config.cpp(true);
|
||||
cpp_config.include(&src_dir);
|
||||
cpp_config
|
||||
.flag_if_supported("-Wno-unused-parameter")
|
||||
.flag_if_supported("-Wno-unused-but-set-variable");
|
||||
let scanner_path = src_dir.join("scanner.cc");
|
||||
cpp_config.file(&scanner_path);
|
||||
cpp_config.compile("scanner");
|
||||
println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
|
||||
*/
|
||||
}
|
||||
@ -1,52 +0,0 @@
|
||||
//! This crate provides haskell language support for the [tree-sitter][] parsing library.
|
||||
//!
|
||||
//! Typically, you will use the [language][language func] function to add this language to a
|
||||
//! tree-sitter [Parser][], and then use the parser to parse some code:
|
||||
//!
|
||||
//! ```
|
||||
//! let code = "";
|
||||
//! let mut parser = tree_sitter::Parser::new();
|
||||
//! parser.set_language(tree_sitter_haskell::language()).expect("Error loading haskell grammar");
|
||||
//! let tree = parser.parse(code, None).unwrap();
|
||||
//! ```
|
||||
//!
|
||||
//! [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
|
||||
//! [language func]: fn.language.html
|
||||
//! [Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html
|
||||
//! [tree-sitter]: https://tree-sitter.github.io/
|
||||
|
||||
use tree_sitter::Language;
|
||||
|
||||
extern "C" {
|
||||
fn tree_sitter_haskell() -> Language;
|
||||
}
|
||||
|
||||
/// Get the tree-sitter [Language][] for this grammar.
|
||||
///
|
||||
/// [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
|
||||
pub fn language() -> Language {
|
||||
unsafe { tree_sitter_haskell() }
|
||||
}
|
||||
|
||||
/// The content of the [`node-types.json`][] file for this grammar.
|
||||
///
|
||||
/// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types
|
||||
pub const NODE_TYPES: &'static str = include_str!("../../src/node-types.json");
|
||||
|
||||
// Uncomment these to include any queries that this grammar contains
|
||||
|
||||
pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm");
|
||||
// pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm");
|
||||
pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm");
|
||||
// pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm");
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn test_can_load_grammar() {
|
||||
let mut parser = tree_sitter::Parser::new();
|
||||
parser
|
||||
.set_language(super::language())
|
||||
.expect("Error loading haskell language");
|
||||
}
|
||||
}
|
||||
@ -1,261 +0,0 @@
|
||||
const basic = require('./grammar/basic.js')
|
||||
const id = require('./grammar/id.js')
|
||||
const type = require('./grammar/type.js')
|
||||
const exp = require('./grammar/exp.js')
|
||||
const pat = require('./grammar/pat.js')
|
||||
const import_ = require('./grammar/import.js')
|
||||
const module_ = require('./grammar/module.js')
|
||||
const data = require('./grammar/data.js')
|
||||
const class_ = require('./grammar/class.js')
|
||||
const decl = require('./grammar/decl.js')
|
||||
const pattern = require('./grammar/pattern.js')
|
||||
const misc = require('./grammar/misc.js')
|
||||
|
||||
module.exports = grammar({
|
||||
name: 'haskell',
|
||||
|
||||
/**
|
||||
* These rules may occur anywhere in the grammar and don't have to be specified.
|
||||
*/
|
||||
extras: $ => [
|
||||
/\p{Zs}/,
|
||||
/\n/,
|
||||
/\r/,
|
||||
$.cpp,
|
||||
$.comment,
|
||||
$.pragma,
|
||||
],
|
||||
|
||||
/**
|
||||
* These rules are handled manually by the scanner. Whenever their identifiers are used in the rule tree, the parser
|
||||
* executes the scanner.
|
||||
* Since the newline character is present both here and in `extras`, the scanner will be called before every token.
|
||||
* This makes indentation/layout tracking simpler.
|
||||
*/
|
||||
externals: $ => [
|
||||
$._layout_semicolon,
|
||||
$._layout_start,
|
||||
$._layout_end,
|
||||
$._dot,
|
||||
$.where,
|
||||
$._splice_dollar,
|
||||
$._varsym,
|
||||
$._consym,
|
||||
$._tyconsym,
|
||||
$.comment,
|
||||
$.cpp,
|
||||
$.comma,
|
||||
$.quasiquote_start,
|
||||
$.quasiquote_bar,
|
||||
$.quasiquote_body,
|
||||
$._strict,
|
||||
$._unboxed_close,
|
||||
'|',
|
||||
'in',
|
||||
/\n/,
|
||||
$.empty_file,
|
||||
],
|
||||
|
||||
inline: $ => [
|
||||
$._number,
|
||||
$._stringly,
|
||||
$._qvarid,
|
||||
$._operator_minus,
|
||||
$._qvarsym,
|
||||
$._qvarsym_nominus,
|
||||
$._var,
|
||||
$._qvar,
|
||||
$._tyvar,
|
||||
$._qconid,
|
||||
$._qconsym,
|
||||
$._con,
|
||||
$._conop,
|
||||
$._qconop,
|
||||
$._op,
|
||||
$._qop_nominus,
|
||||
$._gcon_literal,
|
||||
$._gcon,
|
||||
$._tyconid,
|
||||
$._qtyconid,
|
||||
$._qtyconsym,
|
||||
$._qtycon,
|
||||
$._gtycon,
|
||||
$._simple_tycon,
|
||||
$._simple_tyconop,
|
||||
$._quantifiers,
|
||||
$._tyfam_pat_prefix,
|
||||
$._tyfam_pat_infix,
|
||||
],
|
||||
|
||||
precedences: _ => [
|
||||
[
|
||||
'context-empty',
|
||||
'con_unit',
|
||||
],
|
||||
[
|
||||
'infix-type',
|
||||
'btype',
|
||||
],
|
||||
[
|
||||
'function-type',
|
||||
'type',
|
||||
],
|
||||
],
|
||||
|
||||
conflicts: $ => [
|
||||
/**
|
||||
* This could be done with the second named precedence further up, but it somehow overrides symbolic infix
|
||||
* constructors.
|
||||
* Needs more investigation.
|
||||
*/
|
||||
[$._type_infix, $.type_infix],
|
||||
|
||||
/**
|
||||
* Optional context for a data/newtype decl with infix types:
|
||||
*
|
||||
* data a ~ b => A a b
|
||||
* data a + b
|
||||
*/
|
||||
[$.type_name, $._simpletype_infix],
|
||||
|
||||
/**
|
||||
* Same as above, but with regular types:
|
||||
*
|
||||
* data A a b
|
||||
* data C a b => A a b
|
||||
* data C Int a => A a
|
||||
* data B Int ~ B a => A a
|
||||
*/
|
||||
[$.type_name, $._simpletype],
|
||||
[$._atype, $.constraint],
|
||||
|
||||
/**
|
||||
* Constraints and parenthesized types.
|
||||
*
|
||||
* data (A a) => A
|
||||
* data (A a) %% A => A
|
||||
*
|
||||
* After the `a`, the closing parens is ambiguous.
|
||||
*/
|
||||
[$._type_infix, $.constraint],
|
||||
|
||||
/**
|
||||
* Top-level expression splices fundamentally conflict with decls, and since decls start with either `var` or `pat`,
|
||||
* they cannot be disambiguated.
|
||||
*
|
||||
* function_variable:
|
||||
* func (A a) = a
|
||||
*
|
||||
* function_pattern:
|
||||
* Just 1 = Just 1
|
||||
* a : as = [1, 2, 3]
|
||||
*
|
||||
* splice:
|
||||
* makeLenses ''A
|
||||
*
|
||||
* The disambiguation can clearly be made from the `=`, but my impression is that the conflict check only considers
|
||||
* immediate lookahead.
|
||||
*/
|
||||
[$._fun_name, $.exp_name],
|
||||
[$._fun_name, $.pat_name],
|
||||
[$._fun_name, $.pat_name, $.exp_name],
|
||||
[$.signature, $.pat_name],
|
||||
[$.exp_name, $._pat_constructor],
|
||||
[$.exp_name, $.pat_name],
|
||||
[$._aexp, $._apat],
|
||||
[$.pat_negation, $._literal],
|
||||
|
||||
/**
|
||||
* Ambiguity between symbolic and regular constructors:
|
||||
*
|
||||
* data A = Maybe Int :+ Int
|
||||
* data A = Name Int
|
||||
*
|
||||
* both start with two tycons.
|
||||
*/
|
||||
[$.type_name, $.data_constructor],
|
||||
|
||||
/**
|
||||
* Ambiguity between symbolic and regular type family equations.
|
||||
*/
|
||||
[$.type_name, $.tyfam_pat],
|
||||
|
||||
/**
|
||||
* For getting a node for function application, and no extra node if the expression only consists of one term.
|
||||
*/
|
||||
[$._exp_apply, $._fexp],
|
||||
[$._exp_apply],
|
||||
|
||||
/**
|
||||
* Same as `exp_apply`, but for patterns.
|
||||
*/
|
||||
[$.pat_apply, $._apat],
|
||||
[$.pat_apply],
|
||||
|
||||
/**
|
||||
* Same as `exp_apply`, but for types.
|
||||
*/
|
||||
[$.type_apply, $._btype],
|
||||
[$.type_apply],
|
||||
|
||||
/**
|
||||
* Implicit parameters have slightly weird restrictions.
|
||||
*/
|
||||
[$._type_or_implicit, $._context_constraints],
|
||||
|
||||
/**
|
||||
* `(# | | ...` can start both `pat` and `exp`.
|
||||
*/
|
||||
[$._pat_unboxed_sum, $._exp_unboxed_sum],
|
||||
|
||||
/**
|
||||
* The nullary unboxed tuple `(# #)` is indistinguishable between exp and pat.
|
||||
*/
|
||||
[$.exp_unboxed_tuple, $.pat_unboxed_tuple],
|
||||
|
||||
[$.exp_lambda_case],
|
||||
],
|
||||
|
||||
word: $ => $._varid,
|
||||
|
||||
rules: {
|
||||
haskell: $ => choice(
|
||||
$.empty_file,
|
||||
$._module,
|
||||
terminated($, $._topdecl),
|
||||
),
|
||||
|
||||
_topdecl: $ => choice(
|
||||
alias($.decl_type, $.type_alias),
|
||||
alias($.decl_tyfam, $.type_family),
|
||||
alias($.decl_tyinst, $.type_instance),
|
||||
alias($.decl_role, $.role_annotation),
|
||||
alias($.decl_adt, $.adt),
|
||||
alias($.decl_newtype, $.newtype),
|
||||
alias($.decl_datafam, $.data_family),
|
||||
alias($.decl_datainst, $.data_instance),
|
||||
alias($.decl_import, $.import),
|
||||
alias($.decl_class, $.class),
|
||||
alias($.decl_instance, $.instance),
|
||||
alias($.decl_default, $.default_declaration),
|
||||
$._decl_foreign,
|
||||
alias($.decl_deriving, $.deriving_declaration),
|
||||
$._decl,
|
||||
alias($.decl_pattern, $.pattern_synonym),
|
||||
$.top_splice,
|
||||
),
|
||||
|
||||
...basic,
|
||||
...id,
|
||||
...type,
|
||||
...exp,
|
||||
...pat,
|
||||
...import_,
|
||||
...module_,
|
||||
...data,
|
||||
...class_,
|
||||
...decl,
|
||||
...pattern,
|
||||
...misc,
|
||||
}
|
||||
})
|
||||
@ -1,94 +0,0 @@
|
||||
const
|
||||
|
||||
decimal = /[0-9][0-9_]*/
|
||||
exponent = /[eE][+-]?[0-9_]+/
|
||||
hex_exponent = /[pP][+-]?[0-9a-fA-F_]+/
|
||||
magic_hash = rule => token(seq(rule, optional(token.immediate(/##?/))))
|
||||
|
||||
module.exports = {
|
||||
// ------------------------------------------------------------------------
|
||||
// literals
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
// the `choice` here is necessary to avoid integers being parsed as floats
|
||||
float: _ => magic_hash(
|
||||
seq(
|
||||
decimal,
|
||||
choice(
|
||||
seq(/\.[0-9_]+/, optional(exponent)),
|
||||
exponent,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
char: _ => magic_hash(
|
||||
choice(
|
||||
/'[^']'/,
|
||||
/'\\[^ ]*'/,
|
||||
),
|
||||
),
|
||||
|
||||
string: _ => magic_hash(
|
||||
seq(
|
||||
'"',
|
||||
repeat(choice(
|
||||
/[^\\"\n]/,
|
||||
/\\(\^)?./,
|
||||
/\\\n\s*\\/,
|
||||
)),
|
||||
'"',
|
||||
),
|
||||
),
|
||||
|
||||
_integer_literal: _ => magic_hash(decimal),
|
||||
_binary_literal: _ => magic_hash(/0[bB][01_]+/),
|
||||
_octal_literal: _ => magic_hash(/0[oO][0-7]+/),
|
||||
|
||||
_hex_literal: _ => magic_hash(
|
||||
seq(
|
||||
/0[xX][0-9a-fA-F_]+/,
|
||||
optional(/\.[0-9a-fA-F_]+/),
|
||||
optional(hex_exponent),
|
||||
)
|
||||
),
|
||||
|
||||
integer: $ => choice(
|
||||
$._binary_literal,
|
||||
$._integer_literal,
|
||||
$._octal_literal,
|
||||
$._hex_literal,
|
||||
),
|
||||
|
||||
_stringly: $ => choice(
|
||||
$.string,
|
||||
$.char,
|
||||
),
|
||||
|
||||
_number: $ => choice(
|
||||
$.integer,
|
||||
$.float,
|
||||
),
|
||||
|
||||
_literal: $ => choice(
|
||||
$._stringly,
|
||||
$._number,
|
||||
),
|
||||
|
||||
_unboxed_open: _ => choice('(# ', '(#\n'),
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// pragma
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
pragma: _ => token(
|
||||
seq(
|
||||
'{-#',
|
||||
repeat(choice(
|
||||
/[^#]/,
|
||||
/#[^-]/,
|
||||
/#\-[^}]/,
|
||||
)),
|
||||
'#-}'
|
||||
)
|
||||
),
|
||||
}
|
||||
@ -1,92 +0,0 @@
|
||||
module.exports = {
|
||||
// ------------------------------------------------------------------------
|
||||
// class
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
default_signature: $ => seq('default', $.signature),
|
||||
|
||||
class_datafam: $ => seq(
|
||||
'data',
|
||||
optional('family'),
|
||||
$._simpletype,
|
||||
optional($._type_annotation),
|
||||
),
|
||||
|
||||
_cdecl: $ => choice(
|
||||
$._gendecl,
|
||||
$.default_signature,
|
||||
$.function,
|
||||
$.decl_tyfam_sig,
|
||||
$.decl_type,
|
||||
alias($.class_datafam, $.data_family),
|
||||
),
|
||||
|
||||
fundep: $ => seq(repeat1($.type_variable), '->', repeat1($.type_variable)),
|
||||
|
||||
fundeps: $ => seq('|', sep1($.comma, $.fundep)),
|
||||
|
||||
class_body: $ => where($, $._cdecl),
|
||||
|
||||
decl_class: $ => seq(
|
||||
'class',
|
||||
optional($.context),
|
||||
alias($.constraint, $.class_head),
|
||||
optional($.fundeps),
|
||||
optional($.class_body),
|
||||
),
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// instance
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
inst_datainst: $ => choice(
|
||||
seq(
|
||||
'data',
|
||||
optional('instance'),
|
||||
$._datainst,
|
||||
optional($._adt),
|
||||
),
|
||||
seq(
|
||||
'newtype',
|
||||
optional('instance'),
|
||||
$._datainst,
|
||||
$._newtype
|
||||
),
|
||||
),
|
||||
|
||||
inst_tyinst: $ => seq(
|
||||
'type',
|
||||
optional('instance'),
|
||||
repeat($._atype),
|
||||
'=',
|
||||
$._type,
|
||||
),
|
||||
|
||||
_idecl: $ => choice(
|
||||
$.function,
|
||||
$.signature,
|
||||
$.inst_datainst,
|
||||
$.inst_tyinst,
|
||||
),
|
||||
|
||||
/**
|
||||
* instances only allow single foralls and contexts
|
||||
*/
|
||||
_instance: $ => seq(
|
||||
'instance',
|
||||
optional($.forall),
|
||||
optional($.context),
|
||||
alias($.constraint, $.instance_head),
|
||||
),
|
||||
|
||||
decl_instance: $ => seq(
|
||||
$._instance,
|
||||
optional(where($, $._idecl)),
|
||||
),
|
||||
|
||||
decl_deriving: $ => seq(
|
||||
'deriving',
|
||||
optional(choice($.deriving_strategy, $.via)),
|
||||
$._instance,
|
||||
),
|
||||
}
|
||||
@ -1,166 +0,0 @@
|
||||
const {parens} = require('./util.js')
|
||||
|
||||
module.exports = {
|
||||
// ------------------------------------------------------------------------
|
||||
// adt
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
field: $ => seq(
|
||||
sep1($.comma, $.variable),
|
||||
'::',
|
||||
choice($.strict_type, $._type),
|
||||
),
|
||||
|
||||
data_constructor: $ => seq(
|
||||
$.constructor,
|
||||
repeat(choice($.strict_type, $._atype))
|
||||
),
|
||||
|
||||
data_constructor_infix: $ => seq(
|
||||
choice($.strict_type, $._type_infix),
|
||||
$._conop,
|
||||
choice($.strict_type, $._type_infix),
|
||||
),
|
||||
|
||||
_record_field: $ => braces($.field),
|
||||
|
||||
record_fields: $ => braces(sep1($.comma, $.field)),
|
||||
|
||||
data_constructor_record: $ => seq(
|
||||
$.constructor,
|
||||
$.record_fields,
|
||||
),
|
||||
|
||||
/**
|
||||
* data constructors only allow single foralls and contexts
|
||||
*/
|
||||
constructors: $ => sep1(
|
||||
'|',
|
||||
seq(
|
||||
optional($.forall),
|
||||
optional($.context),
|
||||
choice(
|
||||
$.data_constructor,
|
||||
$.data_constructor_infix,
|
||||
$.data_constructor_record,
|
||||
),
|
||||
)
|
||||
),
|
||||
|
||||
via: $ => seq('via', $._type),
|
||||
|
||||
deriving_strategy: _ => choice('stock', 'newtype', 'anyclass'),
|
||||
|
||||
deriving: $ => seq(
|
||||
'deriving',
|
||||
optional($.deriving_strategy),
|
||||
choice(
|
||||
field('class', $._qtyconid),
|
||||
parens(optional(sep1($.comma, field('class', $._constraint))))
|
||||
),
|
||||
optional($.via),
|
||||
),
|
||||
|
||||
_adt_rhs: $ => seq(
|
||||
'=',
|
||||
$.constructors,
|
||||
repeat($.deriving),
|
||||
),
|
||||
|
||||
_gadt_fun: $ => seq(choice($.strict_type, $._type_infix), '->', $._gadt_sig),
|
||||
|
||||
_gadt_sig: $ => choice(
|
||||
alias($._gadt_fun, $.fun),
|
||||
choice($.strict_type, $._type_infix)
|
||||
),
|
||||
|
||||
/**
|
||||
* gadt constructors only allow single foralls and contexts
|
||||
*/
|
||||
_gadt_constr_type: $ => seq(
|
||||
'::',
|
||||
optional($.forall),
|
||||
optional($.context),
|
||||
choice($._gadt_sig, seq($.record_fields, '->', $._gadt_sig)),
|
||||
),
|
||||
|
||||
gadt_constructor: $ => seq(
|
||||
$._con,
|
||||
$._gadt_constr_type,
|
||||
),
|
||||
|
||||
_gadt_rhs: $ => where($, choice($.gadt_constructor, $.deriving)),
|
||||
|
||||
_adt: $ => seq(
|
||||
choice($._adt_rhs, $._gadt_rhs),
|
||||
),
|
||||
|
||||
decl_adt: $ => seq(
|
||||
'data',
|
||||
optional($.context),
|
||||
$._simpletype,
|
||||
optional($._type_annotation),
|
||||
optional(choice($._adt, repeat($.deriving))),
|
||||
),
|
||||
|
||||
newtype_constructor: $ => seq(
|
||||
$.constructor,
|
||||
choice(
|
||||
$._atype,
|
||||
$._record_field,
|
||||
),
|
||||
),
|
||||
|
||||
_newtype: $ => seq(
|
||||
'=',
|
||||
$.newtype_constructor,
|
||||
repeat($.deriving),
|
||||
),
|
||||
|
||||
_context_newtype: $ => choice(
|
||||
seq($.context, $._simpletype),
|
||||
$._simpletype,
|
||||
),
|
||||
|
||||
decl_newtype: $ => seq(
|
||||
'newtype',
|
||||
$._context_newtype,
|
||||
choice($._newtype, seq(optional($._type_annotation), $._gadt_rhs)),
|
||||
),
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// data family
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
decl_datafam: $ => seq(
|
||||
'data',
|
||||
'family',
|
||||
$._simpletype,
|
||||
optional($._type_annotation),
|
||||
),
|
||||
|
||||
/**
|
||||
* data instances only allow single foralls and contexts
|
||||
*/
|
||||
_datainst: $ => seq(
|
||||
optional($.forall),
|
||||
optional($.context),
|
||||
$._type_infix,
|
||||
optional($._type_annotation),
|
||||
),
|
||||
|
||||
decl_datainst: $ => choice(
|
||||
seq(
|
||||
'data',
|
||||
'instance',
|
||||
$._datainst,
|
||||
optional($._adt),
|
||||
),
|
||||
seq(
|
||||
'newtype',
|
||||
'instance',
|
||||
$._datainst,
|
||||
$._newtype
|
||||
),
|
||||
),
|
||||
}
|
||||
@ -1,122 +0,0 @@
|
||||
const foreign = ($, kw, pent) => seq(
|
||||
'foreign',
|
||||
kw,
|
||||
$._foreign_pre,
|
||||
optional(pent),
|
||||
$.signature,
|
||||
)
|
||||
|
||||
module.exports = {
|
||||
// ------------------------------------------------------------------------
|
||||
// decl
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
_funpat_infix: $ => seq(field('lhs', $._pat), field('op', $.varop), field('rhs', $._pat)),
|
||||
|
||||
_funpat: $ => seq(
|
||||
field('pattern', $._typed_pat),
|
||||
$._funrhs,
|
||||
),
|
||||
|
||||
/**
|
||||
* The `implicit_parid` here is for:
|
||||
* g = let ?par = Impy 5 in f
|
||||
*/
|
||||
_fun_name: $ => field('name', choice($._var, $.implicit_parid)),
|
||||
|
||||
guard_equation: $ => seq($.guards, '=', $._exp),
|
||||
|
||||
_fun_guards: $ => repeat1($.guard_equation),
|
||||
|
||||
_funrhs: $ => seq(
|
||||
choice(
|
||||
seq('=', field('rhs', $._exp)),
|
||||
$._fun_guards,
|
||||
),
|
||||
optional(seq($.where, optional($.decls))),
|
||||
),
|
||||
|
||||
_fun_patterns: $ => repeat1($._apat),
|
||||
|
||||
_funvar: $ => seq($._fun_name, field('patterns', optional(alias($._fun_patterns, $.patterns)))),
|
||||
|
||||
_funlhs: $ => choice(
|
||||
prec.dynamic(2, $._funvar),
|
||||
prec.dynamic(1, field('infix', alias($._funpat_infix, $.infix))),
|
||||
),
|
||||
|
||||
function: $ => seq(
|
||||
$._funlhs,
|
||||
$._funrhs,
|
||||
),
|
||||
|
||||
fixity: $ => seq(
|
||||
choice('infixl', 'infixr', 'infix'),
|
||||
optional($.integer),
|
||||
sep1($.comma, $._op),
|
||||
),
|
||||
|
||||
signature: $ => seq(
|
||||
field('lhs', sep1($.comma, field('name', $._var))),
|
||||
field('type', $._type_annotation),
|
||||
),
|
||||
|
||||
_gendecl: $ => choice(
|
||||
$.signature,
|
||||
$.fixity,
|
||||
),
|
||||
|
||||
/**
|
||||
* in the reference, `apat` is a choice in `lpat`, but this creates a conflict:
|
||||
* `decl` allows the lhs to be a `pat`, as in:
|
||||
* let Just 5 = prog
|
||||
* let a = prog
|
||||
* Since patterns can be `variable`s, the `funpat` lhs of the second example cannot be distinguished from a `funvar`.
|
||||
* The precedences here and in `_funlhs` solve this.
|
||||
*/
|
||||
_decl_fun: $ => choice(
|
||||
$.function,
|
||||
prec.dynamic(1, alias($._funpat, $.function)),
|
||||
),
|
||||
|
||||
_decl: $ => choice(
|
||||
$._gendecl,
|
||||
$._decl_fun,
|
||||
),
|
||||
|
||||
decls: $ => layouted($, $._decl),
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// foreign
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
calling_convention: _ => choice(
|
||||
'ccall',
|
||||
'stdcall',
|
||||
'cplusplus',
|
||||
'jvm',
|
||||
'dotnet',
|
||||
'prim',
|
||||
'capi',
|
||||
),
|
||||
|
||||
safety: _ => choice('unsafe', 'safe', 'interruptible'),
|
||||
|
||||
impent: $ => $.string,
|
||||
|
||||
expent: $ => $.string,
|
||||
|
||||
_foreign_pre: $ => seq(
|
||||
$.calling_convention,
|
||||
optional($.safety),
|
||||
),
|
||||
|
||||
decl_foreign_import: $ => foreign($, 'import', $.impent),
|
||||
|
||||
decl_foreign_export: $ => foreign($, 'export', $.expent),
|
||||
|
||||
_decl_foreign: $ => choice(
|
||||
alias($.decl_foreign_import, $.foreign_import),
|
||||
alias($.decl_foreign_export, $.foreign_export)
|
||||
),
|
||||
}
|
||||
@ -1,118 +0,0 @@
|
||||
const {parens} = require('./util.js')
|
||||
|
||||
module.exports = {
|
||||
// ------------------------------------------------------------------------
|
||||
// var
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
_varid: _ => /[_a-z](\w|')*#?/,
|
||||
label: _ => /#[_a-z](\w|')*/,
|
||||
variable: $ => $._varid,
|
||||
qualified_variable: $ => qualified($, $.variable),
|
||||
_qvarid: $ => choice($.qualified_variable, $.variable),
|
||||
|
||||
operator: $ => $._varsym,
|
||||
_minus: $ => alias('-', $.operator),
|
||||
_operator_minus: $ => choice($.operator, $._minus),
|
||||
qualified_operator: $ => qualified($, $._operator_minus),
|
||||
_qvarsym: $ => choice($.qualified_operator, $._operator_minus),
|
||||
_qvarsym_nominus: $ => choice($.qualified_operator, $.operator),
|
||||
|
||||
_var: $ => choice($.variable, parens($._operator_minus)),
|
||||
_qvar: $ => choice($._qvarid, parens($._qvarsym)),
|
||||
|
||||
varop: $ => choice($._operator_minus, ticked($.variable)),
|
||||
_qvarop: $ => choice($._qvarsym, ticked($._qvarid)),
|
||||
_qvarop_nominus: $ => choice($._qvarsym_nominus, ticked($._qvarid)),
|
||||
|
||||
implicit_parid: _ => /\?[_a-z](\w|')*/,
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// con
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
_conid: _ => /[A-Z](\w|')*#?/,
|
||||
constructor: $ => $._conid,
|
||||
qualified_constructor: $ => qualified($, $.constructor),
|
||||
_qconid: $ => choice($.qualified_constructor, $.constructor),
|
||||
|
||||
constructor_operator: $ => $._consym,
|
||||
qualified_constructor_operator: $ => qualified($, $.constructor_operator),
|
||||
_qconsym: $ => choice($.qualified_constructor_operator, $.constructor_operator),
|
||||
|
||||
_con: $ => choice($.constructor, parens($.constructor_operator)),
|
||||
_qcon: $ => choice($._qconid, parens($._qconsym)),
|
||||
_conop: $ => choice($.constructor_operator, ticked($.constructor)),
|
||||
_qconop: $ => choice($._qconsym, ticked($._qconid)),
|
||||
_op: $ => choice($.varop, $._conop),
|
||||
_qop: $ => choice($._qvarop, $._qconop),
|
||||
|
||||
_qop_nominus: $ => choice($._qvarop_nominus, $._qconop),
|
||||
|
||||
con_unit: _ => prec('con_unit', parens()),
|
||||
con_list: _ => brackets(),
|
||||
con_tuple: $ => parens(repeat1($.comma)),
|
||||
|
||||
_gcon_literal: $ => choice(
|
||||
$.con_unit,
|
||||
$.con_list,
|
||||
$.con_tuple,
|
||||
),
|
||||
|
||||
literal: $ => choice(
|
||||
$._literal,
|
||||
$._gcon_literal,
|
||||
),
|
||||
|
||||
_gcon: $ => choice(
|
||||
$._qcon,
|
||||
$._gcon_literal,
|
||||
),
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// tycon
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
_tyconid: $ => alias($.constructor, $.type),
|
||||
qualified_type: $ => qualified($, $._tyconid),
|
||||
_qtyconid: $ => choice($.qualified_type, $._tyconid),
|
||||
|
||||
_type_operator: $ => choice(alias($._tyconsym, $.type_operator), $.constructor_operator),
|
||||
qualified_type_operator: $ => qualified($, alias($._tyconsym, $.type_operator)),
|
||||
_qualified_type_operator: $ => choice($.qualified_type_operator, $.qualified_constructor_operator),
|
||||
_qtyconsym: $ => choice($._qualified_type_operator, $._type_operator),
|
||||
|
||||
_ticked_tycon: $ => ticked($._tyconid),
|
||||
_simple_tyconop: $ => choice(alias($._ticked_tycon, $.ticked), $._type_operator),
|
||||
_simple_tycon: $ => choice($._tyconid, parens($._type_operator)),
|
||||
|
||||
_ticked_qtycon: $ => ticked($._qtyconid),
|
||||
_qtyconops: $ => choice(alias($._ticked_qtycon, $.ticked), $._qtyconsym),
|
||||
_promoted_tyconop: $ => seq(quote, $._qtyconops),
|
||||
_qtyconop: $ => choice(
|
||||
alias($._promoted_tyconop, $.promoted),
|
||||
$._qtyconops,
|
||||
),
|
||||
|
||||
tycon_arrow: _ => parens('->'),
|
||||
|
||||
type_literal: $ => choice(
|
||||
$._literal,
|
||||
$.con_unit,
|
||||
$.con_list,
|
||||
$.con_tuple,
|
||||
),
|
||||
|
||||
_qtycon: $ => choice($._qtyconid, parens($._qtyconsym)),
|
||||
|
||||
_promoted_tycon: $ => seq(quote, $._qtycon),
|
||||
|
||||
_gtycon: $ => choice(
|
||||
alias($._promoted_tycon, $.promoted),
|
||||
$._qtycon,
|
||||
$.tycon_arrow,
|
||||
),
|
||||
|
||||
_name: $ => choice($._var, $._con),
|
||||
_qname: $ => choice($._qvar, $._qcon),
|
||||
}
|
||||
@ -1,45 +0,0 @@
|
||||
const {parens} = require('./util.js')
|
||||
|
||||
module.exports = {
|
||||
// ------------------------------------------------------------------------
|
||||
// import
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
_import_name: $ => choice(
|
||||
$._con,
|
||||
$._var,
|
||||
),
|
||||
|
||||
namespace: _ => choice('pattern', 'type'),
|
||||
|
||||
import_con_names: $ => parens(optional(choice(alias('..', $.all_names), sep1($.comma, $._import_name)))),
|
||||
|
||||
import_item: $ => seq(
|
||||
optional($.namespace),
|
||||
choice(
|
||||
$._var,
|
||||
seq($._simple_tycon, optional($.import_con_names)),
|
||||
),
|
||||
),
|
||||
|
||||
import_list: $ => seq(
|
||||
optional('hiding'),
|
||||
parens(optional(seq(
|
||||
sep1(
|
||||
$.comma,
|
||||
$.import_item
|
||||
),
|
||||
optional($.comma), // for trailing commas at the end of an import list
|
||||
))),
|
||||
),
|
||||
|
||||
decl_import: $ => seq(
|
||||
'import',
|
||||
optional('qualified'),
|
||||
optional(alias($.string, $.import_package)),
|
||||
$._qmodid,
|
||||
optional('qualified'),
|
||||
optional(seq('as', $._qmodid)),
|
||||
optional($.import_list),
|
||||
),
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
const {parens, sep1} = require('./util.js')
|
||||
|
||||
module.exports = {
|
||||
decl_default: $ => seq('default', parens(optional(sep1($.comma, $._type_infix)))),
|
||||
|
||||
/**
|
||||
* Even though the doc states "arbitrary expression", using any others than these two not only makes little sense,
|
||||
* it also incurs a >100% increase in generation time and parser size.
|
||||
*/
|
||||
_splice_exp: $ => choice(
|
||||
$.exp_name,
|
||||
$.exp_parens,
|
||||
),
|
||||
|
||||
/**
|
||||
* Right precedence because of double splices `$$a`
|
||||
*/
|
||||
splice: $ => seq($._splice_dollar, $._splice_exp),
|
||||
|
||||
/**
|
||||
* Since `_aexp` includes `splice`, this allows for a top level dollar splice as well.
|
||||
*/
|
||||
top_splice: $ => $._exp_infix,
|
||||
|
||||
/**
|
||||
* `quasiquote_start` is determined by the scanner.
|
||||
* While the quoter and the bar may not be preceded by whitespace, this is not necessary to ensure here with
|
||||
* `token.immediate` since the scanner already verifies it.
|
||||
*/
|
||||
quasiquote: $ => seq(
|
||||
$.quasiquote_start,
|
||||
optional(alias($._qvarid, $.quoter)),
|
||||
$.quasiquote_bar,
|
||||
optional($.quasiquote_body),
|
||||
token('|]'),
|
||||
),
|
||||
}
|
||||
@ -1,38 +0,0 @@
|
||||
const {parens} = require('./util.js')
|
||||
|
||||
module.exports = {
|
||||
// ------------------------------------------------------------------------
|
||||
// module
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
_modid: $ => alias($.constructor, $.module),
|
||||
|
||||
_qualifying_module: $ => repeat1(seq($._modid, $._dot)),
|
||||
|
||||
qualified_module: $ => qualified($, $._modid),
|
||||
_qmodid: $ => choice($.qualified_module, $._modid),
|
||||
|
||||
export_names: $ => parens(optional(choice(alias('..', $.all_names), sep($.comma, $._name)))),
|
||||
|
||||
export: $ => choice(
|
||||
$._qvar,
|
||||
seq(
|
||||
optional($.namespace),
|
||||
$._qtycon,
|
||||
optional($.export_names),
|
||||
),
|
||||
seq('module', field('module', $._qmodid)),
|
||||
),
|
||||
|
||||
exports: $ => parens(
|
||||
optional(sep1($.comma, $.export)),
|
||||
optional($.comma), // for trailing commas at the end of an export list
|
||||
),
|
||||
|
||||
_module: $ => seq(
|
||||
'module',
|
||||
field('module', $._qmodid),
|
||||
optional($.exports),
|
||||
where($, $._topdecl),
|
||||
),
|
||||
}
|
||||
@ -1,97 +0,0 @@
|
||||
const {parens} = require('./util.js')
|
||||
|
||||
module.exports = {
|
||||
pat_field: $ => choice(
|
||||
alias('..', $.wildcard),
|
||||
seq($._qvar, optional(seq('=', $._nested_pat))),
|
||||
),
|
||||
|
||||
pat_fields: $ => braces(optional(sep1($.comma, $.pat_field))),
|
||||
|
||||
pat_as: $ => seq(field('var', $.variable), token.immediate('@'), field('pat', $._apat)),
|
||||
|
||||
pat_parens: $ => parens($._nested_pat),
|
||||
|
||||
pat_view: $ => seq($._exp, '->', $._nested_pat),
|
||||
|
||||
pat_tuple: $ => parens(sep2($.comma, $._nested_pat)),
|
||||
|
||||
pat_unboxed_tuple: $ => seq($._unboxed_open, sep($.comma, $._nested_pat), $._unboxed_close),
|
||||
|
||||
_pat_unboxed_sum: $ => sep2('|', optional($._nested_pat)),
|
||||
|
||||
pat_unboxed_sum: $ => seq($._unboxed_open, $._pat_unboxed_sum, $._unboxed_close),
|
||||
|
||||
pat_list: $ => brackets(sep1($.comma, $._nested_pat)),
|
||||
|
||||
pat_strict: $ => seq($._strict, $._apat),
|
||||
|
||||
pat_irrefutable: $ => seq('~', $._apat),
|
||||
|
||||
pat_negation: $ => seq('-', $._apat),
|
||||
|
||||
pat_name: $ => $._var,
|
||||
|
||||
/**
|
||||
* Needed non-inlined for conflict definition.
|
||||
*/
|
||||
_pat_constructor: $ => alias($._qcon, $.pat_name),
|
||||
|
||||
pat_wildcard: _ => '_',
|
||||
|
||||
pat_record: $ => seq(field('con', $._pat_constructor), field('fields', $.pat_fields)),
|
||||
|
||||
_apat: $ => choice(
|
||||
$.pat_name,
|
||||
$.pat_as,
|
||||
$._pat_constructor,
|
||||
$.pat_record,
|
||||
alias($.literal, $.pat_literal),
|
||||
$.pat_wildcard,
|
||||
$.pat_parens,
|
||||
$.pat_tuple,
|
||||
$.pat_unboxed_tuple,
|
||||
$.pat_unboxed_sum,
|
||||
$.pat_list,
|
||||
$.pat_strict,
|
||||
$.pat_irrefutable,
|
||||
$.splice,
|
||||
$.quasiquote,
|
||||
),
|
||||
|
||||
/**
|
||||
* In patterns, application is only legal if the first element is a con.
|
||||
*/
|
||||
pat_apply: $ => seq($._pat_constructor, repeat1($._apat)),
|
||||
|
||||
_lpat: $ => choice(
|
||||
$._apat,
|
||||
$.pat_negation,
|
||||
$.pat_apply,
|
||||
),
|
||||
|
||||
pat_infix: $ => seq($._lpat, $._qconop, $._pat),
|
||||
|
||||
/**
|
||||
* Without the precs, a conflict is needed.
|
||||
*/
|
||||
_pat: $ => choice(
|
||||
prec(2, $.pat_infix),
|
||||
prec(1, $._lpat),
|
||||
),
|
||||
|
||||
pat_typed: $ => seq(field('pattern', $._pat), $._type_annotation),
|
||||
|
||||
_typed_pat: $ => choice(
|
||||
$._pat,
|
||||
$.pat_typed,
|
||||
),
|
||||
|
||||
/**
|
||||
* Patterns that occur inside parentheses, and thus can always have view patterns and type annotations.
|
||||
*/
|
||||
_nested_pat: $ => choice(
|
||||
$._typed_pat,
|
||||
$.pat_view,
|
||||
)
|
||||
}
|
||||
@ -1,42 +0,0 @@
|
||||
const {parens} = require('./util.js')
|
||||
|
||||
module.exports = {
|
||||
// ------------------------------------------------------------------------
|
||||
// pattern synonym
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
_pattern_type: $ => seq(
|
||||
$._con,
|
||||
$._type_annotation,
|
||||
),
|
||||
|
||||
_pattern_equals: $ => seq(
|
||||
field('lhs', $._pat),
|
||||
'=',
|
||||
field('rhs', $._pat),
|
||||
),
|
||||
|
||||
_pattern_decl: $ => seq(
|
||||
$._pat,
|
||||
$._funrhs,
|
||||
),
|
||||
|
||||
/**
|
||||
* `where` may not be empty
|
||||
*/
|
||||
_pattern_arrow: $ => seq(
|
||||
field('lhs', $._pat),
|
||||
'<-',
|
||||
field('rhs', $._pat),
|
||||
optional(seq($.where, layouted($, $._pattern_decl))),
|
||||
),
|
||||
|
||||
decl_pattern: $ => seq(
|
||||
'pattern',
|
||||
choice(
|
||||
alias($._pattern_type, $.signature),
|
||||
alias($._pattern_equals, $.equation),
|
||||
alias($._pattern_arrow, $.equation),
|
||||
),
|
||||
),
|
||||
}
|
||||
@ -1,261 +0,0 @@
|
||||
const {parens} = require('./util.js')
|
||||
|
||||
module.exports = {
|
||||
// ------------------------------------------------------------------------
|
||||
// type
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
type_variable: $ => $._varid,
|
||||
|
||||
annotated_type_variable: $ => parens($.type_variable, $._type_annotation),
|
||||
|
||||
_tyvar: $ => choice(
|
||||
$.annotated_type_variable,
|
||||
$.type_variable,
|
||||
),
|
||||
|
||||
_forall_kw: _ => choice('forall', '∀'),
|
||||
|
||||
_forall_dot: _ => choice('.', '->'),
|
||||
|
||||
_forall: $ => seq(
|
||||
$._forall_kw,
|
||||
repeat1($._tyvar),
|
||||
),
|
||||
|
||||
_quantifiers: $ => seq(
|
||||
alias($._forall, $.quantifiers),
|
||||
$._forall_dot,
|
||||
),
|
||||
|
||||
forall: $ => $._quantifiers,
|
||||
|
||||
type_parens: $ => parens($._type_or_implicit),
|
||||
|
||||
type_list: $ => brackets(sep1($.comma, $._type_or_implicit)),
|
||||
|
||||
_type_tuple: $ => sep2($.comma, $._type_or_implicit),
|
||||
|
||||
type_tuple: $ => parens($._type_tuple),
|
||||
|
||||
_type_sum: $ => sep2('|', $._type_or_implicit),
|
||||
|
||||
_type_promotable_literal: $ => choice(
|
||||
$.type_literal,
|
||||
$.type_tuple,
|
||||
$.type_list,
|
||||
),
|
||||
|
||||
_type_promoted_literal: $ => seq(quote, $._type_promotable_literal),
|
||||
|
||||
_type_literal: $ => choice(
|
||||
alias($._type_promoted_literal, $.promoted),
|
||||
$._type_promotable_literal,
|
||||
),
|
||||
|
||||
strict_type: $ => seq($._strict, $._atype),
|
||||
|
||||
type_name: $ => choice(
|
||||
$._tyvar,
|
||||
$._gtycon,
|
||||
),
|
||||
|
||||
type_star: _ => '*',
|
||||
|
||||
/**
|
||||
* The `(##)` format of the unary tuple is parsed as an operator, see `exp_unboxed_tuple`.
|
||||
*/
|
||||
type_unboxed_tuple: $ => seq($._unboxed_open, sep($.comma, $._type_or_implicit), $._unboxed_close),
|
||||
|
||||
type_unboxed_sum: $ => seq($._unboxed_open, $._type_sum, $._unboxed_close),
|
||||
|
||||
_atype: $ => choice(
|
||||
$.type_name,
|
||||
$.type_star,
|
||||
$._type_literal,
|
||||
$.type_parens,
|
||||
$.type_unboxed_tuple,
|
||||
$.type_unboxed_sum,
|
||||
$.splice,
|
||||
$.quasiquote,
|
||||
),
|
||||
|
||||
/**
|
||||
* Type application, as in `Either e (Int, Text)`.
|
||||
*/
|
||||
type_apply: $ => seq($._atype, repeat1($._atype)),
|
||||
|
||||
/**
|
||||
* The point of this `choice` is to get a node for type application only if there is more than one atype present.
|
||||
*/
|
||||
_btype: $ => choice(
|
||||
$._atype,
|
||||
$.type_apply,
|
||||
),
|
||||
|
||||
implicit_param: $ => seq(
|
||||
$.implicit_parid,
|
||||
$._type_annotation,
|
||||
),
|
||||
|
||||
type_infix: $ => seq(
|
||||
field('left', $._btype),
|
||||
field('op', $._qtyconop),
|
||||
field('right', $._type_infix),
|
||||
),
|
||||
|
||||
_type_infix: $ => choice(
|
||||
$.type_infix,
|
||||
$._btype,
|
||||
),
|
||||
|
||||
constraint: $ => choice(
|
||||
seq(field('class', alias($.type_name, $.class_name)), repeat($._atype)),
|
||||
$.type_infix,
|
||||
),
|
||||
|
||||
_quantified_constraint: $ => seq($._quantifiers, $._constraint),
|
||||
|
||||
_constraint_context: $ => seq($._context, $._constraint),
|
||||
|
||||
_constraint: $ => choice(
|
||||
alias($._quantified_constraint, $.forall),
|
||||
alias($._constraint_context, $.context),
|
||||
parens($._constraint),
|
||||
$.constraint,
|
||||
),
|
||||
|
||||
_context_constraints: $ => seq(
|
||||
choice(
|
||||
$.constraint,
|
||||
prec('context-empty', parens(optional(sep1($.comma, choice($._constraint, $.implicit_param))))),
|
||||
),
|
||||
),
|
||||
|
||||
_context: $ => seq($._context_constraints, '=>'),
|
||||
|
||||
context: $ => $._context,
|
||||
|
||||
_type_quantifiers: $ => seq($._quantifiers, $._type),
|
||||
|
||||
_type_context: $ => seq($._context, $._type),
|
||||
|
||||
modifier: $ => seq('%', $._atype),
|
||||
|
||||
_fun_arrow: $ => seq(
|
||||
optional($.modifier),
|
||||
'->',
|
||||
),
|
||||
|
||||
_type_fun: $ => prec('function-type', seq($._type_infix, $._fun_arrow, $._type)),
|
||||
|
||||
_type: $ => prec('type', choice(
|
||||
alias($._type_quantifiers, $.forall),
|
||||
alias($._type_context, $.context),
|
||||
alias($._type_fun, $.fun),
|
||||
$._type_infix,
|
||||
)),
|
||||
|
||||
_type_or_implicit: $ => choice(
|
||||
$.implicit_param,
|
||||
$._type,
|
||||
),
|
||||
|
||||
_type_annotation: $ => seq(
|
||||
'::',
|
||||
field('type', $._type_or_implicit),
|
||||
),
|
||||
|
||||
_simpletype_infix: $ => seq(
|
||||
$._tyvar,
|
||||
field('name', $._simple_tyconop),
|
||||
$._tyvar,
|
||||
),
|
||||
|
||||
_simpletype: $ => choice(
|
||||
parens($._simpletype),
|
||||
alias($._simpletype_infix, $.type_infix),
|
||||
seq(
|
||||
field('name', $._simple_tycon),
|
||||
repeat($._tyvar),
|
||||
),
|
||||
),
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// type decl
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
decl_type: $ => seq(
|
||||
'type',
|
||||
$._simpletype,
|
||||
choice(
|
||||
seq('=', $._type_or_implicit),
|
||||
$._type_annotation
|
||||
),
|
||||
),
|
||||
|
||||
decl_tyfam_sig: $ => seq(
|
||||
'type',
|
||||
'family',
|
||||
$._simpletype,
|
||||
$._type_annotation,
|
||||
),
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// type family
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
tyfam_head: $ => $._simpletype,
|
||||
|
||||
_tyfam_pat_prefix: $ => seq(
|
||||
field('name', $._qtyconid),
|
||||
repeat($._atype),
|
||||
),
|
||||
|
||||
_tyfam_pat_infix: $ => seq(
|
||||
$._atype,
|
||||
field('op', $._qtyconop),
|
||||
$._atype,
|
||||
),
|
||||
|
||||
tyfam_pat: $ => choice(
|
||||
$._tyfam_pat_prefix,
|
||||
$._tyfam_pat_infix,
|
||||
),
|
||||
|
||||
tyfam_eq: $ => seq(
|
||||
alias($.tyfam_pat, $.pattern),
|
||||
'=',
|
||||
$._type_or_implicit,
|
||||
),
|
||||
|
||||
decl_tyfam: $ => seq(
|
||||
'type',
|
||||
'family',
|
||||
alias($.tyfam_head, $.head),
|
||||
optional($._type_annotation),
|
||||
optional(where($, alias($.tyfam_eq, $.equation))),
|
||||
),
|
||||
|
||||
decl_tyinst: $ => seq(
|
||||
'type',
|
||||
'instance',
|
||||
repeat($._atype),
|
||||
'=',
|
||||
$._type_or_implicit,
|
||||
),
|
||||
|
||||
type_role: _ => choice(
|
||||
'representational',
|
||||
'nominal',
|
||||
'phantom',
|
||||
'_',
|
||||
),
|
||||
|
||||
decl_role: $ => seq(
|
||||
'type',
|
||||
'role',
|
||||
$._qtycon,
|
||||
repeat1($.type_role),
|
||||
)
|
||||
}
|
||||
@ -1,73 +0,0 @@
|
||||
const
|
||||
|
||||
parens = (...rule) => seq('(', ...rule, ')')
|
||||
|
||||
braces = (...rule) => seq('{', ...rule, '}')
|
||||
|
||||
brackets = (...rule) => seq('[', ...rule, ']')
|
||||
|
||||
ticked = (...rule) => seq('`', ...rule, '`')
|
||||
|
||||
quote = '\''
|
||||
|
||||
qualified = ($, id) => seq($._qualifying_module, id)
|
||||
|
||||
sep = (sep, rule) => optional(seq(rule, repeat(seq(sep, rule))))
|
||||
|
||||
sep1 = (sep, rule) => seq(rule, repeat(seq(sep, rule)))
|
||||
|
||||
sep2 = (sep, rule) => seq(rule, repeat1(seq(sep, rule)))
|
||||
|
||||
/**
|
||||
* Wrap a repeated rule with semicolon rules.
|
||||
* Between any two occurences of a rule in a layout, if no explicit semicolon is encountered, delegate to the scanner
|
||||
* to determine heuristically where a statement or decl may end.
|
||||
* After the last repetition, the semicolon is optional.
|
||||
* The dynamic precision is needed because of some irregularities with standalone deriving decls and data deriving
|
||||
* clauses.
|
||||
*/
|
||||
terminated = ($, rule) => seq(
|
||||
sep1(prec.dynamic(1, choice(';', $._layout_semicolon)), rule),
|
||||
optional(choice(';', $._layout_semicolon)),
|
||||
)
|
||||
|
||||
layouted_braces = rule => braces(sep(';', rule), optional(';')),
|
||||
|
||||
/**
|
||||
* Wrap a repeated rule in a layout.
|
||||
* This is used for `where`, `let`, `of` and `do`, and the toplevel module.
|
||||
* The `_layout_start` rule is picked up by the scanner and causes the current column (or indent, for newline
|
||||
* layouts) to be recorded.
|
||||
* When a `_layout_end` or `_layout_semicolon` is encountered by the scanner, the recorded indent is compared to the
|
||||
* current one to make a decision.
|
||||
* If explicit braces are provided, the scanner isn't relevant.
|
||||
*/
|
||||
layouted = ($, rule) => choice(
|
||||
layouted_braces(rule),
|
||||
seq($._layout_start, optional(terminated($, rule)), $._layout_end),
|
||||
)
|
||||
|
||||
layouted_without_end = ($, rule) => choice(
|
||||
layouted_braces(rule),
|
||||
seq($._layout_start, optional(terminated($, rule))),
|
||||
)
|
||||
|
||||
where = ($, rule) => seq(
|
||||
$.where,
|
||||
optional(layouted($, rule)),
|
||||
)
|
||||
|
||||
module.exports = {
|
||||
parens,
|
||||
braces,
|
||||
brackets,
|
||||
ticked,
|
||||
quote,
|
||||
qualified,
|
||||
sep,
|
||||
sep1,
|
||||
sep2,
|
||||
terminated,
|
||||
layouted,
|
||||
where,
|
||||
}
|
||||
@ -1,38 +0,0 @@
|
||||
{
|
||||
"name": "tree-sitter-haskell",
|
||||
"version": "0.14.0",
|
||||
"description": "Haskell grammar for tree-sitter",
|
||||
"repository": "github:tree-sitter/tree-sitter-haskell",
|
||||
"main": "bindings/node",
|
||||
"keywords": [
|
||||
"parser",
|
||||
"haskell"
|
||||
],
|
||||
"author": "Rick Winfrey",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"nan": "^2.12.1",
|
||||
"node-gyp": "^7.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tree-sitter-cli": "^0.19.4",
|
||||
"web-tree-sitter": "^0.19.4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tree-sitter test",
|
||||
"examples": "script/parse-examples",
|
||||
"examples-wasm": "script/parse-examples wasm"
|
||||
},
|
||||
"tree-sitter": [
|
||||
{
|
||||
"scope": "source.haskell",
|
||||
"file-types": [
|
||||
"hs"
|
||||
],
|
||||
"highlights": [
|
||||
"queries/highlights.scm"
|
||||
],
|
||||
"injection-regex": "^(hs|haskell)$"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@ -1,154 +0,0 @@
|
||||
;; Copyright 2022 nvim-treesitter
|
||||
;;
|
||||
;; Licensed under the Apache License, Version 2.0 (the "License");
|
||||
;; you may not use this file except in compliance with the License.
|
||||
;; You may obtain a copy of the License at
|
||||
;;
|
||||
;; http://www.apache.org/licenses/LICENSE-2.0
|
||||
;;
|
||||
;; Unless required by applicable law or agreed to in writing, software
|
||||
;; distributed under the License is distributed on an "AS IS" BASIS,
|
||||
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
;; See the License for the specific language governing permissions and
|
||||
;; limitations under the License.
|
||||
|
||||
;; ----------------------------------------------------------------------------
|
||||
;; Literals and comments
|
||||
|
||||
(integer) @number
|
||||
(exp_negation) @number
|
||||
(exp_literal (float)) @float
|
||||
(char) @character
|
||||
(string) @string
|
||||
|
||||
(con_unit) @symbol ; unit, as in ()
|
||||
|
||||
(comment) @comment
|
||||
|
||||
|
||||
;; ----------------------------------------------------------------------------
|
||||
;; Punctuation
|
||||
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"{"
|
||||
"}"
|
||||
"["
|
||||
"]"
|
||||
] @punctuation.bracket
|
||||
|
||||
[
|
||||
(comma)
|
||||
";"
|
||||
] @punctuation.delimiter
|
||||
|
||||
|
||||
;; ----------------------------------------------------------------------------
|
||||
;; Keywords, operators, includes
|
||||
|
||||
[
|
||||
"forall"
|
||||
"∀"
|
||||
] @repeat
|
||||
|
||||
(pragma) @constant.macro
|
||||
|
||||
[
|
||||
"if"
|
||||
"then"
|
||||
"else"
|
||||
"case"
|
||||
"of"
|
||||
] @conditional
|
||||
|
||||
[
|
||||
"import"
|
||||
"qualified"
|
||||
"module"
|
||||
] @include
|
||||
|
||||
[
|
||||
(operator)
|
||||
(constructor_operator)
|
||||
(type_operator)
|
||||
(tycon_arrow)
|
||||
(qualified_module) ; grabs the `.` (dot), ex: import System.IO
|
||||
(all_names)
|
||||
(wildcard)
|
||||
"="
|
||||
"|"
|
||||
"::"
|
||||
"=>"
|
||||
"->"
|
||||
"<-"
|
||||
"\\"
|
||||
"`"
|
||||
"@"
|
||||
] @operator
|
||||
|
||||
(module) @namespace
|
||||
|
||||
[
|
||||
(where)
|
||||
"let"
|
||||
"in"
|
||||
"class"
|
||||
"instance"
|
||||
"data"
|
||||
"newtype"
|
||||
"family"
|
||||
"type"
|
||||
"as"
|
||||
"hiding"
|
||||
"deriving"
|
||||
"via"
|
||||
"stock"
|
||||
"anyclass"
|
||||
"do"
|
||||
"mdo"
|
||||
"rec"
|
||||
"infix"
|
||||
"infixl"
|
||||
"infixr"
|
||||
] @keyword
|
||||
|
||||
|
||||
;; ----------------------------------------------------------------------------
|
||||
;; Functions and variables
|
||||
|
||||
(variable) @variable
|
||||
(pat_wildcard) @variable
|
||||
|
||||
(signature name: (variable) @type)
|
||||
(function
|
||||
name: (variable) @function
|
||||
patterns: (patterns))
|
||||
((signature (fun)) . (function (variable) @function))
|
||||
((signature (context (fun))) . (function (variable) @function))
|
||||
((signature (forall (context (fun)))) . (function (variable) @function))
|
||||
|
||||
(exp_infix (variable) @operator) ; consider infix functions as operators
|
||||
|
||||
(exp_infix (exp_name) @function (#set! "priority" 101))
|
||||
(exp_apply . (exp_name (variable) @function))
|
||||
(exp_apply . (exp_name (qualified_variable (variable) @function)))
|
||||
|
||||
|
||||
;; ----------------------------------------------------------------------------
|
||||
;; Types
|
||||
|
||||
(type) @type
|
||||
(type_variable) @type
|
||||
|
||||
(constructor) @constructor
|
||||
|
||||
; True or False
|
||||
((constructor) @_bool (#match? @_bool "(True|False)")) @boolean
|
||||
|
||||
|
||||
;; ----------------------------------------------------------------------------
|
||||
;; Quasi-quotes
|
||||
|
||||
(quoter) @function
|
||||
; Highlighting of quasiquote_body is handled by injections.scm
|
||||
@ -1,4 +0,0 @@
|
||||
(signature name: (variable)) @local.definition
|
||||
(function name: (variable)) @local.definition
|
||||
(pat_name (variable)) @local.definition
|
||||
(exp_name (variable)) @local.reference
|
||||
@ -1 +0,0 @@
|
||||
examples/haskell-language-server/test/testdata/FuncTestFail.hs
|
||||
@ -1 +0,0 @@
|
||||
examples/polysemy/src/Polysemy/Law.hs
|
||||
@ -1,6 +0,0 @@
|
||||
examples/semantic/semantic/test/fixtures/haskell/corpus/function-declarations.A.hs
|
||||
examples/semantic/semantic/test/fixtures/haskell/corpus/function-declarations.B.hs
|
||||
examples/semantic/semantic/test/fixtures/haskell/corpus/type-synonyms.A.hs
|
||||
examples/semantic/semantic/test/fixtures/haskell/corpus/type-synonyms.B.hs
|
||||
examples/semantic/semantic/test/fixtures/haskell/corpus/tempate-haskell.A.hs
|
||||
examples/semantic/semantic/test/fixtures/haskell/corpus/template-haskell.B.hs
|
||||
@ -1,50 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Usage: script/parse-examples [repo_name] [native|wasm]
|
||||
|
||||
# Exit immediately if a command exits with a non-zero status.
|
||||
set -e
|
||||
|
||||
# Change directory to project root.
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
# Get the repository name
|
||||
name=$1
|
||||
repo=examples/$name
|
||||
|
||||
# Parse examples in 'native' or 'wasm' mode.
|
||||
mode=${2:-native}
|
||||
|
||||
known_failures=$(cat "script/known-failures-$name.txt")
|
||||
examples_to_parse=$(
|
||||
for example in $(find "$repo" -name '*.hs'); do
|
||||
if [[ ! $known_failures == *$example* ]]; then
|
||||
echo $example
|
||||
fi
|
||||
done
|
||||
)
|
||||
|
||||
if [ "$mode" == "native" ]; then
|
||||
# Ensure the scanner was recompiled
|
||||
tree-sitter test -f 'just compile it' >/dev/null
|
||||
elif [ "$mode" == "wasm" ]; then
|
||||
# Ensure tree-sitter-haskell.wasm was compiled
|
||||
make node_modules/web-tree-sitter -s
|
||||
make tree-sitter-haskell.wasm -s
|
||||
fi
|
||||
|
||||
start=$(date '+%s.%N')
|
||||
if [ "$mode" == "native" ]; then
|
||||
echo $examples_to_parse | xargs -n 2000 tree-sitter parse -q
|
||||
elif [ "$mode" == "wasm" ]; then
|
||||
echo $examples_to_parse | xargs -n 2000 ./script/tree-sitter-parse.js
|
||||
fi
|
||||
end=$(date '+%s.%N')
|
||||
|
||||
skipped=$( echo $known_failures | wc -w )
|
||||
parsed=$( echo $examples_to_parse | wc -w )
|
||||
total=$((parsed+skipped))
|
||||
percent=$(bc -l <<< "100*$parsed/$total")
|
||||
duration=$(bc -l <<< "$end - $start")
|
||||
|
||||
printf "Successfully parsed %.2f%% of '$name' in %.4fs (%d of %d files)\n" $percent $duration $parsed $total
|
||||
@ -1,42 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Usage: script/parse-examples [native|wasm]
|
||||
|
||||
# Exit immediately if a command exits with a non-zero status.
|
||||
set -e
|
||||
|
||||
# Parse examples in 'native' or 'wasm' mode.
|
||||
mode=${1:-native}
|
||||
|
||||
# Change directory to project root.
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
# Clone a GitHub repository to the examples directory
|
||||
# clone_repo OWNER NAME SHA
|
||||
function clone_repo {
|
||||
owner=$1
|
||||
name=$2
|
||||
sha=$3
|
||||
|
||||
path=examples/$name
|
||||
if [ ! -d "$path" ]; then
|
||||
git clone "https://github.com/$owner/$name" "$path" --quiet
|
||||
fi
|
||||
|
||||
pushd "$path" >/dev/null
|
||||
git fetch --quiet
|
||||
git reset --hard $sha --quiet
|
||||
popd >/dev/null
|
||||
}
|
||||
|
||||
clone_repo joshvera effects 08f5f36f2600362685af593f4b327e933b60bf97
|
||||
clone_repo PostgRest postgrest f80cfbf165f951a062b3cbedac4556019905ca49
|
||||
clone_repo GaloisInc ivory 3d00324ad1c113c7e70957ff6a6d636d271d0fc4
|
||||
clone_repo polysemy-research polysemy c37d485b614e98622f5e7473a478b781a6ad5c45
|
||||
clone_repo github semantic b162132339622fe1e80e243f630fe092d5c0cbe1
|
||||
clone_repo haskell haskell-language-server d397ef491ef1689d43028f4d3d01a42118292235
|
||||
clone_repo AndrasKovacs flatparse ddae0996d2bdd0b5b092484dbe5829b4ee2ef1f6
|
||||
|
||||
for name in effects postgrest ivory polysemy semantic haskell-language-server flatparse; do
|
||||
script/parse-example "$name" "$mode"
|
||||
done
|
||||
@ -1,21 +0,0 @@
|
||||
#!/usr/bin/env node --trace-warnings --unhandled-rejections=strict
|
||||
|
||||
const fs = require('fs');
|
||||
const Parser = require('web-tree-sitter');
|
||||
|
||||
if (process.argv.length < 3) {
|
||||
console.log('Usage: script/tree-sitter-parse.js <haskell-file..>')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
Parser.init().then(() => {
|
||||
Parser.Language.load('tree-sitter-haskell.wasm').then((Haskell) => {
|
||||
const parser = new Parser;
|
||||
parser.setLanguage(Haskell);
|
||||
for (let i = 2; i < process.argv.length - 1; i++) {
|
||||
const fileName = process.argv[i]
|
||||
const sourceCode = fs.readFileSync(fileName, 'utf8')
|
||||
const tree = parser.parse(sourceCode);
|
||||
}
|
||||
});
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,224 +0,0 @@
|
||||
#ifndef TREE_SITTER_PARSER_H_
|
||||
#define TREE_SITTER_PARSER_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define ts_builtin_sym_error ((TSSymbol)-1)
|
||||
#define ts_builtin_sym_end 0
|
||||
#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024
|
||||
|
||||
typedef uint16_t TSStateId;
|
||||
|
||||
#ifndef TREE_SITTER_API_H_
|
||||
typedef uint16_t TSSymbol;
|
||||
typedef uint16_t TSFieldId;
|
||||
typedef struct TSLanguage TSLanguage;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
TSFieldId field_id;
|
||||
uint8_t child_index;
|
||||
bool inherited;
|
||||
} TSFieldMapEntry;
|
||||
|
||||
typedef struct {
|
||||
uint16_t index;
|
||||
uint16_t length;
|
||||
} TSFieldMapSlice;
|
||||
|
||||
typedef struct {
|
||||
bool visible;
|
||||
bool named;
|
||||
bool supertype;
|
||||
} TSSymbolMetadata;
|
||||
|
||||
typedef struct TSLexer TSLexer;
|
||||
|
||||
struct TSLexer {
|
||||
int32_t lookahead;
|
||||
TSSymbol result_symbol;
|
||||
void (*advance)(TSLexer *, bool);
|
||||
void (*mark_end)(TSLexer *);
|
||||
uint32_t (*get_column)(TSLexer *);
|
||||
bool (*is_at_included_range_start)(const TSLexer *);
|
||||
bool (*eof)(const TSLexer *);
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
TSParseActionTypeShift,
|
||||
TSParseActionTypeReduce,
|
||||
TSParseActionTypeAccept,
|
||||
TSParseActionTypeRecover,
|
||||
} TSParseActionType;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t type;
|
||||
TSStateId state;
|
||||
bool extra;
|
||||
bool repetition;
|
||||
} shift;
|
||||
struct {
|
||||
uint8_t type;
|
||||
uint8_t child_count;
|
||||
TSSymbol symbol;
|
||||
int16_t dynamic_precedence;
|
||||
uint16_t production_id;
|
||||
} reduce;
|
||||
uint8_t type;
|
||||
} TSParseAction;
|
||||
|
||||
typedef struct {
|
||||
uint16_t lex_state;
|
||||
uint16_t external_lex_state;
|
||||
} TSLexMode;
|
||||
|
||||
typedef union {
|
||||
TSParseAction action;
|
||||
struct {
|
||||
uint8_t count;
|
||||
bool reusable;
|
||||
} entry;
|
||||
} TSParseActionEntry;
|
||||
|
||||
struct TSLanguage {
|
||||
uint32_t version;
|
||||
uint32_t symbol_count;
|
||||
uint32_t alias_count;
|
||||
uint32_t token_count;
|
||||
uint32_t external_token_count;
|
||||
uint32_t state_count;
|
||||
uint32_t large_state_count;
|
||||
uint32_t production_id_count;
|
||||
uint32_t field_count;
|
||||
uint16_t max_alias_sequence_length;
|
||||
const uint16_t *parse_table;
|
||||
const uint16_t *small_parse_table;
|
||||
const uint32_t *small_parse_table_map;
|
||||
const TSParseActionEntry *parse_actions;
|
||||
const char * const *symbol_names;
|
||||
const char * const *field_names;
|
||||
const TSFieldMapSlice *field_map_slices;
|
||||
const TSFieldMapEntry *field_map_entries;
|
||||
const TSSymbolMetadata *symbol_metadata;
|
||||
const TSSymbol *public_symbol_map;
|
||||
const uint16_t *alias_map;
|
||||
const TSSymbol *alias_sequences;
|
||||
const TSLexMode *lex_modes;
|
||||
bool (*lex_fn)(TSLexer *, TSStateId);
|
||||
bool (*keyword_lex_fn)(TSLexer *, TSStateId);
|
||||
TSSymbol keyword_capture_token;
|
||||
struct {
|
||||
const bool *states;
|
||||
const TSSymbol *symbol_map;
|
||||
void *(*create)(void);
|
||||
void (*destroy)(void *);
|
||||
bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist);
|
||||
unsigned (*serialize)(void *, char *);
|
||||
void (*deserialize)(void *, const char *, unsigned);
|
||||
} external_scanner;
|
||||
const TSStateId *primary_state_ids;
|
||||
};
|
||||
|
||||
/*
|
||||
* Lexer Macros
|
||||
*/
|
||||
|
||||
#define START_LEXER() \
|
||||
bool result = false; \
|
||||
bool skip = false; \
|
||||
bool eof = false; \
|
||||
int32_t lookahead; \
|
||||
goto start; \
|
||||
next_state: \
|
||||
lexer->advance(lexer, skip); \
|
||||
start: \
|
||||
skip = false; \
|
||||
lookahead = lexer->lookahead;
|
||||
|
||||
#define ADVANCE(state_value) \
|
||||
{ \
|
||||
state = state_value; \
|
||||
goto next_state; \
|
||||
}
|
||||
|
||||
#define SKIP(state_value) \
|
||||
{ \
|
||||
skip = true; \
|
||||
state = state_value; \
|
||||
goto next_state; \
|
||||
}
|
||||
|
||||
#define ACCEPT_TOKEN(symbol_value) \
|
||||
result = true; \
|
||||
lexer->result_symbol = symbol_value; \
|
||||
lexer->mark_end(lexer);
|
||||
|
||||
#define END_STATE() return result;
|
||||
|
||||
/*
|
||||
* Parse Table Macros
|
||||
*/
|
||||
|
||||
#define SMALL_STATE(id) id - LARGE_STATE_COUNT
|
||||
|
||||
#define STATE(id) id
|
||||
|
||||
#define ACTIONS(id) id
|
||||
|
||||
#define SHIFT(state_value) \
|
||||
{{ \
|
||||
.shift = { \
|
||||
.type = TSParseActionTypeShift, \
|
||||
.state = state_value \
|
||||
} \
|
||||
}}
|
||||
|
||||
#define SHIFT_REPEAT(state_value) \
|
||||
{{ \
|
||||
.shift = { \
|
||||
.type = TSParseActionTypeShift, \
|
||||
.state = state_value, \
|
||||
.repetition = true \
|
||||
} \
|
||||
}}
|
||||
|
||||
#define SHIFT_EXTRA() \
|
||||
{{ \
|
||||
.shift = { \
|
||||
.type = TSParseActionTypeShift, \
|
||||
.extra = true \
|
||||
} \
|
||||
}}
|
||||
|
||||
#define REDUCE(symbol_val, child_count_val, ...) \
|
||||
{{ \
|
||||
.reduce = { \
|
||||
.type = TSParseActionTypeReduce, \
|
||||
.symbol = symbol_val, \
|
||||
.child_count = child_count_val, \
|
||||
__VA_ARGS__ \
|
||||
}, \
|
||||
}}
|
||||
|
||||
#define RECOVER() \
|
||||
{{ \
|
||||
.type = TSParseActionTypeRecover \
|
||||
}}
|
||||
|
||||
#define ACCEPT_INPUT() \
|
||||
{{ \
|
||||
.type = TSParseActionTypeAccept \
|
||||
}}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TREE_SITTER_PARSER_H_
|
||||
@ -1,3 +0,0 @@
|
||||
a = 1
|
||||
b = 2
|
||||
c = 3
|
||||
@ -1,396 +0,0 @@
|
||||
================================================================================
|
||||
plain adt: empty
|
||||
================================================================================
|
||||
|
||||
data A
|
||||
|
||||
---
|
||||
|
||||
(haskell (adt (type)))
|
||||
|
||||
================================================================================
|
||||
plain adt: one nullary con
|
||||
================================================================================
|
||||
|
||||
data A = A
|
||||
|
||||
---
|
||||
|
||||
(haskell (adt (type) (constructors (data_constructor (constructor)))))
|
||||
|
||||
================================================================================
|
||||
plain adt: one unary con
|
||||
================================================================================
|
||||
|
||||
data A = A A
|
||||
|
||||
---
|
||||
|
||||
(haskell (adt (type) (constructors (data_constructor (constructor) (type_name (type))))))
|
||||
|
||||
================================================================================
|
||||
plain adt: strict
|
||||
================================================================================
|
||||
|
||||
data A = A !A !(A A)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type)
|
||||
(constructors
|
||||
(data_constructor
|
||||
(constructor)
|
||||
(strict_type (type_name (type)))
|
||||
(strict_type (type_parens (type_apply (type_name (type)) (type_name (type)))))))))
|
||||
|
||||
================================================================================
|
||||
plain adt: tyvars
|
||||
================================================================================
|
||||
|
||||
data A a a a = A a !a [a]
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type)
|
||||
(type_variable)
|
||||
(type_variable)
|
||||
(type_variable)
|
||||
(constructors
|
||||
(data_constructor (constructor) (type_name (type_variable)) (strict_type (type_name (type_variable))) (type_list (type_name (type_variable)))))))
|
||||
|
||||
================================================================================
|
||||
plain adt: unpack strict
|
||||
================================================================================
|
||||
|
||||
data A = A {-# unpack #-} !A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type)
|
||||
(constructors
|
||||
(data_constructor (constructor) (pragma) (strict_type (type_name (type)))))))
|
||||
|
||||
================================================================================
|
||||
plain adt: record
|
||||
================================================================================
|
||||
|
||||
data A a = A { a :: A, a, a :: A, a :: {-# unpack #-} !a, a :: !A }
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type)
|
||||
(type_variable)
|
||||
(constructors
|
||||
(data_constructor_record
|
||||
(constructor)
|
||||
(record_fields
|
||||
(field (variable) (type_name (type)))
|
||||
(comma)
|
||||
(field (variable) (comma) (variable) (type_name (type)))
|
||||
(comma)
|
||||
(field (variable) (pragma) (strict_type (type_name (type_variable))))
|
||||
(comma)
|
||||
(field (variable) (strict_type (type_name (type)))))))))
|
||||
|
||||
================================================================================
|
||||
plain adt: multiple cons
|
||||
================================================================================
|
||||
|
||||
data A = A | A A | A !A A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type)
|
||||
(constructors
|
||||
(data_constructor (constructor))
|
||||
(data_constructor (constructor) (type_name (type)))
|
||||
(data_constructor (constructor) (strict_type (type_name (type))) (type_name (type))))))
|
||||
|
||||
================================================================================
|
||||
plain adt: multiple records
|
||||
================================================================================
|
||||
|
||||
data A =
|
||||
A { a :: A, a :: !A }
|
||||
|
|
||||
A { a :: A }
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type)
|
||||
(constructors
|
||||
(data_constructor_record
|
||||
(constructor)
|
||||
(record_fields
|
||||
(field (variable) (type_name (type)))
|
||||
(comma)
|
||||
(field (variable) (strict_type (type_name (type))))))
|
||||
(data_constructor_record
|
||||
(constructor)
|
||||
(record_fields
|
||||
(field (variable) (type_name (type))))))))
|
||||
|
||||
================================================================================
|
||||
plain adt: deriving basic
|
||||
================================================================================
|
||||
|
||||
data A = A deriving A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type)
|
||||
(constructors (data_constructor (constructor)))
|
||||
(deriving (type))))
|
||||
|
||||
================================================================================
|
||||
plain adt: deriving empty
|
||||
================================================================================
|
||||
|
||||
data A deriving A
|
||||
|
||||
data A
|
||||
deriving A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt (type) (deriving (type)))
|
||||
(adt (type) (deriving (type))))
|
||||
|
||||
================================================================================
|
||||
plain adt: deriving multi, strategy
|
||||
================================================================================
|
||||
|
||||
data A = A deriving (A, A) deriving stock (A)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type)
|
||||
(constructors (data_constructor (constructor)))
|
||||
(deriving (constraint (class_name (type))) (comma) (constraint (class_name (type))))
|
||||
(deriving (deriving_strategy) (constraint (class_name (type))))))
|
||||
|
||||
================================================================================
|
||||
plain adt: deriving via
|
||||
================================================================================
|
||||
|
||||
data A = A deriving (A) via (A A)
|
||||
data A = A deriving (A) via A A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type)
|
||||
(constructors (data_constructor (constructor)))
|
||||
(deriving
|
||||
(constraint (class_name (type)))
|
||||
(via (type_parens (type_apply (type_name (type)) (type_name (type)))))))
|
||||
(adt
|
||||
(type)
|
||||
(constructors (data_constructor (constructor)))
|
||||
(deriving
|
||||
(constraint (class_name (type)))
|
||||
(via (type_apply (type_name (type)) (type_name (type)))))))
|
||||
|
||||
================================================================================
|
||||
plain adt: deriving on newline, multiple
|
||||
================================================================================
|
||||
|
||||
data A =
|
||||
A
|
||||
deriving A
|
||||
deriving A
|
||||
data A =
|
||||
A
|
||||
deriving A
|
||||
deriving A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type)
|
||||
(constructors (data_constructor (constructor)))
|
||||
(deriving (type))
|
||||
(deriving (type)))
|
||||
(adt
|
||||
(type)
|
||||
(constructors (data_constructor (constructor)))
|
||||
(deriving (type))
|
||||
(deriving (type))))
|
||||
|
||||
================================================================================
|
||||
plain adt: deriving with forall/context
|
||||
================================================================================
|
||||
|
||||
data A = A deriving (∀ a . A => A)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type)
|
||||
(constructors (data_constructor (constructor)))
|
||||
(deriving
|
||||
(forall
|
||||
(quantifiers (type_variable))
|
||||
(context (constraint (class_name (type)))
|
||||
(constraint (class_name (type))))))))
|
||||
|
||||
================================================================================
|
||||
plain adt: context
|
||||
================================================================================
|
||||
|
||||
data A a (A a) => A = A
|
||||
data (A a, A a) => A = A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(context
|
||||
(constraint
|
||||
(class_name (type))
|
||||
(type_name (type_variable))
|
||||
(type_parens (type_apply (type_name (type)) (type_name (type_variable)))))
|
||||
)
|
||||
(type)
|
||||
(constructors (data_constructor (constructor))))
|
||||
(adt
|
||||
(context
|
||||
(constraint (class_name (type)) (type_name (type_variable)))
|
||||
(comma)
|
||||
(constraint (class_name (type)) (type_name (type_variable)))
|
||||
)
|
||||
(type)
|
||||
(constructors (data_constructor (constructor)))))
|
||||
|
||||
================================================================================
|
||||
plain adt: prim
|
||||
================================================================================
|
||||
|
||||
data A = A !A#
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type)
|
||||
(constructors (data_constructor (constructor) (strict_type (type_name (type)))))))
|
||||
|
||||
================================================================================
|
||||
plain adt: forall
|
||||
================================================================================
|
||||
|
||||
data A = forall a . A | ∀ a . A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type)
|
||||
(constructors
|
||||
(forall (quantifiers (type_variable)))
|
||||
(data_constructor (constructor))
|
||||
(forall (quantifiers (type_variable)))
|
||||
(data_constructor (constructor)))))
|
||||
|
||||
================================================================================
|
||||
plain adt: con context
|
||||
================================================================================
|
||||
|
||||
data A = ∀ a . A a => A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type)
|
||||
(constructors
|
||||
(forall (quantifiers (type_variable)))
|
||||
(context (constraint (class_name (type)) (type_name (type_variable))))
|
||||
(data_constructor (constructor)))))
|
||||
|
||||
================================================================================
|
||||
plain adt: type_variable kind
|
||||
================================================================================
|
||||
|
||||
data A (a :: * -> 'A)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type)
|
||||
(annotated_type_variable
|
||||
(type_variable)
|
||||
(fun (type_star) (type_name (promoted (type)))))))
|
||||
|
||||
================================================================================
|
||||
plain adt: signature
|
||||
================================================================================
|
||||
|
||||
data A :: (k -> '[ 'A]) -> *
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type)
|
||||
(fun
|
||||
(type_parens
|
||||
(fun
|
||||
(type_name (type_variable))
|
||||
(promoted (type_list (type_name (promoted (type)))))))
|
||||
(type_star))))
|
||||
|
||||
================================================================================
|
||||
plain adt: type operator varsym
|
||||
================================================================================
|
||||
|
||||
data a +++ b = a :+++ b
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type_infix (type_variable) (type_operator) (type_variable))
|
||||
(constructors
|
||||
(data_constructor_infix
|
||||
(type_name (type_variable))
|
||||
(constructor_operator)
|
||||
(type_name (type_variable))))))
|
||||
|
||||
================================================================================
|
||||
plain adt: type operator consym
|
||||
================================================================================
|
||||
|
||||
data a :<- b = a :<- b
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type_infix (type_variable) (constructor_operator) (type_variable))
|
||||
(constructors
|
||||
(data_constructor_infix
|
||||
(type_name (type_variable))
|
||||
(constructor_operator)
|
||||
(type_name (type_variable))))))
|
||||
@ -1,246 +0,0 @@
|
||||
================================================================================
|
||||
class: minimal
|
||||
================================================================================
|
||||
|
||||
class A a
|
||||
|
||||
---
|
||||
|
||||
(haskell (class (class_head class: (class_name (type)) (type_name (type_variable)))))
|
||||
|
||||
================================================================================
|
||||
class: context variants
|
||||
================================================================================
|
||||
|
||||
class A a => Read a
|
||||
class (A a, A a) => A a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(class
|
||||
(context
|
||||
(constraint (class_name (type)) (type_name (type_variable)))
|
||||
)
|
||||
(class_head (class_name (type)) (type_name (type_variable))))
|
||||
(class
|
||||
(context
|
||||
(constraint (class_name (type)) (type_name (type_variable)))
|
||||
(comma)
|
||||
(constraint (class_name (type)) (type_name (type_variable)))
|
||||
)
|
||||
(class_head (class_name (type)) (type_name (type_variable)))))
|
||||
|
||||
================================================================================
|
||||
class: method with context
|
||||
================================================================================
|
||||
|
||||
class A a where a :: A a => a -> a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(class
|
||||
(class_head class: (class_name (type)) (type_name (type_variable)))
|
||||
(class_body
|
||||
(where)
|
||||
(signature
|
||||
name: (variable)
|
||||
type: (context
|
||||
(constraint class: (class_name (type)) (type_name (type_variable)))
|
||||
(fun (type_name (type_variable)) (type_name (type_variable))))))))
|
||||
|
||||
================================================================================
|
||||
class: braces
|
||||
================================================================================
|
||||
|
||||
class Foo a where {
|
||||
a :: a;
|
||||
a :: a;
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(class
|
||||
(class_head (class_name (type)) (type_name (type_variable)))
|
||||
(class_body
|
||||
(where)
|
||||
(signature (variable) (type_name (type_variable)))
|
||||
(signature (variable) (type_name (type_variable))))))
|
||||
|
||||
================================================================================
|
||||
class: fixity
|
||||
================================================================================
|
||||
|
||||
class A where
|
||||
infixl `op`
|
||||
a :: Int
|
||||
infixr 7 `op`
|
||||
a = a
|
||||
infix 7 `op`, `ip`, `ap`
|
||||
infix <$>
|
||||
infix 7 <$>
|
||||
infix 7 :
|
||||
infix 7 :.
|
||||
infix 7 :<:
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(class
|
||||
(class_head (class_name (type)))
|
||||
(class_body
|
||||
(where)
|
||||
(fixity (varop (variable)))
|
||||
(signature (variable) (type_name (type)))
|
||||
(fixity (integer) (varop (variable)))
|
||||
(function (variable) (exp_name (variable)))
|
||||
(fixity (integer) (varop (variable)) (comma) (varop (variable)) (comma) (varop (variable)))
|
||||
(fixity (varop (operator)))
|
||||
(fixity (integer) (varop (operator)))
|
||||
(fixity (integer) (constructor_operator))
|
||||
(fixity (integer) (constructor_operator))
|
||||
(fixity (integer) (constructor_operator)))))
|
||||
|
||||
================================================================================
|
||||
class: multi method operator
|
||||
================================================================================
|
||||
|
||||
class A where
|
||||
(<), (<=), (>=), (>) :: a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(class
|
||||
(class_head (class_name (type)))
|
||||
(class_body
|
||||
(where)
|
||||
(signature
|
||||
(operator)
|
||||
(comma)
|
||||
(operator)
|
||||
(comma)
|
||||
(operator)
|
||||
(comma)
|
||||
(operator)
|
||||
(type_name (type_variable))))))
|
||||
|
||||
================================================================================
|
||||
class: multi param
|
||||
================================================================================
|
||||
|
||||
class A a a a
|
||||
|
||||
---
|
||||
|
||||
(haskell (class (class_head (class_name (type)) (type_name (type_variable)) (type_name (type_variable)) (type_name (type_variable)))))
|
||||
|
||||
================================================================================
|
||||
class: default signature
|
||||
================================================================================
|
||||
|
||||
class A where
|
||||
a :: Int
|
||||
default a :: Int
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(class
|
||||
(class_head (class_name (type)))
|
||||
(class_body
|
||||
(where)
|
||||
(signature (variable) (type_name (type)))
|
||||
(default_signature (signature (variable) (type_name (type)))))))
|
||||
|
||||
================================================================================
|
||||
class: type_variable kind
|
||||
================================================================================
|
||||
|
||||
class A (a :: [*] -> k)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(class
|
||||
(class_head
|
||||
(class_name (type))
|
||||
(type_name
|
||||
(annotated_type_variable
|
||||
(type_variable)
|
||||
(fun (type_list (type_star)) (type_name (type_variable))))))))
|
||||
|
||||
================================================================================
|
||||
class: associated family
|
||||
================================================================================
|
||||
|
||||
class A a where
|
||||
type A a :: a
|
||||
type A a = A
|
||||
type family A a :: a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(class
|
||||
(class_head (class_name (type)) (type_name (type_variable)))
|
||||
(class_body
|
||||
(where)
|
||||
(decl_type (type) (type_variable) (type_name (type_variable)))
|
||||
(decl_type (type) (type_variable) (type_name (type)))
|
||||
(decl_tyfam_sig (type) (type_variable) (type_name (type_variable))))))
|
||||
|
||||
================================================================================
|
||||
class: associated data
|
||||
================================================================================
|
||||
|
||||
class A a where
|
||||
data A a
|
||||
data family A a :: * -> Type
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(class
|
||||
(class_head (class_name (type)) (type_name (type_variable)))
|
||||
(class_body
|
||||
(where)
|
||||
(data_family (type) (type_variable))
|
||||
(data_family
|
||||
(type)
|
||||
(type_variable)
|
||||
(fun (type_star) (type_name (type)))))))
|
||||
|
||||
================================================================================
|
||||
class: fundeps
|
||||
================================================================================
|
||||
|
||||
class A | a -> a a, a a -> a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(class
|
||||
(class_head class: (class_name (type)))
|
||||
(fundeps
|
||||
(fundep (type_variable) (type_variable) (type_variable))
|
||||
(comma)
|
||||
(fundep (type_variable) (type_variable) (type_variable)))))
|
||||
|
||||
================================================================================
|
||||
class: infix operator name
|
||||
================================================================================
|
||||
|
||||
class a ++ b
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(class
|
||||
(class_head
|
||||
(type_infix
|
||||
left: (type_name (type_variable))
|
||||
op: (type_operator)
|
||||
right: (type_name (type_variable))))))
|
||||
@ -1,96 +0,0 @@
|
||||
================================================================================
|
||||
comment: line
|
||||
================================================================================
|
||||
|
||||
--
|
||||
-- a
|
||||
--
|
||||
-- a
|
||||
|
||||
---
|
||||
|
||||
(haskell (comment) (comment) (comment) (comment) (empty_file))
|
||||
|
||||
================================================================================
|
||||
comment: multi
|
||||
================================================================================
|
||||
|
||||
{- a
|
||||
a
|
||||
- a
|
||||
-}
|
||||
f = a
|
||||
{-a-}
|
||||
|
||||
---
|
||||
|
||||
(haskell (comment) (function (variable) (exp_name (variable))) (comment))
|
||||
|
||||
================================================================================
|
||||
comment: hash inside
|
||||
================================================================================
|
||||
|
||||
{- #comment -}
|
||||
|
||||
---
|
||||
|
||||
(haskell (comment) (empty_file))
|
||||
|
||||
================================================================================
|
||||
comment: newline termination
|
||||
================================================================================
|
||||
|
||||
--
|
||||
|
||||
---
|
||||
|
||||
(haskell (comment) (empty_file))
|
||||
|
||||
================================================================================
|
||||
comment: nested
|
||||
================================================================================
|
||||
|
||||
{- comment
|
||||
{- nested
|
||||
-}
|
||||
-}
|
||||
|
||||
---
|
||||
|
||||
(haskell (comment) (empty_file))
|
||||
|
||||
================================================================================
|
||||
comment: unicode symbol
|
||||
================================================================================
|
||||
|
||||
-- ∀
|
||||
|
||||
{- ∀ -}
|
||||
|
||||
---
|
||||
|
||||
(haskell (comment) (comment) (empty_file))
|
||||
|
||||
================================================================================
|
||||
comment: double minus before multiline end
|
||||
================================================================================
|
||||
|
||||
module A where
|
||||
|
||||
{- --}
|
||||
|
||||
---
|
||||
|
||||
(haskell (module) (where) (comment))
|
||||
|
||||
================================================================================
|
||||
comment: double brace before nested begin
|
||||
================================================================================
|
||||
|
||||
module A where
|
||||
|
||||
{- {{- -} -}
|
||||
|
||||
---
|
||||
|
||||
(haskell (module) (where) (comment))
|
||||
@ -1,27 +0,0 @@
|
||||
================================================================================
|
||||
consym: valid
|
||||
================================================================================
|
||||
|
||||
data A = Int :+ Int
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type)
|
||||
(constructors
|
||||
(data_constructor_infix
|
||||
(type_name (type))
|
||||
(constructor_operator)
|
||||
(type_name (type))))))
|
||||
|
||||
|
||||
================================================================================
|
||||
consym: error: ::
|
||||
================================================================================
|
||||
|
||||
data A = Int :: Int
|
||||
|
||||
---
|
||||
|
||||
(haskell (adt (type) (constructors (data_constructor (constructor) (ERROR) (type_name (type))))))
|
||||
@ -1,137 +0,0 @@
|
||||
================================================================================
|
||||
context: multi, multi line
|
||||
================================================================================
|
||||
|
||||
a ::
|
||||
A a a =>
|
||||
(A a, A a) =>
|
||||
(A => a a) ->
|
||||
A a ->
|
||||
a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(signature
|
||||
(variable)
|
||||
(context
|
||||
(constraint (class_name (type)) (type_name (type_variable)) (type_name (type_variable)))
|
||||
(context
|
||||
(constraint (class_name (type)) (type_name (type_variable)))
|
||||
(comma)
|
||||
(constraint (class_name (type)) (type_name (type_variable)))
|
||||
(fun
|
||||
(type_parens
|
||||
(context (constraint (class_name (type)))
|
||||
(type_apply (type_name (type_variable)) (type_name (type_variable)))))
|
||||
(fun (type_apply (type_name (type)) (type_name (type_variable))) (type_name (type_variable))))))))
|
||||
|
||||
================================================================================
|
||||
context: multi, single line
|
||||
================================================================================
|
||||
|
||||
a :: A a a => (A a, A a) => a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(signature
|
||||
(variable)
|
||||
(context
|
||||
(constraint (class_name (type)) (type_name (type_variable)) (type_name (type_variable)))
|
||||
(context
|
||||
(constraint (class_name (type)) (type_name (type_variable)))
|
||||
(comma)
|
||||
(constraint (class_name (type)) (type_name (type_variable)))
|
||||
(type_name (type_variable))))))
|
||||
|
||||
================================================================================
|
||||
context: operator
|
||||
================================================================================
|
||||
|
||||
a :: a ++ a => a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(signature
|
||||
name: (variable)
|
||||
type: (context
|
||||
(constraint (type_infix left: (type_name (type_variable)) op: (type_operator) right: (type_name (type_variable))))
|
||||
(type_name (type_variable)))))
|
||||
|
||||
================================================================================
|
||||
context: implicit
|
||||
================================================================================
|
||||
|
||||
a :: (?aaa :: a -> a -> a) => a -> a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(signature
|
||||
(variable)
|
||||
(context
|
||||
(implicit_param
|
||||
(implicit_parid)
|
||||
(fun (type_name (type_variable)) (fun (type_name (type_variable)) (type_name (type_variable)))))
|
||||
(fun
|
||||
(type_name (type_variable))
|
||||
(type_name (type_variable))))))
|
||||
|
||||
================================================================================
|
||||
context: forall/context in constraint
|
||||
================================================================================
|
||||
|
||||
a :: (forall a . A => A) => A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(signature
|
||||
(variable)
|
||||
(context
|
||||
(forall
|
||||
(quantifiers (type_variable))
|
||||
(context (constraint (class_name (type)))
|
||||
(constraint (class_name (type)))))
|
||||
(type_name (type)))))
|
||||
|
||||
================================================================================
|
||||
context: multiple nested foralls/contexts in constraint
|
||||
================================================================================
|
||||
|
||||
a :: (forall a . forall a . (forall a . A => A) => forall a . A => A) => A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(signature
|
||||
(variable)
|
||||
(context
|
||||
(forall
|
||||
(quantifiers (type_variable))
|
||||
(forall
|
||||
(quantifiers (type_variable))
|
||||
(context
|
||||
(forall
|
||||
(quantifiers (type_variable))
|
||||
(context
|
||||
(constraint (class_name (type)))
|
||||
(constraint (class_name (type)))))
|
||||
(forall
|
||||
(quantifiers (type_variable))
|
||||
(context
|
||||
(constraint (class_name (type)))
|
||||
(constraint (class_name (type))))))))
|
||||
(type_name (type)))))
|
||||
|
||||
================================================================================
|
||||
context: double parenthesis
|
||||
================================================================================
|
||||
|
||||
a :: ((A)) => A
|
||||
|
||||
---
|
||||
|
||||
(haskell (signature (variable) (context (constraint (class_name (type))) (type_name (type)))))
|
||||
@ -1,92 +0,0 @@
|
||||
================================================================================
|
||||
cpp: restore layout
|
||||
================================================================================
|
||||
|
||||
a = do
|
||||
do
|
||||
do
|
||||
a <- a
|
||||
#ifndef Aaaa
|
||||
a <- a
|
||||
#elif Aaa
|
||||
a <- a
|
||||
a
|
||||
a
|
||||
#else
|
||||
a <- a
|
||||
a
|
||||
a
|
||||
#endif
|
||||
a <- a
|
||||
a
|
||||
a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_do
|
||||
(stmt
|
||||
(exp_do
|
||||
(stmt
|
||||
(exp_do
|
||||
(stmt (bind_pattern (pat_name (variable)) (exp_name (variable))))
|
||||
(cpp)))
|
||||
(stmt (bind_pattern (pat_name (variable)) (exp_name (variable))))
|
||||
(cpp)
|
||||
(cpp)
|
||||
(stmt (bind_pattern (pat_name (variable)) (exp_name (variable))))
|
||||
(stmt (exp_name (variable)))))
|
||||
(stmt (exp_name (variable))))))
|
||||
|
||||
================================================================================
|
||||
cpp: multiline
|
||||
================================================================================
|
||||
|
||||
#if a \
|
||||
a \
|
||||
a
|
||||
|
||||
a = a
|
||||
|
||||
#endif
|
||||
|
||||
---
|
||||
|
||||
(haskell (cpp) (function (variable) (exp_name (variable))) (cpp))
|
||||
|
||||
================================================================================
|
||||
cpp: newline after decl in layout with one-way if
|
||||
================================================================================
|
||||
|
||||
instance A where
|
||||
a = a
|
||||
|
||||
#if
|
||||
a = a
|
||||
#endif
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(instance
|
||||
(instance_head (class_name (type)))
|
||||
(where)
|
||||
(function (variable) (exp_name (variable)))
|
||||
(cpp)
|
||||
(function (variable) (exp_name (variable)))
|
||||
(cpp)))
|
||||
|
||||
================================================================================
|
||||
cpp: incomplete #if/#else
|
||||
================================================================================
|
||||
|
||||
#if a
|
||||
#else
|
||||
|
||||
a = a
|
||||
|
||||
---
|
||||
|
||||
(haskell (cpp) (ERROR (empty_file)) (empty_file))
|
||||
@ -1,12 +0,0 @@
|
||||
================================================================================
|
||||
default: default decl
|
||||
================================================================================
|
||||
|
||||
default ()
|
||||
default (A, A)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(default_declaration)
|
||||
(default_declaration (type_name (type)) (comma) (type_name (type))))
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,216 +0,0 @@
|
||||
================================================================================
|
||||
family: closed, nullary
|
||||
================================================================================
|
||||
|
||||
type family A where
|
||||
A = A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_family
|
||||
(head (type))
|
||||
(where)
|
||||
(equation
|
||||
(pattern (type))
|
||||
(type_name (type)))))
|
||||
|
||||
================================================================================
|
||||
family: closed, tyvars
|
||||
================================================================================
|
||||
|
||||
type family A a b c where
|
||||
A a b c = b c
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_family
|
||||
(head name: (type) (type_variable) (type_variable) (type_variable))
|
||||
(where)
|
||||
(equation
|
||||
(pattern name: (type) (type_name (type_variable)) (type_name (type_variable)) (type_name (type_variable)))
|
||||
(type_apply (type_name (type_variable)) (type_name (type_variable))))))
|
||||
|
||||
================================================================================
|
||||
family: closed, pattern matching
|
||||
================================================================================
|
||||
|
||||
type family A a b c where
|
||||
A (Maybe a) [c] = a (Maybe c)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_family
|
||||
(head (type) (type_variable) (type_variable) (type_variable))
|
||||
(where)
|
||||
(equation
|
||||
(pattern
|
||||
(type)
|
||||
(type_parens (type_apply (type_name (type)) (type_name (type_variable))))
|
||||
(type_list (type_name (type_variable))))
|
||||
(type_apply (type_name (type_variable)) (type_parens (type_apply (type_name (type)) (type_name (type_variable))))))))
|
||||
|
||||
================================================================================
|
||||
family: closed, signature
|
||||
================================================================================
|
||||
|
||||
type family A a :: (k -> *) -> 'Just k where
|
||||
A a = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_family
|
||||
(head name: (type) (type_variable))
|
||||
type: (fun
|
||||
(type_parens (fun (type_name (type_variable)) (type_star)))
|
||||
(type_apply (type_name (promoted (type))) (type_name (type_variable))))
|
||||
(where)
|
||||
(equation
|
||||
(pattern name: (type) (type_name (type_variable)))
|
||||
(type_name (type_variable)))))
|
||||
|
||||
================================================================================
|
||||
family: closed, type_variable kind
|
||||
================================================================================
|
||||
|
||||
type family A (a :: ([k] -> *) -> k) where
|
||||
A a = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_family
|
||||
(head
|
||||
(type)
|
||||
(annotated_type_variable
|
||||
(type_variable)
|
||||
(fun
|
||||
(type_parens (fun (type_list (type_name (type_variable))) (type_star)))
|
||||
(type_name (type_variable)))))
|
||||
(where)
|
||||
(equation (pattern (type) (type_name (type_variable))) (type_name (type_variable)))))
|
||||
|
||||
================================================================================
|
||||
family: open
|
||||
================================================================================
|
||||
|
||||
type family A (a :: a) :: *
|
||||
type instance A [A] = A
|
||||
type instance A (A A) = A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_family
|
||||
(head
|
||||
name: (type)
|
||||
(annotated_type_variable (type_variable) type: (type_name (type_variable))))
|
||||
type: (type_star))
|
||||
(type_instance
|
||||
(type_name (type))
|
||||
(type_list (type_name (type)))
|
||||
(type_name (type)))
|
||||
(type_instance
|
||||
(type_name (type))
|
||||
(type_parens
|
||||
(type_apply
|
||||
(type_name (type))
|
||||
(type_name (type))))
|
||||
(type_name (type))))
|
||||
|
||||
================================================================================
|
||||
family: data family
|
||||
================================================================================
|
||||
|
||||
data family A a (a :: [a]) :: Type -> *
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(data_family
|
||||
(type)
|
||||
(type_variable)
|
||||
(annotated_type_variable (type_variable) (type_list (type_name (type_variable))))
|
||||
(fun (type_name (type)) (type_star))))
|
||||
|
||||
================================================================================
|
||||
family: data instance adt
|
||||
================================================================================
|
||||
|
||||
data instance ∀ a . A a A =
|
||||
A a A a
|
||||
|
|
||||
A { a :: A }
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(data_instance
|
||||
(forall (quantifiers (type_variable)))
|
||||
(type_apply
|
||||
(type_name (type))
|
||||
(type_name (type_variable))
|
||||
(type_name (type)))
|
||||
(constructors
|
||||
(data_constructor (constructor) (type_name (type_variable)) (type_name (type)) (type_name (type_variable)))
|
||||
(data_constructor_record
|
||||
(constructor)
|
||||
(record_fields (field (variable) (type_name (type))))))))
|
||||
|
||||
================================================================================
|
||||
family: data instance gadt
|
||||
================================================================================
|
||||
|
||||
data instance A a where
|
||||
A :: A -> A a
|
||||
deriving (A, A)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(data_instance
|
||||
(type_apply
|
||||
(type_name (type))
|
||||
(type_name (type_variable)))
|
||||
(where)
|
||||
(gadt_constructor
|
||||
(constructor)
|
||||
(fun (type_name (type)) (type_apply (type_name (type)) (type_name (type_variable)))))
|
||||
(deriving (constraint (class_name (type))) (comma) (constraint (class_name (type))))))
|
||||
|
||||
================================================================================
|
||||
family: data instance newtype
|
||||
================================================================================
|
||||
|
||||
newtype instance A a a = A a deriving A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(data_instance
|
||||
(type_apply
|
||||
(type_name (type))
|
||||
(type_name (type_variable))
|
||||
(type_name (type_variable)))
|
||||
(newtype_constructor (constructor) (type_name (type_variable)))
|
||||
(deriving (type))))
|
||||
|
||||
================================================================================
|
||||
family: symbolic equation
|
||||
================================================================================
|
||||
|
||||
type family A a where
|
||||
a <> a = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_family
|
||||
(head (type) (type_variable))
|
||||
(where)
|
||||
(equation
|
||||
(pattern (type_name (type_variable)) (type_operator) (type_name (type_variable)))
|
||||
(type_name (type_variable)))))
|
||||
@ -1,49 +0,0 @@
|
||||
================================================================================
|
||||
foreign: safety, calling convention
|
||||
================================================================================
|
||||
|
||||
foreign import ccall interruptible "safe import" a :: A
|
||||
foreign import prim "prim" a :: (# A#, A# #)
|
||||
foreign export stdcall unsafe "unsafe import" a :: A
|
||||
foreign export cplusplus safe "safe import" a :: A
|
||||
foreign import jvm unsafe "unsafe import" a :: A
|
||||
foreign import dotnet unsafe "unsafe import" a :: A
|
||||
foreign import capi unsafe "unsafe import" a :: A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(foreign_import
|
||||
(calling_convention)
|
||||
(safety)
|
||||
(impent (string))
|
||||
(signature (variable) (type_name (type))))
|
||||
(foreign_import
|
||||
(calling_convention)
|
||||
(impent (string))
|
||||
(signature (variable) (type_unboxed_tuple (type_name (type)) (comma) (type_name (type)))))
|
||||
(foreign_export
|
||||
(calling_convention)
|
||||
(safety)
|
||||
(expent (string))
|
||||
(signature (variable) (type_name (type))))
|
||||
(foreign_export
|
||||
(calling_convention)
|
||||
(safety)
|
||||
(expent (string))
|
||||
(signature (variable) (type_name (type))))
|
||||
(foreign_import
|
||||
(calling_convention)
|
||||
(safety)
|
||||
(impent (string))
|
||||
(signature (variable) (type_name (type))))
|
||||
(foreign_import
|
||||
(calling_convention)
|
||||
(safety)
|
||||
(impent (string))
|
||||
(signature (variable) (type_name (type))))
|
||||
(foreign_import
|
||||
(calling_convention)
|
||||
(safety)
|
||||
(impent (string))
|
||||
(signature (variable) (type_name (type)))))
|
||||
@ -1,190 +0,0 @@
|
||||
================================================================================
|
||||
gadt: empty
|
||||
================================================================================
|
||||
|
||||
data A where
|
||||
|
||||
---
|
||||
|
||||
(haskell (adt (type) (where)))
|
||||
|
||||
================================================================================
|
||||
gadt: basic
|
||||
================================================================================
|
||||
|
||||
data A a where
|
||||
A :: A -> !(A a) ->
|
||||
A a
|
||||
A :: {-# unpack #-} A -> A a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type)
|
||||
(type_variable)
|
||||
(where)
|
||||
(gadt_constructor
|
||||
(constructor)
|
||||
(fun
|
||||
(type_name (type))
|
||||
(fun
|
||||
(strict_type (type_parens (type_apply (type_name (type)) (type_name (type_variable)))))
|
||||
(type_apply (type_name (type)) (type_name (type_variable))))))
|
||||
(gadt_constructor
|
||||
(constructor)
|
||||
(pragma)
|
||||
(fun
|
||||
(type_name (type))
|
||||
(type_apply (type_name (type)) (type_name (type_variable)))))))
|
||||
|
||||
================================================================================
|
||||
gadt: record
|
||||
================================================================================
|
||||
|
||||
data A where
|
||||
A :: { a :: A, a :: !A } -> A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type)
|
||||
(where)
|
||||
(gadt_constructor
|
||||
(constructor)
|
||||
(record_fields
|
||||
(field (variable) (type_name (type)))
|
||||
(comma)
|
||||
(field (variable) (strict_type (type_name (type)))))
|
||||
(type_name (type)))))
|
||||
|
||||
================================================================================
|
||||
gadt: signature
|
||||
================================================================================
|
||||
|
||||
data A :: [*] -> * where
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type)
|
||||
(fun
|
||||
(type_list (type_star))
|
||||
(type_star))
|
||||
(where)))
|
||||
|
||||
================================================================================
|
||||
gadt: context
|
||||
================================================================================
|
||||
|
||||
data A a => A where
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(context (constraint (class_name (type)) (type_name (type_variable))))
|
||||
(type)
|
||||
(where)))
|
||||
|
||||
================================================================================
|
||||
gadt: con context
|
||||
================================================================================
|
||||
|
||||
data A where
|
||||
A :: A a => A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type)
|
||||
(where)
|
||||
(gadt_constructor
|
||||
(constructor)
|
||||
(context
|
||||
(constraint (class_name (type)) (type_name (type_variable)))
|
||||
)
|
||||
(type_name (type)))))
|
||||
|
||||
================================================================================
|
||||
gadt: forall
|
||||
================================================================================
|
||||
|
||||
data A where
|
||||
A :: ∀ a . A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type)
|
||||
(where)
|
||||
(gadt_constructor
|
||||
(constructor)
|
||||
(forall (quantifiers (type_variable)))
|
||||
(type_name (type)))))
|
||||
|
||||
================================================================================
|
||||
gadt: deriving
|
||||
================================================================================
|
||||
|
||||
data A where
|
||||
A :: A
|
||||
deriving A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type)
|
||||
(where)
|
||||
(gadt_constructor (constructor) (type_name (type)))
|
||||
(deriving (type))))
|
||||
|
||||
================================================================================
|
||||
gadt: symbolic operator
|
||||
================================================================================
|
||||
|
||||
data a +++ b where
|
||||
(:+++) :: a -> b -> a +++ b
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type_infix (type_variable) (type_operator) (type_variable))
|
||||
(where)
|
||||
(gadt_constructor
|
||||
(constructor_operator)
|
||||
(fun
|
||||
(type_name (type_variable))
|
||||
(fun
|
||||
(type_name (type_variable))
|
||||
(type_infix
|
||||
(type_name (type_variable))
|
||||
(type_operator)
|
||||
(type_name (type_variable))))))))
|
||||
|
||||
================================================================================
|
||||
gadt: newtype
|
||||
================================================================================
|
||||
|
||||
newtype A where
|
||||
A :: A
|
||||
|
||||
---
|
||||
|
||||
(haskell (newtype (type) (where) (gadt_constructor (constructor) (type_name (type)))))
|
||||
|
||||
================================================================================
|
||||
gadt: symbolic type
|
||||
================================================================================
|
||||
|
||||
data (:#) a where
|
||||
|
||||
---
|
||||
|
||||
(haskell (adt (constructor_operator) (type_variable) (where)))
|
||||
@ -1,46 +0,0 @@
|
||||
================================================================================
|
||||
id: variable
|
||||
================================================================================
|
||||
|
||||
a = a
|
||||
_a0 = a
|
||||
_A0 = a
|
||||
a0 = a
|
||||
a9 = a
|
||||
aA = a
|
||||
aZ' = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function (variable) (exp_name (variable)))
|
||||
(function (variable) (exp_name (variable)))
|
||||
(function (variable) (exp_name (variable)))
|
||||
(function (variable) (exp_name (variable)))
|
||||
(function (variable) (exp_name (variable)))
|
||||
(function (variable) (exp_name (variable)))
|
||||
(function (variable) (exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
id: constructor
|
||||
================================================================================
|
||||
|
||||
data B = A
|
||||
| A0
|
||||
| A9
|
||||
| Aa
|
||||
| A_
|
||||
| Az'
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(adt
|
||||
(type)
|
||||
(constructors
|
||||
(data_constructor (constructor))
|
||||
(data_constructor (constructor))
|
||||
(data_constructor (constructor))
|
||||
(data_constructor (constructor))
|
||||
(data_constructor (constructor))
|
||||
(data_constructor (constructor)))))
|
||||
@ -1,251 +0,0 @@
|
||||
================================================================================
|
||||
import: single-segment module plain
|
||||
================================================================================
|
||||
|
||||
module A where
|
||||
|
||||
import A
|
||||
|
||||
---
|
||||
|
||||
(haskell (module) (where) (import (module)))
|
||||
|
||||
================================================================================
|
||||
import: empty single-segment module
|
||||
================================================================================
|
||||
|
||||
import A ()
|
||||
|
||||
---
|
||||
|
||||
(haskell (import (module) (import_list)))
|
||||
|
||||
================================================================================
|
||||
import: single-segment module with alias
|
||||
================================================================================
|
||||
|
||||
import A as A
|
||||
|
||||
---
|
||||
|
||||
(haskell (import (module) (module)))
|
||||
|
||||
================================================================================
|
||||
import: multi-segment module
|
||||
================================================================================
|
||||
|
||||
import A.A
|
||||
|
||||
---
|
||||
|
||||
(haskell (import (qualified_module (module) (module))))
|
||||
|
||||
================================================================================
|
||||
import: var only
|
||||
================================================================================
|
||||
|
||||
import Aaa.A (aa)
|
||||
|
||||
---
|
||||
|
||||
(haskell (import (qualified_module (module) (module)) (import_list (import_item (variable)))))
|
||||
|
||||
================================================================================
|
||||
import: type only
|
||||
================================================================================
|
||||
|
||||
import Aaa.A (A)
|
||||
|
||||
---
|
||||
|
||||
(haskell (import (qualified_module (module) (module)) (import_list (import_item (type)))))
|
||||
|
||||
================================================================================
|
||||
import: type with constructor
|
||||
================================================================================
|
||||
|
||||
import Aaa.A (A(A))
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(import
|
||||
(qualified_module (module) (module))
|
||||
(import_list (import_item (type) (import_con_names (constructor))))))
|
||||
|
||||
================================================================================
|
||||
import: type with var
|
||||
================================================================================
|
||||
|
||||
import Aaa.A (A(aa))
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(import
|
||||
(qualified_module (module) (module))
|
||||
(import_list (import_item (type) (import_con_names (variable))))))
|
||||
|
||||
================================================================================
|
||||
import: type with symbolic var
|
||||
================================================================================
|
||||
|
||||
import Aaa.A (A((<>)))
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(import
|
||||
(qualified_module (module) (module))
|
||||
(import_list (import_item (type) (import_con_names (operator))))))
|
||||
|
||||
================================================================================
|
||||
import: type dotdot
|
||||
================================================================================
|
||||
|
||||
import Aaa.A (A(..))
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(import
|
||||
(qualified_module (module) (module))
|
||||
(import_list (import_item (type) (import_con_names (all_names))))))
|
||||
|
||||
================================================================================
|
||||
import: qualified basic
|
||||
================================================================================
|
||||
|
||||
import qualified Aaa.A
|
||||
import qualified A ()
|
||||
import qualified Aaa.A (a)
|
||||
import Aaa.A qualified (a)
|
||||
import qualified Aaa.A hiding (A, a)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(import (qualified_module (module) (module)))
|
||||
(import (module) (import_list))
|
||||
(import (qualified_module (module) (module)) (import_list (import_item (variable))))
|
||||
(import (qualified_module (module) (module)) (import_list (import_item (variable))))
|
||||
(import
|
||||
(qualified_module (module) (module))
|
||||
(import_list (import_item (type)) (comma) (import_item (variable)))))
|
||||
|
||||
================================================================================
|
||||
import: qualified as
|
||||
================================================================================
|
||||
|
||||
module A where
|
||||
|
||||
import qualified Aaa.A as A
|
||||
import qualified Aaa.A as A (A(A, a), aa)
|
||||
import qualified A as A ()
|
||||
import qualified Aaa.A as A
|
||||
import qualified Aaa.A as Aaa.A
|
||||
import qualified Aaa.A as A hiding (a)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(module)
|
||||
(where)
|
||||
(import (qualified_module (module) (module)) (module))
|
||||
(import
|
||||
(qualified_module (module) (module))
|
||||
(module)
|
||||
(import_list
|
||||
(import_item (type) (import_con_names (constructor) (comma) (variable)))
|
||||
(comma)
|
||||
(import_item (variable))))
|
||||
(import (module) (module) (import_list))
|
||||
(import (qualified_module (module) (module)) (module))
|
||||
(import (qualified_module (module) (module)) (qualified_module (module) (module)))
|
||||
(import (qualified_module (module) (module)) (module) (import_list (import_item (variable)))))
|
||||
|
||||
================================================================================
|
||||
import: prim
|
||||
================================================================================
|
||||
|
||||
import Aaa.Aa (Aa#, aa#)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(import
|
||||
(qualified_module (module) (module))
|
||||
(import_list (import_item (type)) (comma) (import_item (variable)))))
|
||||
|
||||
================================================================================
|
||||
import: package
|
||||
================================================================================
|
||||
|
||||
import "a" Aaa.Aa
|
||||
import qualified "a" Aaa.Aa as Aa (Aa(a))
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(import (import_package) (qualified_module (module) (module)))
|
||||
(import
|
||||
(import_package)
|
||||
(qualified_module (module) (module))
|
||||
(module)
|
||||
(import_list (import_item (type) (import_con_names (variable))))))
|
||||
|
||||
================================================================================
|
||||
import: consym
|
||||
================================================================================
|
||||
|
||||
import A ((:<|>)((:<|>)))
|
||||
|
||||
---
|
||||
|
||||
(haskell (import (module) (import_list (import_item (constructor_operator) (import_con_names (constructor_operator))))))
|
||||
|
||||
================================================================================
|
||||
import: operator
|
||||
================================================================================
|
||||
|
||||
import A ((<=<))
|
||||
|
||||
---
|
||||
|
||||
(haskell (import (module) (import_list (import_item (type_operator)))))
|
||||
|
||||
================================================================================
|
||||
import: pattern/type
|
||||
================================================================================
|
||||
|
||||
import A (pattern A, type A)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(import
|
||||
(module)
|
||||
(import_list
|
||||
(import_item (namespace) (type))
|
||||
(comma)
|
||||
(import_item (namespace) (type)))))
|
||||
|
||||
================================================================================
|
||||
import: trailing comma
|
||||
================================================================================
|
||||
|
||||
import A (A,)
|
||||
|
||||
---
|
||||
|
||||
(haskell (import (module) (import_list (import_item (type)) (comma))))
|
||||
|
||||
================================================================================
|
||||
import: type operator with namespace
|
||||
================================================================================
|
||||
|
||||
import A (type (++)(..))
|
||||
|
||||
---
|
||||
|
||||
(haskell (import (module) (import_list (import_item (namespace) (type_operator) (import_con_names (all_names))))))
|
||||
@ -1,256 +0,0 @@
|
||||
================================================================================
|
||||
instance: minimal
|
||||
================================================================================
|
||||
|
||||
instance A a
|
||||
|
||||
---
|
||||
|
||||
(haskell (instance (instance_head (class_name (type)) (type_name (type_variable)))))
|
||||
|
||||
================================================================================
|
||||
instance: type
|
||||
================================================================================
|
||||
|
||||
instance A A a A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(instance
|
||||
(instance_head
|
||||
(class_name (type))
|
||||
(type_name (type))
|
||||
(type_name (type_variable))
|
||||
(type_name (type)))))
|
||||
|
||||
================================================================================
|
||||
instance: forall
|
||||
================================================================================
|
||||
|
||||
instance forall a (a :: *) . A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(instance
|
||||
(forall
|
||||
(quantifiers
|
||||
(type_variable)
|
||||
(annotated_type_variable (type_variable) (type_star)))
|
||||
)
|
||||
(instance_head (class_name (type)))))
|
||||
|
||||
================================================================================
|
||||
instance: context
|
||||
================================================================================
|
||||
|
||||
instance A a => A
|
||||
instance (A a, A a) => A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(instance
|
||||
(context (constraint (class_name (type)) (type_name (type_variable))))
|
||||
(instance_head (class_name (type))))
|
||||
(instance
|
||||
(context
|
||||
(constraint (class_name (type)) (type_name (type_variable)))
|
||||
(comma)
|
||||
(constraint (class_name (type)) (type_name (type_variable)))
|
||||
)
|
||||
(instance_head (class_name (type)))))
|
||||
|
||||
================================================================================
|
||||
instance: method
|
||||
================================================================================
|
||||
|
||||
instance A a where a a = Just a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(instance
|
||||
(instance_head (class_name (type)) (type_name (type_variable)))
|
||||
(where)
|
||||
(function
|
||||
(variable)
|
||||
(patterns (pat_name (variable)))
|
||||
(exp_apply (exp_name (constructor)) (exp_name (variable))))))
|
||||
|
||||
================================================================================
|
||||
instance: signature
|
||||
================================================================================
|
||||
|
||||
instance A a where
|
||||
a :: A a => a -> a
|
||||
a a = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(instance
|
||||
(instance_head (class_name (type)) (type_name (type_variable)))
|
||||
(where)
|
||||
(signature
|
||||
(variable)
|
||||
(context
|
||||
(constraint (class_name (type)) (type_name (type_variable)))
|
||||
(fun (type_name (type_variable)) (type_name (type_variable)))))
|
||||
(function
|
||||
(variable)
|
||||
(patterns (pat_name (variable)))
|
||||
(exp_name (variable)))))
|
||||
|
||||
================================================================================
|
||||
instance: equality constraint
|
||||
================================================================================
|
||||
|
||||
instance A a ~ A a => A a
|
||||
instance A ~~ A => A a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(instance
|
||||
(context
|
||||
(constraint
|
||||
(type_infix
|
||||
left: (type_apply (type_name (type)) (type_name (type_variable)))
|
||||
op: (type_operator)
|
||||
right: (type_apply (type_name (type)) (type_name (type_variable)))))
|
||||
)
|
||||
(instance_head class: (class_name (type)) (type_name (type_variable))))
|
||||
(instance
|
||||
(context
|
||||
(constraint
|
||||
(type_infix
|
||||
left: (type_name (type))
|
||||
op: (type_operator)
|
||||
right: (type_name (type))))
|
||||
)
|
||||
(instance_head class: (class_name (type)) (type_name (type_variable)))))
|
||||
|
||||
================================================================================
|
||||
instance: associated type instance
|
||||
================================================================================
|
||||
|
||||
instance A where
|
||||
type A A a = A a
|
||||
type instance A a = A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(instance
|
||||
(instance_head
|
||||
(class_name (type)))
|
||||
(where)
|
||||
(inst_tyinst
|
||||
(type_name (type))
|
||||
(type_name (type))
|
||||
(type_name (type_variable))
|
||||
(type_apply (type_name (type)) (type_name (type_variable))))
|
||||
(inst_tyinst
|
||||
(type_name (type))
|
||||
(type_name (type_variable))
|
||||
(type_name (type)))))
|
||||
|
||||
================================================================================
|
||||
instance: associated data instance
|
||||
================================================================================
|
||||
|
||||
instance A where
|
||||
data A a = A a | A { a :: A }
|
||||
data instance ∀ a . A a => A a = A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(instance
|
||||
(instance_head (class_name (type)))
|
||||
(where)
|
||||
(inst_datainst
|
||||
(type_apply
|
||||
(type_name (type))
|
||||
(type_name (type_variable)))
|
||||
(constructors
|
||||
(data_constructor (constructor) (type_name (type_variable)))
|
||||
(data_constructor_record
|
||||
(constructor)
|
||||
(record_fields (field (variable) (type_name (type)))))))
|
||||
(inst_datainst
|
||||
(forall (quantifiers (type_variable)))
|
||||
(context (constraint (class_name (type)) (type_name (type_variable))))
|
||||
(type_apply
|
||||
(type_name (type))
|
||||
(type_name (type_variable)))
|
||||
(constructors (data_constructor (constructor))))))
|
||||
|
||||
================================================================================
|
||||
instance: infix pattern lhs method
|
||||
================================================================================
|
||||
|
||||
instance A where
|
||||
a == a = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(instance
|
||||
(instance_head (class_name (type)))
|
||||
(where)
|
||||
(function
|
||||
(infix (pat_name (variable)) (varop (operator)) (pat_name (variable)))
|
||||
(exp_name (variable)))))
|
||||
|
||||
================================================================================
|
||||
instance: standalone deriving
|
||||
================================================================================
|
||||
|
||||
deriving instance A (A a)
|
||||
deriving instance A ++ A
|
||||
deriving instance A a => A (A a)
|
||||
deriving instance (A a, A a a) => A (A a)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(deriving_declaration (instance_head
|
||||
(class_name (type))
|
||||
(type_parens (type_apply (type_name (type)) (type_name (type_variable))))))
|
||||
(deriving_declaration
|
||||
(instance_head
|
||||
(type_infix
|
||||
(type_name (type))
|
||||
(type_operator)
|
||||
(type_name (type)))))
|
||||
(deriving_declaration
|
||||
(context (constraint (class_name (type)) (type_name (type_variable))))
|
||||
(instance_head
|
||||
(class_name (type))
|
||||
(type_parens (type_apply (type_name (type)) (type_name (type_variable))))))
|
||||
(deriving_declaration
|
||||
(context
|
||||
(constraint (class_name (type)) (type_name (type_variable)))
|
||||
(comma)
|
||||
(constraint (class_name (type)) (type_name (type_variable)) (type_name (type_variable)))
|
||||
)
|
||||
(instance_head
|
||||
(class_name (type))
|
||||
(type_parens (type_apply (type_name (type)) (type_name (type_variable)))))))
|
||||
|
||||
|
||||
================================================================================
|
||||
instance: deriving via
|
||||
================================================================================
|
||||
|
||||
deriving via (A a) instance A a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(deriving_declaration
|
||||
(via (type_parens (type_apply (type_name (type)) (type_name (type_variable)))))
|
||||
(instance_head (class_name (type)) (type_name (type_variable)))))
|
||||
@ -1,770 +0,0 @@
|
||||
================================================================================
|
||||
layout: where on same level as case alt with nothing following
|
||||
================================================================================
|
||||
|
||||
a =
|
||||
case b of
|
||||
c -> d
|
||||
where e = f
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_case (exp_name (variable)) (alts (alt (pat_name (variable)) (exp_name (variable)))))
|
||||
(where)
|
||||
(decls (function (variable) (exp_name (variable))))))
|
||||
|
||||
================================================================================
|
||||
layout: error: where on same level as case alt with following alt
|
||||
================================================================================
|
||||
|
||||
a = case a of
|
||||
a -> a
|
||||
where
|
||||
a = a
|
||||
a -> a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_case (exp_name (variable)) (alts (alt (pat_name (variable)) (exp_name (variable)))))
|
||||
(where)
|
||||
(decls (function (variable) (exp_name (variable)))))
|
||||
(ERROR))
|
||||
|
||||
================================================================================
|
||||
layout: where on deeper level as case alt with following alt
|
||||
================================================================================
|
||||
|
||||
a = case b of
|
||||
c -> d
|
||||
where
|
||||
e = f
|
||||
g -> h
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_case
|
||||
(exp_name (variable))
|
||||
(alts
|
||||
(alt (pat_name (variable)) (exp_name (variable))
|
||||
(where) (decls (function (variable) (exp_name (variable)))))
|
||||
(alt (pat_name (variable)) (exp_name (variable)))))))
|
||||
|
||||
================================================================================
|
||||
layout: where with subsequent top decl
|
||||
================================================================================
|
||||
|
||||
a =
|
||||
a
|
||||
where a = a
|
||||
a = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_name (variable))
|
||||
(where)
|
||||
(decls (function (variable) (exp_name (variable)))))
|
||||
(function (variable) (exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
layout: indented empty where with subsequent top decl
|
||||
================================================================================
|
||||
|
||||
a =
|
||||
a
|
||||
where
|
||||
a = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_name (variable))
|
||||
(where))
|
||||
(function (variable) (exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
layout: where after case alt in do, then immediate top level where indented further right
|
||||
================================================================================
|
||||
|
||||
x = do a <- b
|
||||
case c of
|
||||
_ -> d
|
||||
where e = f
|
||||
where g = h
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_do
|
||||
(stmt
|
||||
(bind_pattern
|
||||
(pat_name (variable))
|
||||
(exp_name (variable))))
|
||||
(stmt
|
||||
(exp_case
|
||||
(exp_name (variable))
|
||||
(alts
|
||||
(alt
|
||||
(pat_wildcard)
|
||||
(exp_name (variable))
|
||||
(where)
|
||||
(decls (function (variable) (exp_name (variable)))))))))
|
||||
(where)
|
||||
(decls (function (variable) (exp_name (variable))))))
|
||||
|
||||
================================================================================
|
||||
layout: where after case alt in do, then immediate toplevel where at minimum indent
|
||||
================================================================================
|
||||
|
||||
a = do
|
||||
case a of
|
||||
a -> a
|
||||
where a = a
|
||||
where a = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_do
|
||||
(stmt
|
||||
(exp_case
|
||||
(exp_name (variable))
|
||||
(alts
|
||||
(alt
|
||||
(pat_name (variable))
|
||||
(exp_name (variable))
|
||||
(where)
|
||||
(decls (function (variable) (exp_name (variable)))))))))
|
||||
(where)
|
||||
(decls (function (variable) (exp_name (variable))))))
|
||||
|
||||
================================================================================
|
||||
layout: where after case alt inline, then immediate toplevel where at minimum indent
|
||||
================================================================================
|
||||
|
||||
f = case a of
|
||||
a -> a where a = a
|
||||
where a = a
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_case
|
||||
(exp_name (variable))
|
||||
(alts
|
||||
(alt (pat_name (variable)) (exp_name (variable))
|
||||
(where)
|
||||
(decls (function (variable) (exp_name (variable)))))))
|
||||
(where)
|
||||
(decls (function (variable) (exp_name (variable))))))
|
||||
|
||||
================================================================================
|
||||
layout: do nested
|
||||
================================================================================
|
||||
|
||||
x = do a
|
||||
b
|
||||
do
|
||||
c
|
||||
d
|
||||
do e
|
||||
f
|
||||
g
|
||||
h
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_do
|
||||
(stmt (exp_name (variable)))
|
||||
(stmt (exp_name (variable)))
|
||||
(stmt
|
||||
(exp_do
|
||||
(stmt (exp_name (variable)))
|
||||
(stmt (exp_name (variable)))
|
||||
(stmt
|
||||
(exp_do
|
||||
(stmt (exp_name (variable)))
|
||||
(stmt (exp_name (variable)))))
|
||||
(stmt (exp_name (variable)))))
|
||||
(stmt (exp_name (variable))))))
|
||||
|
||||
================================================================================
|
||||
layout: do and indented where
|
||||
================================================================================
|
||||
|
||||
a = do
|
||||
b
|
||||
where c = d
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_do (stmt (exp_name (variable))))
|
||||
(where)
|
||||
(decls (function (variable) (exp_name (variable))))))
|
||||
|
||||
================================================================================
|
||||
layout: do and empty line
|
||||
================================================================================
|
||||
|
||||
a = do
|
||||
a <- a
|
||||
|
||||
a <- a
|
||||
a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_do
|
||||
(stmt (bind_pattern (pat_name (variable)) (exp_name (variable))))
|
||||
(stmt (bind_pattern (pat_name (variable)) (exp_name (variable))))
|
||||
(stmt (exp_name (variable))))))
|
||||
|
||||
================================================================================
|
||||
layout: recursive do with rec keyword
|
||||
================================================================================
|
||||
|
||||
f = mdo
|
||||
a <- pure 5
|
||||
rec
|
||||
b <- pure c
|
||||
c <- pure b
|
||||
pure c
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_do
|
||||
(stmt (bind_pattern (pat_name (variable)) (exp_apply (exp_name (variable)) (exp_literal (integer)))))
|
||||
(stmt
|
||||
(rec
|
||||
(stmt (bind_pattern (pat_name (variable)) (exp_apply (exp_name (variable)) (exp_name (variable)))))
|
||||
(stmt (bind_pattern (pat_name (variable)) (exp_apply (exp_name (variable)) (exp_name (variable)))))))
|
||||
(stmt (exp_apply (exp_name (variable)) (exp_name (variable)))))))
|
||||
|
||||
================================================================================
|
||||
layout: in after let on same indent
|
||||
================================================================================
|
||||
|
||||
a = let a = a
|
||||
in a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_let_in
|
||||
(exp_let
|
||||
(decls
|
||||
(function (variable) (exp_name (variable)))))
|
||||
(exp_in (exp_name (variable))))))
|
||||
|
||||
================================================================================
|
||||
layout: identifier named "whe" in place of valid "where"
|
||||
================================================================================
|
||||
|
||||
a =
|
||||
case b of
|
||||
whe -> d
|
||||
where
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_case
|
||||
(exp_name (variable))
|
||||
(alts (alt (pat_name (variable)) (exp_name (variable)))))
|
||||
(where)))
|
||||
|
||||
================================================================================
|
||||
layout: identifier "i" should not prematurely fail the scanner due to "in" parser
|
||||
================================================================================
|
||||
|
||||
a (i:a) = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(patterns
|
||||
(pat_parens
|
||||
(pat_infix
|
||||
(pat_name (variable))
|
||||
(constructor_operator)
|
||||
(pat_name (variable)))))
|
||||
(exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
layout: empty file
|
||||
================================================================================
|
||||
|
||||
|
||||
---
|
||||
|
||||
(haskell (empty_file))
|
||||
|
||||
================================================================================
|
||||
layout: indented let/in
|
||||
================================================================================
|
||||
|
||||
a = let
|
||||
a = let
|
||||
a = a
|
||||
in a
|
||||
in do
|
||||
a <- a
|
||||
a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_let_in
|
||||
(exp_let
|
||||
(decls
|
||||
(function
|
||||
(variable)
|
||||
(exp_let_in
|
||||
(exp_let
|
||||
(decls (function (variable) (exp_name (variable)))))
|
||||
(exp_in (exp_name (variable)))))))
|
||||
(exp_in (exp_do (stmt (bind_pattern (pat_name (variable)) (exp_name (variable)))) (stmt (exp_name (variable))))))))
|
||||
|
||||
================================================================================
|
||||
layout: where after stmt, on deeper or same indent
|
||||
================================================================================
|
||||
|
||||
a = do
|
||||
b
|
||||
where d = e
|
||||
|
||||
a = do
|
||||
b
|
||||
where d = e
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_do (stmt (exp_name (variable))))
|
||||
(where)
|
||||
(decls (function (variable) (exp_name (variable)))))
|
||||
(function
|
||||
(variable)
|
||||
(exp_do (stmt (exp_name (variable))))
|
||||
(where)
|
||||
(decls (function (variable) (exp_name (variable))))))
|
||||
|
||||
================================================================================
|
||||
layout: empty where, then indented decls after inline where
|
||||
================================================================================
|
||||
|
||||
c = d where
|
||||
e = f where
|
||||
g = h
|
||||
i = j
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_name (variable)) (where))
|
||||
(function
|
||||
(variable)
|
||||
(exp_name (variable))
|
||||
(where)
|
||||
(decls (function (variable) (exp_name (variable)))))
|
||||
(function
|
||||
(variable)
|
||||
(exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
layout: parenthesized case inline
|
||||
================================================================================
|
||||
|
||||
a =
|
||||
(\case a -> b) . c
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_infix
|
||||
(exp_parens (exp_lambda_case (alts (alt (pat_name (variable)) (exp_name (variable))))))
|
||||
(operator)
|
||||
(exp_name (variable)))))
|
||||
|
||||
================================================================================
|
||||
layout: parenthesized case newline
|
||||
================================================================================
|
||||
|
||||
a =
|
||||
(\case a -> b
|
||||
) . c
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_infix
|
||||
(exp_parens (exp_lambda_case (alts (alt (pat_name (variable)) (exp_name (variable))))))
|
||||
(operator)
|
||||
(exp_name (variable)))))
|
||||
|
||||
================================================================================
|
||||
layout: comment between where and decl
|
||||
================================================================================
|
||||
|
||||
a = b where
|
||||
{- comment -} c = d
|
||||
|
||||
a = b where
|
||||
-- comment
|
||||
c = d
|
||||
|
||||
a = b where -- comment
|
||||
c = d
|
||||
|
||||
a = b where {- comment -}
|
||||
c = d
|
||||
|
||||
a = b where -1 = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_name (variable))
|
||||
(where)
|
||||
(comment)
|
||||
(decls (function (variable) (exp_name (variable)))))
|
||||
(function
|
||||
(variable)
|
||||
(exp_name (variable))
|
||||
(where)
|
||||
(comment)
|
||||
(decls (function (variable) (exp_name (variable)))))
|
||||
(function
|
||||
(variable)
|
||||
(exp_name (variable))
|
||||
(where)
|
||||
(comment)
|
||||
(decls (function (variable) (exp_name (variable)))))
|
||||
(function
|
||||
(variable)
|
||||
(exp_name (variable))
|
||||
(where)
|
||||
(comment)
|
||||
(decls (function (variable) (exp_name (variable)))))
|
||||
(function
|
||||
(variable)
|
||||
(exp_name (variable))
|
||||
(where)
|
||||
(decls (function (pat_negation (pat_literal (integer))) (exp_name (variable))))))
|
||||
|
||||
================================================================================
|
||||
layout: comment in empty where on next line indented
|
||||
================================================================================
|
||||
|
||||
a = b where
|
||||
{-# pragma #-}
|
||||
a = a where
|
||||
{- comment
|
||||
-}
|
||||
|
||||
a = a where
|
||||
--
|
||||
a = b
|
||||
where
|
||||
{- comment -}
|
||||
c = d
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function (variable) (exp_name (variable)) (where))
|
||||
(pragma)
|
||||
(function (variable) (exp_name (variable)) (where))
|
||||
(comment)
|
||||
(function (variable) (exp_name (variable)) (where))
|
||||
(comment)
|
||||
(function (variable) (exp_name (variable)) (where))
|
||||
(comment)
|
||||
(function (variable) (exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
layout: normal module
|
||||
================================================================================
|
||||
|
||||
module A where
|
||||
a = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(module)
|
||||
(where)
|
||||
(function (variable) (exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
layout: indented module keyword, decls further left
|
||||
================================================================================
|
||||
|
||||
module A where
|
||||
a = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(module)
|
||||
(where)
|
||||
(function (variable) (exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
layout: end two layouts at the same position
|
||||
================================================================================
|
||||
|
||||
a = case a of
|
||||
a -> do a
|
||||
a :: a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_case (exp_name (variable)) (alts (alt (pat_name (variable)) (exp_do (stmt (exp_name (variable))))))))
|
||||
(signature (variable) (type_name (type_variable))))
|
||||
|
||||
================================================================================
|
||||
layout: case in a list terminated by bracket
|
||||
================================================================================
|
||||
|
||||
a = [case a of a -> a]
|
||||
a = [case a of a -> a
|
||||
]
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_list (exp_case (exp_name (variable)) (alts (alt (pat_name (variable)) (exp_name (variable)))))))
|
||||
(function
|
||||
(variable)
|
||||
(exp_list (exp_case (exp_name (variable)) (alts (alt (pat_name (variable)) (exp_name (variable))))))))
|
||||
|
||||
================================================================================
|
||||
layout: case in a list terminated by comma
|
||||
================================================================================
|
||||
|
||||
a = [case a of a -> a, a]
|
||||
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_list
|
||||
(exp_case (exp_name (variable)) (alts (alt (pat_name (variable)) (exp_name (variable)))))
|
||||
(comma)
|
||||
(exp_name (variable)))))
|
||||
|
||||
================================================================================
|
||||
layout: case in a list terminated by comprehension bar
|
||||
================================================================================
|
||||
|
||||
a = [case a of a -> a | a <- a]
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_list_comprehension
|
||||
(exp_case (exp_name (variable)) (alts (alt (pat_name (variable)) (exp_name (variable)))))
|
||||
(qual (bind_pattern (pat_name (variable)) (exp_name (variable)))))))
|
||||
|
||||
================================================================================
|
||||
layout: do in an if-then block
|
||||
================================================================================
|
||||
|
||||
a = if a then do a; a else a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_cond
|
||||
(exp_name (variable))
|
||||
(exp_do (stmt (exp_name (variable))) (stmt (exp_name (variable))))
|
||||
(exp_name (variable)))))
|
||||
|
||||
================================================================================
|
||||
layout: nondecreasing indent for do in if-then
|
||||
================================================================================
|
||||
|
||||
a = do
|
||||
a <- a
|
||||
if a then do
|
||||
a <- a
|
||||
pure a
|
||||
else a
|
||||
a <- a
|
||||
pure a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_do
|
||||
(stmt (bind_pattern (pat_name (variable)) (exp_name (variable))))
|
||||
(stmt
|
||||
(exp_cond
|
||||
(exp_name (variable))
|
||||
(exp_do
|
||||
(stmt (bind_pattern (pat_name (variable)) (exp_name (variable))))
|
||||
(stmt (exp_apply (exp_name (variable)) (exp_name (variable)))))
|
||||
(exp_name (variable))))
|
||||
(stmt (bind_pattern (pat_name (variable)) (exp_name (variable))))
|
||||
(stmt (exp_apply (exp_name (variable)) (exp_name (variable)))))))
|
||||
|
||||
================================================================================
|
||||
layout: infix in statement position ends layout
|
||||
================================================================================
|
||||
|
||||
a = do
|
||||
a
|
||||
>>= a
|
||||
|
||||
a = do
|
||||
a
|
||||
`a` a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_infix (exp_do (stmt (exp_name (variable)))) (operator) (exp_name (variable))))
|
||||
(function
|
||||
(variable)
|
||||
(exp_infix (exp_do (stmt (exp_name (variable)))) (variable) (exp_name (variable)))))
|
||||
|
||||
================================================================================
|
||||
layout: two lines starting with m without leading newline or module
|
||||
================================================================================
|
||||
m1 :: a -> a
|
||||
m1 = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(signature (variable) (fun (type_name (type_variable)) (type_name (type_variable))))
|
||||
(function (variable) (exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
layout: do not end do layout with strictness annotation
|
||||
================================================================================
|
||||
|
||||
a = do
|
||||
a <- a
|
||||
!a <- a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_do
|
||||
(stmt (bind_pattern (pat_name (variable)) (exp_name (variable))))
|
||||
(stmt (bind_pattern (pat_strict (pat_name (variable))) (exp_name (variable)))))))
|
||||
|
||||
================================================================================
|
||||
layout: let/in after do
|
||||
================================================================================
|
||||
|
||||
a = do
|
||||
let g = a
|
||||
in a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_do
|
||||
(stmt
|
||||
(exp_let_in
|
||||
(exp_let (decls (function (variable) (exp_name (variable)))))
|
||||
(exp_in (exp_name (variable))))))))
|
||||
|
||||
================================================================================
|
||||
layout: instance after where, triggers rule for "in" token
|
||||
================================================================================
|
||||
|
||||
class A where
|
||||
|
||||
instance A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(class (class_head (class_name (type))) (class_body (where)))
|
||||
(instance (instance_head (class_name (type)))))
|
||||
|
||||
================================================================================
|
||||
layout: carriage return
|
||||
================================================================================
|
||||
|
||||
a = a
|
||||
a = a
|
||||
|
||||
---
|
||||
|
||||
(haskell (function (variable) (exp_name (variable))) (function (variable) (exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
layout: test
|
||||
================================================================================
|
||||
@ -1,188 +0,0 @@
|
||||
================================================================================
|
||||
module: starting on first line
|
||||
================================================================================
|
||||
module A where
|
||||
|
||||
---
|
||||
|
||||
(haskell module: (module) (where))
|
||||
|
||||
================================================================================
|
||||
module: starting on second line
|
||||
================================================================================
|
||||
|
||||
module A where
|
||||
|
||||
---
|
||||
|
||||
(haskell (module) (where))
|
||||
|
||||
================================================================================
|
||||
module: exports empty
|
||||
================================================================================
|
||||
|
||||
module A () where
|
||||
|
||||
---
|
||||
|
||||
(haskell (module) (exports) (where))
|
||||
|
||||
================================================================================
|
||||
module: exports regular
|
||||
================================================================================
|
||||
|
||||
module A (
|
||||
a',
|
||||
A,
|
||||
A(..),
|
||||
A(a, a),
|
||||
) where
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(module)
|
||||
(exports
|
||||
(export (variable))
|
||||
(comma)
|
||||
(export (type))
|
||||
(comma)
|
||||
(export (type) (export_names (all_names)))
|
||||
(comma)
|
||||
(export (type) (export_names (variable) (comma) (variable))) (comma))
|
||||
(where))
|
||||
|
||||
================================================================================
|
||||
module: exports symbolic
|
||||
================================================================================
|
||||
|
||||
module A (
|
||||
(<>)((:<>), A),
|
||||
) where
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(module)
|
||||
(exports (export (type_operator) (export_names (constructor_operator) (comma) (constructor))) (comma))
|
||||
(where))
|
||||
|
||||
================================================================================
|
||||
module: exports type
|
||||
================================================================================
|
||||
|
||||
module A (
|
||||
type A,
|
||||
type (<>),
|
||||
) where
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(module)
|
||||
(exports
|
||||
(export (namespace) (type))
|
||||
(comma)
|
||||
(export (namespace) (type_operator))
|
||||
(comma))
|
||||
(where))
|
||||
|
||||
================================================================================
|
||||
module: exports pattern
|
||||
================================================================================
|
||||
|
||||
module A (
|
||||
pattern A,
|
||||
pattern (<>),
|
||||
) where
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(module)
|
||||
(exports
|
||||
(export (namespace) (type))
|
||||
(comma)
|
||||
(export (namespace) (type_operator))
|
||||
(comma))
|
||||
(where))
|
||||
|
||||
================================================================================
|
||||
module: exports module
|
||||
================================================================================
|
||||
|
||||
module A (
|
||||
a,
|
||||
module A,
|
||||
module A.A.A,
|
||||
) where
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(module)
|
||||
(exports
|
||||
(export (variable))
|
||||
(comma)
|
||||
(export (module))
|
||||
(comma)
|
||||
(export (qualified_module (module) (module) (module)))
|
||||
(comma))
|
||||
(where))
|
||||
|
||||
================================================================================
|
||||
module: exports qualified
|
||||
================================================================================
|
||||
|
||||
module A (
|
||||
A.A.a,
|
||||
type (A.A.++),
|
||||
type (A.A.:++),
|
||||
A.A.A,
|
||||
A.A.A((<=<), (:++), A, a),
|
||||
type A.A((>>), A),
|
||||
pattern A.A((>>), A),
|
||||
) where
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(module)
|
||||
(exports
|
||||
(export (qualified_variable (module) (module) (variable)))
|
||||
(comma)
|
||||
(export (namespace) (qualified_type_operator (module) (module) (type_operator)))
|
||||
(comma)
|
||||
(export (namespace) (qualified_constructor_operator (module) (module) (constructor_operator)))
|
||||
(comma)
|
||||
(export (qualified_type (module) (module) (type)))
|
||||
(comma)
|
||||
(export
|
||||
(qualified_type (module) (module) (type))
|
||||
(export_names (operator) (comma) (constructor_operator) (comma) (constructor) (comma) (variable)))
|
||||
(comma)
|
||||
(export (namespace) (qualified_type (module) (type)) (export_names (operator) (comma) (constructor)))
|
||||
(comma)
|
||||
(export (namespace) (qualified_type (module) (type)) (export_names (operator) (comma) (constructor)))
|
||||
(comma))
|
||||
(where))
|
||||
|
||||
================================================================================
|
||||
module: qualified
|
||||
================================================================================
|
||||
|
||||
module A.A'.A where
|
||||
|
||||
---
|
||||
|
||||
(haskell (qualified_module (module) (module) (module)) (where))
|
||||
|
||||
================================================================================
|
||||
module: export minus
|
||||
================================================================================
|
||||
|
||||
module A (type(-), (-)) where
|
||||
|
||||
---
|
||||
|
||||
(haskell (module) (exports (export (namespace) (type_operator)) (comma) (export (type_operator))) (where))
|
||||
@ -1,109 +0,0 @@
|
||||
================================================================================
|
||||
newtype: basic
|
||||
================================================================================
|
||||
|
||||
newtype A = A A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(newtype
|
||||
(type)
|
||||
(newtype_constructor (constructor) (type_name (type)))))
|
||||
|
||||
================================================================================
|
||||
newtype: context
|
||||
================================================================================
|
||||
|
||||
newtype A a => A a = A a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(newtype
|
||||
(context (constraint (class_name (type)) (type_name (type_variable))))
|
||||
(type)
|
||||
(type_variable)
|
||||
(newtype_constructor (constructor) (type_name (type_variable)))))
|
||||
|
||||
================================================================================
|
||||
newtype: record
|
||||
================================================================================
|
||||
|
||||
newtype A = A { a :: A a }
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(newtype
|
||||
(type)
|
||||
(newtype_constructor
|
||||
(constructor)
|
||||
(field (variable) (type_apply (type_name (type)) (type_name (type_variable)))))))
|
||||
|
||||
================================================================================
|
||||
newtype: type_variable kind
|
||||
================================================================================
|
||||
|
||||
newtype A a (a :: [* -> *]) a =
|
||||
A a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(newtype
|
||||
(type)
|
||||
(type_variable)
|
||||
(annotated_type_variable
|
||||
(type_variable)
|
||||
(type_list (fun (type_star) (type_star))))
|
||||
(type_variable)
|
||||
(newtype_constructor (constructor) (type_name (type_variable)))))
|
||||
|
||||
================================================================================
|
||||
newtype: deriving
|
||||
================================================================================
|
||||
|
||||
newtype A = A a deriving A
|
||||
newtype A a =
|
||||
A { a :: A }
|
||||
deriving (A, A)
|
||||
deriving newtype A
|
||||
deriving A via (A a)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(newtype
|
||||
(type)
|
||||
(newtype_constructor (constructor) (type_name (type_variable)))
|
||||
(deriving (type)))
|
||||
(newtype
|
||||
(type)
|
||||
(type_variable)
|
||||
(newtype_constructor (constructor) (field (variable) (type_name (type))))
|
||||
(deriving (constraint (class_name (type))) (comma) (constraint (class_name (type))))
|
||||
(deriving (deriving_strategy) (type))
|
||||
(deriving
|
||||
(type)
|
||||
(via (type_parens (type_apply (type_name (type)) (type_name (type_variable))))))))
|
||||
|
||||
================================================================================
|
||||
newtype: unlifted
|
||||
================================================================================
|
||||
|
||||
newtype A :: TYPE 'A where
|
||||
A :: A# -> A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(newtype
|
||||
(type)
|
||||
(type_apply
|
||||
(type_name (type))
|
||||
(type_name (promoted (type))))
|
||||
(where)
|
||||
(gadt_constructor
|
||||
(constructor)
|
||||
(fun (type_name (type)) (type_name (type))))))
|
||||
@ -1,100 +0,0 @@
|
||||
================================================================================
|
||||
number: decimal
|
||||
================================================================================
|
||||
|
||||
a = 0
|
||||
a = 100_00_532
|
||||
a = 55#
|
||||
a = 55##
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_literal (integer)))
|
||||
(function
|
||||
(variable)
|
||||
(exp_literal (integer)))
|
||||
(function
|
||||
(variable)
|
||||
(exp_literal (integer)))
|
||||
(function
|
||||
(variable)
|
||||
(exp_literal (integer))))
|
||||
|
||||
================================================================================
|
||||
number: octal
|
||||
================================================================================
|
||||
|
||||
a = 0o00
|
||||
a = 0O77
|
||||
a = 0O77##
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function (variable) (exp_literal (integer)))
|
||||
(function (variable) (exp_literal (integer)))
|
||||
(function (variable) (exp_literal (integer))))
|
||||
|
||||
================================================================================
|
||||
number: hex
|
||||
================================================================================
|
||||
|
||||
a = 0xA8
|
||||
a = 0XEF84Fe23
|
||||
a = 0xa_e_123_4
|
||||
a = 0xa_e_123_4##
|
||||
a = 0x0.1p-4
|
||||
a = 0xFp3
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function (variable) (exp_literal (integer)))
|
||||
(function (variable) (exp_literal (integer)))
|
||||
(function (variable) (exp_literal (integer)))
|
||||
(function (variable) (exp_literal (integer)))
|
||||
(function (variable) (exp_literal (integer)))
|
||||
(function (variable) (exp_literal (integer))))
|
||||
|
||||
================================================================================
|
||||
number: float
|
||||
================================================================================
|
||||
|
||||
a = 0.32847283472
|
||||
a = 0.00e01
|
||||
a = 0.00e01#
|
||||
a = 0.00e+01
|
||||
a = 0.99E-01
|
||||
a = 00e01
|
||||
a = 00e+01
|
||||
a = 99E-01
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function (variable) (exp_literal (float)))
|
||||
(function (variable) (exp_literal (float)))
|
||||
(function (variable) (exp_literal (float)))
|
||||
(function (variable) (exp_literal (float)))
|
||||
(function (variable) (exp_literal (float)))
|
||||
(function (variable) (exp_literal (float)))
|
||||
(function (variable) (exp_literal (float)))
|
||||
(function (variable) (exp_literal (float))))
|
||||
|
||||
================================================================================
|
||||
number: binary
|
||||
================================================================================
|
||||
|
||||
a = 0b01110
|
||||
a = 0B10010
|
||||
a = 0B10010##
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function (variable) (exp_literal (integer)))
|
||||
(function (variable) (exp_literal (integer)))
|
||||
(function (variable) (exp_literal (integer))))
|
||||
@ -1,485 +0,0 @@
|
||||
================================================================================
|
||||
pat: basic
|
||||
================================================================================
|
||||
|
||||
a a (a:a : as) (a, a, (a, [a])) = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
name: (variable)
|
||||
patterns: (patterns
|
||||
(pat_name (variable))
|
||||
(pat_parens
|
||||
(pat_infix
|
||||
(pat_name (variable))
|
||||
(constructor_operator)
|
||||
(pat_infix (pat_name (variable)) (constructor_operator) (pat_name (variable)))))
|
||||
(pat_tuple
|
||||
(pat_name (variable))
|
||||
(comma)
|
||||
(pat_name (variable))
|
||||
(comma)
|
||||
(pat_tuple (pat_name (variable)) (comma) (pat_list (pat_name (variable))))))
|
||||
rhs: (exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
pat: con
|
||||
================================================================================
|
||||
|
||||
a A = a
|
||||
a (A a) = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function (variable) (patterns (pat_name (constructor))) (exp_name (variable)))
|
||||
(function
|
||||
(variable)
|
||||
(patterns (pat_parens (pat_apply (pat_name (constructor)) (pat_name (variable)))))
|
||||
(exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
pat: consym
|
||||
================================================================================
|
||||
|
||||
a (a :++ a) = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(patterns (pat_parens (pat_infix (pat_name (variable)) (constructor_operator) (pat_name (variable)))))
|
||||
(exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
pat: as
|
||||
================================================================================
|
||||
|
||||
a a@(A a) a@(A a) = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(patterns
|
||||
(pat_as (variable) (pat_parens (pat_apply (pat_name (constructor)) (pat_name (variable)))))
|
||||
(pat_as (variable) (pat_parens (pat_apply (pat_name (constructor)) (pat_name (variable))))))
|
||||
(exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
pat: wildcard
|
||||
================================================================================
|
||||
|
||||
a (A _) _ = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(patterns
|
||||
(pat_parens (pat_apply (pat_name (constructor)) (pat_wildcard)))
|
||||
(pat_wildcard))
|
||||
(exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
pat: literal
|
||||
================================================================================
|
||||
|
||||
a 1 2 = 3
|
||||
a "a" "a" = a
|
||||
a 'a' 'b' = a
|
||||
a 1.0 2.0 = 3.0
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function (variable) (patterns (pat_literal (integer)) (pat_literal (integer))) (exp_literal (integer)))
|
||||
(function (variable) (patterns (pat_literal (string)) (pat_literal (string))) (exp_name (variable)))
|
||||
(function (variable) (patterns (pat_literal (char)) (pat_literal (char))) (exp_name (variable)))
|
||||
(function (variable) (patterns (pat_literal (float)) (pat_literal (float))) (exp_literal (float))))
|
||||
|
||||
================================================================================
|
||||
pat: record
|
||||
================================================================================
|
||||
|
||||
f A {} = a
|
||||
f A {..} = a
|
||||
f a@A { a = a, b = a, a, .. } = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function (variable) (patterns (pat_record (pat_name (constructor)) (pat_fields))) (exp_name (variable)))
|
||||
(function
|
||||
(variable)
|
||||
(patterns
|
||||
(pat_record
|
||||
(pat_name (constructor))
|
||||
(pat_fields (pat_field (wildcard)))))
|
||||
(exp_name (variable)))
|
||||
(function
|
||||
(variable)
|
||||
(patterns
|
||||
(pat_as
|
||||
(variable)
|
||||
(pat_record
|
||||
(pat_name (constructor))
|
||||
(pat_fields
|
||||
(pat_field (variable) (pat_name (variable)))
|
||||
(comma)
|
||||
(pat_field (variable) (pat_name (variable)))
|
||||
(comma)
|
||||
(pat_field (variable)) (comma) (pat_field (wildcard))))))
|
||||
(exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
pat: irrefutable
|
||||
================================================================================
|
||||
|
||||
a ~a = a
|
||||
a ~(~a) = a
|
||||
a ~(~(a, a), a) = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable) (patterns (pat_irrefutable (pat_name (variable)))) (exp_name (variable)))
|
||||
(function
|
||||
(variable) (patterns (pat_irrefutable (pat_parens (pat_irrefutable (pat_name (variable))))))
|
||||
(exp_name (variable)))
|
||||
(function
|
||||
(variable)
|
||||
(patterns (pat_irrefutable
|
||||
(pat_tuple
|
||||
(pat_irrefutable (pat_tuple (pat_name (variable)) (comma) (pat_name (variable))))
|
||||
(comma)
|
||||
(pat_name (variable)))))
|
||||
(exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
pat: view pattern in function lhs
|
||||
================================================================================
|
||||
|
||||
a (a a -> Aa a a) = a
|
||||
a (a -> a, a -> a) = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(patterns
|
||||
(pat_parens
|
||||
(pat_view
|
||||
(exp_apply (exp_name (variable)) (exp_name (variable)))
|
||||
(pat_apply (pat_name (constructor)) (pat_name (variable)) (pat_name (variable))))))
|
||||
(exp_name (variable)))
|
||||
(function
|
||||
(variable)
|
||||
(patterns
|
||||
(pat_tuple
|
||||
(pat_view (exp_name (variable)) (pat_name (variable)))
|
||||
(comma)
|
||||
(pat_view (exp_name (variable)) (pat_name (variable)))))
|
||||
(exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
pat: view pattern in lambda
|
||||
================================================================================
|
||||
|
||||
a = \ (a -> a) -> a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_lambda
|
||||
(pat_parens (pat_view (exp_name (variable)) (pat_name (variable))))
|
||||
(exp_name (variable)))))
|
||||
|
||||
================================================================================
|
||||
pat: infix pattern in decl lhs
|
||||
================================================================================
|
||||
|
||||
A a == A a = a == a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
infix: (infix
|
||||
lhs: (pat_apply (pat_name (constructor)) (pat_name (variable)))
|
||||
op: (varop (operator))
|
||||
rhs: (pat_apply (pat_name (constructor)) (pat_name (variable))))
|
||||
rhs: (exp_infix (exp_name (variable)) (operator) (exp_name (variable)))))
|
||||
|
||||
================================================================================
|
||||
pat: infix pattern variable
|
||||
================================================================================
|
||||
|
||||
a |> a = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(infix (pat_name (variable)) (varop (operator)) (pat_name (variable)))
|
||||
(exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
pat: tuple pattern function
|
||||
================================================================================
|
||||
|
||||
(a, a) = a
|
||||
|
||||
---
|
||||
|
||||
(haskell (function (pat_tuple (pat_name (variable)) (comma) (pat_name (variable))) (exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
pat: con application pattern function
|
||||
================================================================================
|
||||
|
||||
A a = a
|
||||
|
||||
---
|
||||
|
||||
(haskell (function (pat_apply (pat_name (constructor)) (pat_name (variable))) (exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
pat: parens con application pattern function
|
||||
================================================================================
|
||||
|
||||
(A a) = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
pattern: (pat_parens (pat_apply (pat_name (constructor)) (pat_name (variable))))
|
||||
rhs: (exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
pat: parenthesized record
|
||||
================================================================================
|
||||
|
||||
a (A{}) = a
|
||||
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable) (patterns (pat_parens (pat_record (pat_name (constructor)) (pat_fields))))
|
||||
(exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
pat: guards
|
||||
================================================================================
|
||||
|
||||
a a | a < 1, a > 1 = A
|
||||
| A (A A {..} _) : a <- a = A
|
||||
| otherwise = A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
name: (variable)
|
||||
patterns: (patterns (pat_name (variable)))
|
||||
(guard_equation
|
||||
(guards
|
||||
(guard (exp_infix (exp_name (variable)) (operator) (exp_literal (integer))))
|
||||
(comma)
|
||||
(guard (exp_infix (exp_name (variable)) (operator) (exp_literal (integer)))))
|
||||
(exp_name (constructor)))
|
||||
(guard_equation
|
||||
(guards
|
||||
(guard
|
||||
(pattern_guard
|
||||
(pat_infix
|
||||
(pat_apply
|
||||
(pat_name (constructor))
|
||||
(pat_parens
|
||||
(pat_apply
|
||||
(pat_name (constructor))
|
||||
(pat_record con: (pat_name (constructor)) fields: (pat_fields (pat_field (wildcard))))
|
||||
(pat_wildcard))))
|
||||
(constructor_operator)
|
||||
(pat_name (variable)))
|
||||
(exp_name (variable)))))
|
||||
(exp_name (constructor)))
|
||||
(guard_equation
|
||||
(guards (guard (exp_name (variable))))
|
||||
(exp_name (constructor)))))
|
||||
|
||||
================================================================================
|
||||
pat: view pattern in record
|
||||
================================================================================
|
||||
|
||||
a A { a = a -> a } = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(patterns
|
||||
(pat_record
|
||||
(pat_name (constructor))
|
||||
(pat_fields (pat_field (variable) (pat_view (exp_name (variable)) (pat_name (variable)))))))
|
||||
(exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
pat: unboxed tuple
|
||||
================================================================================
|
||||
|
||||
a (# a, a, a #) = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(patterns (pat_unboxed_tuple (pat_name (variable)) (comma) (pat_name (variable)) (comma) (pat_name (variable))))
|
||||
(exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
pat: unboxed sum, nullary tuple
|
||||
================================================================================
|
||||
|
||||
a (# (# #) | | #) = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(patterns
|
||||
(pat_unboxed_sum (pat_unboxed_tuple)))
|
||||
(exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
pat: signature
|
||||
================================================================================
|
||||
|
||||
a (a :: A) = a
|
||||
a = do
|
||||
let (a :: A, a) = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(patterns (pat_parens (pat_typed (pat_name (variable)) (type_name (type)))))
|
||||
(exp_name (variable)))
|
||||
(function
|
||||
(variable)
|
||||
(exp_do
|
||||
(stmt
|
||||
(let
|
||||
(decls
|
||||
(function
|
||||
(pat_tuple (pat_typed (pat_name (variable)) (type_name (type))) (comma) (pat_name (variable)))
|
||||
(exp_name (variable)))))))))
|
||||
|
||||
================================================================================
|
||||
pat: do binder signature
|
||||
================================================================================
|
||||
|
||||
a = do
|
||||
a :: A <- a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
name: (variable)
|
||||
rhs: (exp_do
|
||||
(stmt (bind_pattern (pat_typed pattern: (pat_name (variable)) type: (type_name (type))) (exp_name (variable)))))))
|
||||
|
||||
================================================================================
|
||||
pat: funpat signature
|
||||
================================================================================
|
||||
|
||||
a :: A = a
|
||||
|
||||
---
|
||||
|
||||
(haskell (function (pat_typed (pat_name (variable)) (type_name (type))) (exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
pat: do binder view pattern
|
||||
================================================================================
|
||||
|
||||
a = do
|
||||
(a -> a) <- a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_do
|
||||
(stmt
|
||||
(bind_pattern
|
||||
(pat_parens (pat_view (exp_name (variable)) (pat_name (variable))))
|
||||
(exp_name (variable)))))))
|
||||
|
||||
================================================================================
|
||||
pat: splice
|
||||
================================================================================
|
||||
|
||||
a $(a) = a
|
||||
|
||||
---
|
||||
|
||||
(haskell (function (variable) (patterns (splice (exp_parens (exp_name (variable))))) (exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
pat: quasiqoute
|
||||
================================================================================
|
||||
|
||||
a [a|a|] = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(patterns (quasiquote (quasiquote_start) (quoter) (quasiquote_bar) (quasiquote_body)))
|
||||
(exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
pat: operator
|
||||
================================================================================
|
||||
|
||||
a (++) = a
|
||||
|
||||
---
|
||||
|
||||
(haskell (function (variable) (patterns (pat_name (operator))) (exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
pat: negation with parens
|
||||
================================================================================
|
||||
|
||||
f (-(a)) = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(patterns
|
||||
(pat_parens
|
||||
(pat_negation (pat_parens (pat_name (variable))))))
|
||||
(exp_name (variable))))
|
||||
@ -1,162 +0,0 @@
|
||||
================================================================================
|
||||
pattern synonym: unidirectional simple
|
||||
================================================================================
|
||||
|
||||
pattern A a <- a:as
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(pattern_synonym
|
||||
(equation
|
||||
(pat_apply (pat_name (constructor)) (pat_name (variable)))
|
||||
(pat_infix (pat_name (variable)) (constructor_operator) (pat_name (variable))))))
|
||||
|
||||
================================================================================
|
||||
pattern synonym: unidirectional strict
|
||||
================================================================================
|
||||
|
||||
pattern A a = A !a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(pattern_synonym
|
||||
(equation
|
||||
(pat_apply (pat_name (constructor)) (pat_name (variable)))
|
||||
(pat_apply (pat_name (constructor)) (pat_strict (pat_name (variable)))))))
|
||||
|
||||
================================================================================
|
||||
pattern synonym: explicit bidirectional list
|
||||
================================================================================
|
||||
|
||||
pattern HeadC a <- a:as where
|
||||
HeadC a = [a]
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(pattern_synonym
|
||||
(equation
|
||||
(pat_apply (pat_name (constructor)) (pat_name (variable)))
|
||||
(pat_infix (pat_name (variable)) (constructor_operator) (pat_name (variable)))
|
||||
(where)
|
||||
(pat_apply (pat_name (constructor)) (pat_name (variable)))
|
||||
(exp_list (exp_name (variable))))))
|
||||
|
||||
================================================================================
|
||||
pattern synonym: explicit bidirectional strict
|
||||
================================================================================
|
||||
|
||||
pattern A a <- A !a where
|
||||
A !a = A a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(pattern_synonym
|
||||
(equation
|
||||
(pat_apply (pat_name (constructor)) (pat_name (variable)))
|
||||
(pat_apply (pat_name (constructor)) (pat_strict (pat_name (variable))))
|
||||
(where)
|
||||
(pat_apply (pat_name (constructor)) (pat_strict (pat_name (variable))))
|
||||
(exp_apply (exp_name (constructor)) (exp_name (variable))))))
|
||||
|
||||
================================================================================
|
||||
pattern synonym: explicit bidirectional record
|
||||
================================================================================
|
||||
|
||||
pattern A { a } <- A a where
|
||||
A a = if a >= 0 then a else a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(pattern_synonym
|
||||
(equation
|
||||
lhs: (pat_record
|
||||
con: (pat_name (constructor))
|
||||
fields: (pat_fields (pat_field (variable))))
|
||||
rhs: (pat_apply (pat_name (constructor)) (pat_name (variable)))
|
||||
(where)
|
||||
(pat_apply (pat_name (constructor)) (pat_name (variable)))
|
||||
rhs: (exp_cond
|
||||
if: (exp_infix (exp_name (variable)) (operator) (exp_literal (integer)))
|
||||
then: (exp_name (variable))
|
||||
else: (exp_name (variable))))))
|
||||
|
||||
================================================================================
|
||||
pattern synonym: explicit bidirectional guards
|
||||
================================================================================
|
||||
|
||||
pattern A a <- A a where
|
||||
A a
|
||||
| a >= 0 = (A a)
|
||||
| otherwise = (A a)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(pattern_synonym
|
||||
(equation
|
||||
(pat_apply (pat_name (constructor)) (pat_name (variable)))
|
||||
(pat_apply (pat_name (constructor)) (pat_name (variable)))
|
||||
(where)
|
||||
(pat_apply (pat_name (constructor)) (pat_name (variable)))
|
||||
(guard_equation
|
||||
(guards (guard (exp_infix (exp_name (variable)) (operator) (exp_literal (integer)))))
|
||||
(exp_parens (exp_apply (exp_name (constructor)) (exp_name (variable)))))
|
||||
(guard_equation
|
||||
(guards (guard (exp_name (variable))))
|
||||
(exp_parens (exp_apply (exp_name (constructor)) (exp_name (variable))))))))
|
||||
|
||||
================================================================================
|
||||
pattern synonym: signature
|
||||
================================================================================
|
||||
|
||||
pattern A :: A -> A -> (A, A)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(pattern_synonym
|
||||
(signature
|
||||
(constructor)
|
||||
(fun
|
||||
(type_name (type))
|
||||
(fun
|
||||
(type_name (type))
|
||||
(type_tuple
|
||||
(type_name (type))
|
||||
(comma)
|
||||
(type_name (type))))))))
|
||||
|
||||
================================================================================
|
||||
pattern synonym: unidirectional record
|
||||
================================================================================
|
||||
|
||||
pattern A {a, a} = (a, a)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(pattern_synonym
|
||||
(equation
|
||||
(pat_record (pat_name (constructor)) (pat_fields (pat_field (variable)) (comma) (pat_field (variable))))
|
||||
(pat_tuple (pat_name (variable)) (comma) (pat_name (variable))))))
|
||||
|
||||
================================================================================
|
||||
pattern synonym: operator
|
||||
================================================================================
|
||||
|
||||
pattern (:->) :: A
|
||||
pattern a :-> b <- a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(pattern_synonym (signature (constructor_operator) type: (type_name (type))))
|
||||
(pattern_synonym
|
||||
(equation
|
||||
lhs: (pat_infix (pat_name (variable)) (constructor_operator) (pat_name (variable)))
|
||||
rhs: (pat_name (variable)))))
|
||||
@ -1,70 +0,0 @@
|
||||
================================================================================
|
||||
pragma: inline
|
||||
================================================================================
|
||||
|
||||
a = a
|
||||
{-# inline a #-}
|
||||
|
||||
a = a
|
||||
{-# inline conlike [1] a #-}
|
||||
{-#INLINE [~2] a#-}
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function (variable) (exp_name (variable)))
|
||||
(pragma)
|
||||
(function (variable) (exp_name (variable)))
|
||||
(pragma)
|
||||
(pragma))
|
||||
|
||||
|
||||
================================================================================
|
||||
pragma: without module
|
||||
================================================================================
|
||||
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
{-# language ScopedTypeVariables, DataKinds #-}
|
||||
|
||||
---
|
||||
|
||||
(haskell (pragma) (pragma) (empty_file))
|
||||
|
||||
================================================================================
|
||||
pragma: before module
|
||||
================================================================================
|
||||
|
||||
{-# language LambdaCase #-}
|
||||
{-# language ScopedTypeVariables, DataKinds #-}
|
||||
module A where
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(pragma)
|
||||
(pragma)
|
||||
(module)
|
||||
(where))
|
||||
|
||||
================================================================================
|
||||
pragma: instance
|
||||
================================================================================
|
||||
|
||||
instance {-# overlappable #-} A where
|
||||
|
||||
---
|
||||
|
||||
(haskell (instance (pragma) (instance_head (class_name (type))) (where)))
|
||||
|
||||
================================================================================
|
||||
pragma: multiline
|
||||
================================================================================
|
||||
|
||||
module A where
|
||||
{-# rules
|
||||
"a/a" [2] forall a . a a = a
|
||||
#-}
|
||||
|
||||
---
|
||||
|
||||
(haskell (module) (where) (pragma))
|
||||
@ -1,199 +0,0 @@
|
||||
================================================================================
|
||||
signature: basic
|
||||
================================================================================
|
||||
|
||||
a :: a -> A -> A a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(signature
|
||||
name: (variable)
|
||||
type: (fun
|
||||
(type_name (type_variable))
|
||||
(fun
|
||||
(type_name (type))
|
||||
(type_apply (type_name (type)) (type_name (type_variable)))))))
|
||||
|
||||
================================================================================
|
||||
signature: forall
|
||||
================================================================================
|
||||
|
||||
a :: forall a (a :: * -> Type) . (∀ a . a -> a) -> A a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(signature
|
||||
(variable)
|
||||
(forall
|
||||
(quantifiers
|
||||
(type_variable)
|
||||
(annotated_type_variable (type_variable) (fun (type_star) (type_name (type)))))
|
||||
(fun
|
||||
(type_parens
|
||||
(forall
|
||||
(quantifiers (type_variable))
|
||||
(fun (type_name (type_variable)) (type_name (type_variable)))))
|
||||
(type_apply (type_name (type)) (type_name (type_variable)))))))
|
||||
|
||||
|
||||
================================================================================
|
||||
signature: multi method operator
|
||||
================================================================================
|
||||
|
||||
(<), (<=), (>=), (>) :: a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(signature
|
||||
(operator)
|
||||
(comma)
|
||||
(operator)
|
||||
(comma)
|
||||
(operator)
|
||||
(comma)
|
||||
(operator)
|
||||
(type_name (type_variable))))
|
||||
|
||||
|
||||
================================================================================
|
||||
signature: alternating forall/context/arrow
|
||||
================================================================================
|
||||
|
||||
a :: A a => ∀ a . a ++ a => a -> ∀ a . a -> A => A => A a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(signature
|
||||
name: (variable)
|
||||
type: (context
|
||||
(constraint class: (class_name (type)) (type_name (type_variable)))
|
||||
(forall
|
||||
(quantifiers (type_variable))
|
||||
(context
|
||||
(constraint
|
||||
(type_infix
|
||||
left: (type_name (type_variable))
|
||||
op: (type_operator)
|
||||
right: (type_name (type_variable))))
|
||||
(fun
|
||||
(type_name (type_variable))
|
||||
(forall
|
||||
(quantifiers (type_variable))
|
||||
(fun
|
||||
(type_name (type_variable))
|
||||
(context
|
||||
(constraint class: (class_name (type)))
|
||||
(context
|
||||
(constraint class: (class_name (type)))
|
||||
(type_apply (type_name (type)) (type_name (type_variable)))))))))))))
|
||||
|
||||
================================================================================
|
||||
signature: parenthesized operator fun
|
||||
================================================================================
|
||||
|
||||
(<>) = a
|
||||
|
||||
---
|
||||
|
||||
(haskell (function (operator) (exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
signature: operator starting with hash
|
||||
================================================================================
|
||||
|
||||
(#!) :: a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(signature
|
||||
(operator)
|
||||
(type_name (type_variable))))
|
||||
|
||||
|
||||
================================================================================
|
||||
signature: HKT annotation
|
||||
================================================================================
|
||||
|
||||
a :: (a :: (* -> *) -> *) -> a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(signature
|
||||
(variable)
|
||||
(fun
|
||||
(type_name
|
||||
(annotated_type_variable
|
||||
(type_variable)
|
||||
(fun
|
||||
(type_parens (fun (type_star) (type_star)))
|
||||
(type_star))))
|
||||
(type_name (type_variable)))))
|
||||
|
||||
================================================================================
|
||||
signature: partial
|
||||
================================================================================
|
||||
|
||||
a :: A -> _ -> (_, a) -> _a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(signature
|
||||
(variable)
|
||||
(fun
|
||||
(type_name (type))
|
||||
(fun
|
||||
(type_name (type_variable))
|
||||
(fun
|
||||
(type_tuple (type_name (type_variable)) (comma) (type_name (type_variable)))
|
||||
(type_name (type_variable)))))))
|
||||
|
||||
================================================================================
|
||||
signature: unboxed tuple
|
||||
================================================================================
|
||||
|
||||
a :: (# A, A #)
|
||||
|
||||
---
|
||||
|
||||
(haskell (signature (variable) (type_unboxed_tuple (type_name (type)) (comma) (type_name (type)))))
|
||||
|
||||
================================================================================
|
||||
signature: splice
|
||||
================================================================================
|
||||
|
||||
a :: a -> $(a ''A) -> a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(signature
|
||||
(variable)
|
||||
(fun
|
||||
(type_name (type_variable))
|
||||
(fun
|
||||
(splice (exp_parens (exp_apply (exp_name (variable)) (exp_th_quoted_name (type_name (type))))))
|
||||
(type_name (type_variable))))))
|
||||
|
||||
================================================================================
|
||||
signature: quasiquote
|
||||
================================================================================
|
||||
|
||||
a :: a -> [a|a|] -> a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(signature
|
||||
(variable)
|
||||
(fun
|
||||
(type_name (type_variable))
|
||||
(fun
|
||||
(quasiquote (quasiquote_start) (quoter) (quasiquote_bar) (quasiquote_body))
|
||||
(type_name (type_variable))))))
|
||||
@ -1,36 +0,0 @@
|
||||
================================================================================
|
||||
string: special chars
|
||||
================================================================================
|
||||
|
||||
a = "\\\"\a\b\f\n\r\t\v\&\NUL\SOH\STX\ETX\EOT\ENQ\ACK\BEL\BS\HT\LF\VT\FF\CR\SO\SI\DLE\DC1\DC2\DC3\DC4\NAK\SYN\ETB\CAN\EM\SUB\ESC\FS\GS\RS\US\SP\DEL\^A\^Z\^@\^[\^]\^\\^^\^_"
|
||||
|
||||
---
|
||||
|
||||
(haskell (function (variable) (exp_literal (string))))
|
||||
|
||||
================================================================================
|
||||
string: gap
|
||||
================================================================================
|
||||
|
||||
a = "start\
|
||||
\"
|
||||
|
||||
a = "start\
|
||||
\end"
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function (variable) (exp_literal (string)))
|
||||
(function (variable) (exp_literal (string))))
|
||||
|
||||
================================================================================
|
||||
string: magic hash
|
||||
================================================================================
|
||||
|
||||
a = "a"#
|
||||
a = "a"##
|
||||
|
||||
---
|
||||
|
||||
(haskell (function (variable) (exp_literal (string))) (function (variable) (exp_literal (string))))
|
||||
@ -1,150 +0,0 @@
|
||||
================================================================================
|
||||
template haskell: quasiquotes
|
||||
================================================================================
|
||||
|
||||
f =
|
||||
[|body|]
|
||||
[quoter|body|]
|
||||
[quoter|body|with|bars
|
||||
and newline|]
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_apply
|
||||
(quasiquote (quasiquote_start) (quasiquote_bar) (quasiquote_body))
|
||||
(quasiquote (quasiquote_start) (quoter) (quasiquote_bar) (quasiquote_body))
|
||||
(quasiquote (quasiquote_start) (quoter) (quasiquote_bar) (quasiquote_body)))))
|
||||
|
||||
================================================================================
|
||||
template haskell: top level splice with parens
|
||||
================================================================================
|
||||
|
||||
$(a ''Aa)
|
||||
$(a ''A.Aa)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(top_splice (splice (exp_parens (exp_apply (exp_name (variable)) (exp_th_quoted_name (type_name (type)))))))
|
||||
(top_splice
|
||||
(splice
|
||||
(exp_parens
|
||||
(exp_apply
|
||||
(exp_name (variable))
|
||||
(exp_th_quoted_name (type_name (qualified_type (module) (type)))))))))
|
||||
|
||||
================================================================================
|
||||
template haskell: inline splice variable
|
||||
================================================================================
|
||||
|
||||
f = $a
|
||||
|
||||
---
|
||||
|
||||
(haskell (function (variable) (splice (exp_name (variable)))))
|
||||
|
||||
================================================================================
|
||||
template haskell: inline splice parens
|
||||
================================================================================
|
||||
|
||||
f = $(a . a $ a)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(splice
|
||||
(exp_parens
|
||||
(exp_infix
|
||||
(exp_infix (exp_name (variable)) (operator) (exp_name (variable)))
|
||||
(operator)
|
||||
(exp_name (variable)))))))
|
||||
|
||||
================================================================================
|
||||
template haskell: inline splice double
|
||||
================================================================================
|
||||
|
||||
a = $$a
|
||||
a = $$(a)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function (variable) (splice (exp_name (variable))))
|
||||
(function (variable) (splice (exp_parens (exp_name (variable))))))
|
||||
|
||||
================================================================================
|
||||
template haskell: inline splice in function application
|
||||
================================================================================
|
||||
|
||||
a = a $(a)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_apply (exp_name (variable)) (splice (exp_parens (exp_name (variable)))))))
|
||||
|
||||
================================================================================
|
||||
template haskell: top level splice without parens
|
||||
================================================================================
|
||||
|
||||
derive ''Aa
|
||||
derive [''Aa]
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(top_splice (exp_apply (exp_name (variable)) (exp_th_quoted_name (type_name (type)))))
|
||||
(top_splice (exp_apply (exp_name (variable)) (exp_list (exp_th_quoted_name (type_name (type)))))))
|
||||
|
||||
================================================================================
|
||||
template haskell: comment in quasiquote body
|
||||
================================================================================
|
||||
|
||||
a = [|-- a|]
|
||||
a = [|{- a -}|]
|
||||
a = [quote|
|
||||
-- a
|
||||
a -- a
|
||||
|]
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function (variable) (quasiquote (quasiquote_start) (quasiquote_bar) (quasiquote_body)))
|
||||
(function (variable) (quasiquote (quasiquote_start) (quasiquote_bar) (quasiquote_body)))
|
||||
(function (variable) (quasiquote (quasiquote_start) (quoter) (quasiquote_bar) (quasiquote_body)))
|
||||
)
|
||||
|
||||
================================================================================
|
||||
template haskell: qualified quoter
|
||||
================================================================================
|
||||
|
||||
a = [A.a|a|]
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(quasiquote
|
||||
(quasiquote_start)
|
||||
(quoter (module) (variable))
|
||||
(quasiquote_bar)
|
||||
(quasiquote_body))))
|
||||
|
||||
================================================================================
|
||||
template haskell: error: incomplete quote
|
||||
================================================================================
|
||||
|
||||
a = [a|
|
||||
|
||||
---
|
||||
|
||||
(haskell (function (variable) (quasiquote (quasiquote_start) (quoter) (quasiquote_bar) (MISSING "|]"))))
|
||||
@ -1,536 +0,0 @@
|
||||
================================================================================
|
||||
type decl: basic
|
||||
================================================================================
|
||||
|
||||
type A = A
|
||||
type A a = A a
|
||||
type A = A A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_alias
|
||||
(type)
|
||||
(type_name (type)))
|
||||
(type_alias
|
||||
(type)
|
||||
(type_variable)
|
||||
(type_apply (type_name (type)) (type_name (type_variable))))
|
||||
(type_alias
|
||||
(type)
|
||||
(type_apply (type_name (type)) (type_name (type)))))
|
||||
|
||||
================================================================================
|
||||
type decl: two tycons
|
||||
================================================================================
|
||||
|
||||
type A = A A
|
||||
|
||||
---
|
||||
|
||||
(haskell (type_alias (type) (type_apply (type_name (type)) (type_name (type)))))
|
||||
|
||||
================================================================================
|
||||
type decl: promoted constructor
|
||||
================================================================================
|
||||
|
||||
type A = ' A
|
||||
type A = 'A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_alias
|
||||
(type)
|
||||
(type_name (promoted (type))))
|
||||
(type_alias
|
||||
(type)
|
||||
(type_name (promoted (type)))))
|
||||
|
||||
================================================================================
|
||||
type decl: list plain
|
||||
================================================================================
|
||||
|
||||
type A = []
|
||||
type A = [A a]
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_alias
|
||||
(type)
|
||||
(type_literal (con_list)))
|
||||
(type_alias
|
||||
(type)
|
||||
(type_list (type_apply (type_name (type)) (type_name (type_variable))))))
|
||||
|
||||
================================================================================
|
||||
type decl: parens
|
||||
================================================================================
|
||||
|
||||
type A = ()
|
||||
type A = (,)
|
||||
type A = (,,)
|
||||
type A = (->)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_alias
|
||||
(type)
|
||||
(type_literal (con_unit)))
|
||||
(type_alias
|
||||
(type)
|
||||
(type_literal (con_tuple (comma))))
|
||||
(type_alias
|
||||
(type)
|
||||
(type_literal (con_tuple (comma) (comma))))
|
||||
(type_alias
|
||||
(type)
|
||||
(type_name (tycon_arrow))))
|
||||
|
||||
================================================================================
|
||||
type decl: consym
|
||||
================================================================================
|
||||
|
||||
type A = A :++ A ':++ A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_alias
|
||||
(type)
|
||||
(type_infix
|
||||
(type_name (type))
|
||||
(constructor_operator)
|
||||
(type_infix
|
||||
(type_name (type))
|
||||
(promoted (constructor_operator))
|
||||
(type_name (type))))))
|
||||
|
||||
================================================================================
|
||||
type decl: list cons
|
||||
================================================================================
|
||||
|
||||
type A = A : A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_alias
|
||||
(type)
|
||||
(type_infix
|
||||
(type_name (type))
|
||||
(constructor_operator)
|
||||
(type_name (type)))))
|
||||
|
||||
================================================================================
|
||||
type decl: promoted list cons
|
||||
================================================================================
|
||||
|
||||
type A = A ': A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_alias
|
||||
(type)
|
||||
(type_infix
|
||||
(type_name (type))
|
||||
(promoted (constructor_operator))
|
||||
(type_name (type)))))
|
||||
|
||||
================================================================================
|
||||
type decl: promoted list nil
|
||||
================================================================================
|
||||
|
||||
type A = '[]
|
||||
|
||||
---
|
||||
|
||||
(haskell (type_alias (type) (promoted (type_literal (con_list)))))
|
||||
|
||||
================================================================================
|
||||
type decl: qualified consym
|
||||
================================================================================
|
||||
|
||||
type A = A A.A.:++ A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_alias
|
||||
(type)
|
||||
(type_infix
|
||||
(type_name (type))
|
||||
(qualified_constructor_operator (module) (module) (constructor_operator))
|
||||
(type_name (type)))))
|
||||
|
||||
================================================================================
|
||||
type decl: promoted consym
|
||||
================================================================================
|
||||
|
||||
type A = A ':++ A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_alias
|
||||
(type)
|
||||
(type_infix
|
||||
(type_name (type))
|
||||
(promoted (constructor_operator))
|
||||
(type_name (type)))))
|
||||
|
||||
================================================================================
|
||||
type decl: qualified promoted consym
|
||||
================================================================================
|
||||
|
||||
type A = A 'A.:++ A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_alias
|
||||
(type)
|
||||
(type_infix
|
||||
(type_name (type))
|
||||
(promoted (qualified_constructor_operator (module) (constructor_operator)))
|
||||
(type_name (type)))))
|
||||
|
||||
================================================================================
|
||||
type decl: qualified ticked
|
||||
================================================================================
|
||||
|
||||
type A = A `A.A` A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_alias
|
||||
(type)
|
||||
(type_infix
|
||||
(type_name (type))
|
||||
(ticked (qualified_type (module) (type)))
|
||||
(type_name (type)))))
|
||||
|
||||
================================================================================
|
||||
type decl: promoted tuple
|
||||
================================================================================
|
||||
|
||||
type A = '(A a, A)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_alias
|
||||
(type)
|
||||
(promoted
|
||||
(type_tuple
|
||||
(type_apply (type_name (type)) (type_name (type_variable)))
|
||||
(comma)
|
||||
(type_name (type))))))
|
||||
|
||||
================================================================================
|
||||
type decl: equality
|
||||
================================================================================
|
||||
|
||||
type A = A ~ A
|
||||
type A = A ~~ A
|
||||
type A = ∀ a . (A a ~ A a) => A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_alias
|
||||
(type)
|
||||
(type_infix (type_name (type)) (type_operator) (type_name (type))))
|
||||
(type_alias
|
||||
(type)
|
||||
(type_infix (type_name (type)) (type_operator) (type_name (type))))
|
||||
(type_alias
|
||||
(type)
|
||||
(forall
|
||||
(quantifiers (type_variable))
|
||||
(context
|
||||
(constraint
|
||||
(type_infix
|
||||
(type_apply (type_name (type)) (type_name (type_variable)))
|
||||
(type_operator)
|
||||
(type_apply (type_name (type)) (type_name (type_variable))))
|
||||
)
|
||||
(type_name (type))))))
|
||||
|
||||
================================================================================
|
||||
type decl: mixed infix
|
||||
================================================================================
|
||||
|
||||
type A = A :++ A A ': A (A A a) : '[] ':++ A `A.A` '[]
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_alias
|
||||
(type)
|
||||
(type_infix
|
||||
(type_name (type))
|
||||
(constructor_operator)
|
||||
(type_infix
|
||||
(type_apply
|
||||
(type_name (type))
|
||||
(type_name (type)))
|
||||
(promoted (constructor_operator))
|
||||
(type_infix
|
||||
(type_apply
|
||||
(type_name (type))
|
||||
(type_parens (type_apply (type_name (type)) (type_name (type)) (type_name (type_variable)))))
|
||||
(constructor_operator)
|
||||
(type_infix
|
||||
(promoted (type_literal (con_list)))
|
||||
(promoted (constructor_operator))
|
||||
(type_infix
|
||||
(type_name (type))
|
||||
(ticked (qualified_type (module) (type)))
|
||||
(promoted (type_literal (con_list))))))))))
|
||||
|
||||
================================================================================
|
||||
type decl: symbol
|
||||
================================================================================
|
||||
|
||||
type A = "a"
|
||||
type A = A (A "a")
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_alias (type) (type_literal (string)))
|
||||
(type_alias
|
||||
(type)
|
||||
(type_apply
|
||||
(type_name (type))
|
||||
(type_parens (type_apply (type_name (type)) (type_literal (string)))))))
|
||||
|
||||
================================================================================
|
||||
type decl: prefix notation symbol
|
||||
================================================================================
|
||||
|
||||
type A = (++) a a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_alias
|
||||
(type)
|
||||
(type_apply
|
||||
(type_name (type_operator))
|
||||
(type_name (type_variable))
|
||||
(type_name (type_variable)))))
|
||||
|
||||
================================================================================
|
||||
type decl: nullary context
|
||||
================================================================================
|
||||
|
||||
type A = A => A
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_alias
|
||||
(type)
|
||||
(context (constraint (class_name (type))) (type_name (type)))))
|
||||
|
||||
================================================================================
|
||||
type decl: forall
|
||||
================================================================================
|
||||
|
||||
type A = ∀ a a . A => A
|
||||
type A = forall a a . A a => [A]
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_alias
|
||||
(type)
|
||||
(forall
|
||||
(quantifiers (type_variable) (type_variable))
|
||||
(context (constraint (class_name (type))) (type_name (type)))))
|
||||
(type_alias
|
||||
(type)
|
||||
(forall
|
||||
(quantifiers (type_variable) (type_variable))
|
||||
(context
|
||||
(constraint (class_name (type)) (type_name (type_variable)))
|
||||
(type_list (type_name (type)))))))
|
||||
|
||||
================================================================================
|
||||
type decl: lhs parens
|
||||
================================================================================
|
||||
|
||||
type (A a a) = A
|
||||
|
||||
---
|
||||
|
||||
(haskell (type_alias (type) (type_variable) (type_variable) (type_name (type))))
|
||||
|
||||
================================================================================
|
||||
type decl: contraint tuple with implicit parameter
|
||||
================================================================================
|
||||
|
||||
type A = (?a :: A.A, A)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_alias
|
||||
(type)
|
||||
(type_tuple
|
||||
(implicit_param (implicit_parid) (type_name (qualified_type (module) (type))))
|
||||
(comma)
|
||||
(type_name (type)))))
|
||||
|
||||
================================================================================
|
||||
type decl: implicit parameter constraint
|
||||
================================================================================
|
||||
|
||||
type A = ?a :: A
|
||||
|
||||
---
|
||||
|
||||
(haskell (type_alias (type) (implicit_param (implicit_parid) (type_name (type)))))
|
||||
|
||||
================================================================================
|
||||
type decl: role
|
||||
================================================================================
|
||||
|
||||
type role A phantom
|
||||
type role A.A _ representational nominal _ phantom _
|
||||
type role (A.>>) nominal nominal
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(role_annotation (type) (type_role))
|
||||
(role_annotation
|
||||
(qualified_type (module) (type))
|
||||
(type_role)
|
||||
(type_role)
|
||||
(type_role)
|
||||
(type_role)
|
||||
(type_role)
|
||||
(type_role))
|
||||
(role_annotation (qualified_type_operator (module) (type_operator)) (type_role) (type_role)))
|
||||
|
||||
================================================================================
|
||||
type decl: StandaloneKindSignatures
|
||||
================================================================================
|
||||
|
||||
type A a :: a -> Type
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_alias
|
||||
(type)
|
||||
(type_variable)
|
||||
(fun (type_name (type_variable)) (type_name (type)))))
|
||||
|
||||
================================================================================
|
||||
type decl: function with multiplicity modifier
|
||||
================================================================================
|
||||
|
||||
type A = a %1-> a
|
||||
type A = a %1 -> a
|
||||
type A = a %One -> a
|
||||
type A = a %m -> a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_alias
|
||||
(type)
|
||||
(fun
|
||||
(type_name (type_variable))
|
||||
(modifier (type_literal (integer)))
|
||||
(type_name (type_variable))))
|
||||
(type_alias
|
||||
(type)
|
||||
(fun
|
||||
(type_name (type_variable))
|
||||
(modifier (type_literal (integer)))
|
||||
(type_name (type_variable))))
|
||||
(type_alias
|
||||
(type)
|
||||
(fun
|
||||
(type_name (type_variable))
|
||||
(modifier (type_name (type)))
|
||||
(type_name (type_variable))))
|
||||
(type_alias
|
||||
(type)
|
||||
(fun
|
||||
(type_name (type_variable))
|
||||
(modifier (type_name (type_variable)))
|
||||
(type_name (type_variable)))))
|
||||
|
||||
================================================================================
|
||||
type decl: unboxed nullary tuple
|
||||
================================================================================
|
||||
|
||||
type A = (# #)
|
||||
type A = (##)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_alias
|
||||
(type)
|
||||
(type_unboxed_tuple))
|
||||
(type_alias
|
||||
(type)
|
||||
(type_name (type_operator))))
|
||||
|
||||
================================================================================
|
||||
type decl: unboxed unary tuple
|
||||
================================================================================
|
||||
|
||||
type A = (# a #)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_alias
|
||||
(type)
|
||||
(type_unboxed_tuple (type_name (type_variable)))))
|
||||
|
||||
================================================================================
|
||||
type decl: unboxed tuple with newline after opening brace
|
||||
================================================================================
|
||||
|
||||
type A =
|
||||
(#
|
||||
a #)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_alias
|
||||
(type)
|
||||
(type_unboxed_tuple
|
||||
(type_name
|
||||
(type_variable)))))
|
||||
|
||||
================================================================================
|
||||
type decl: unboxed tuple with newline before closing brace
|
||||
================================================================================
|
||||
|
||||
type A =
|
||||
(# a
|
||||
#)
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(type_alias
|
||||
(type)
|
||||
(type_unboxed_tuple
|
||||
(type_name
|
||||
(type_variable)))))
|
||||
@ -1,262 +0,0 @@
|
||||
================================================================================
|
||||
varsym: error: |
|
||||
================================================================================
|
||||
|
||||
f = a | a
|
||||
|
||||
---
|
||||
|
||||
(haskell (function (variable) (exp_apply (exp_name (variable)) (ERROR) (exp_name (variable)))))
|
||||
|
||||
================================================================================
|
||||
varsym: error: lambda
|
||||
================================================================================
|
||||
|
||||
f = a \\ a
|
||||
f = a \ a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_infix (exp_name (variable)) (operator) (exp_name (variable))))
|
||||
(function
|
||||
(variable)
|
||||
(exp_name (variable))) (ERROR (variable)))
|
||||
|
||||
================================================================================
|
||||
varsym: error: ..
|
||||
================================================================================
|
||||
|
||||
f = a .. a
|
||||
f = a ... a
|
||||
f = a . a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function (variable) (exp_apply (exp_name (variable)) (ERROR) (exp_name (variable))))
|
||||
(function (variable) (exp_infix (exp_name (variable)) (operator) (exp_name (variable))))
|
||||
(function (variable) (exp_infix (exp_name (variable)) (operator) (exp_name (variable))))
|
||||
)
|
||||
|
||||
================================================================================
|
||||
varsym: error: arrow
|
||||
================================================================================
|
||||
|
||||
f = a -> a
|
||||
f = a |> a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_apply (exp_name (variable)) (ERROR) (exp_name (variable))))
|
||||
(function
|
||||
(variable)
|
||||
(exp_infix (exp_name (variable)) (operator) (exp_name (variable)))))
|
||||
|
||||
================================================================================
|
||||
varsym: error: carrow
|
||||
================================================================================
|
||||
|
||||
f = a => a
|
||||
f = a =>> a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function (variable) (exp_apply (exp_name (variable)) (ERROR) (exp_name (variable))))
|
||||
(function (variable) (exp_infix (exp_name (variable)) (operator) (exp_name (variable))))
|
||||
)
|
||||
|
||||
================================================================================
|
||||
varsym: error: larrow
|
||||
================================================================================
|
||||
|
||||
f = a < a
|
||||
f = a <- a
|
||||
f = a <-- a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function (variable) (exp_infix (exp_name (variable)) (operator) (exp_name (variable))))
|
||||
(function (variable) (exp_apply (exp_name (variable)) (ERROR) (exp_name (variable))))
|
||||
(function (variable) (exp_infix (exp_name (variable)) (operator) (exp_name (variable))))
|
||||
)
|
||||
|
||||
================================================================================
|
||||
varsym: error: @
|
||||
================================================================================
|
||||
|
||||
f = a @ a
|
||||
f = a @@ a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function (variable) (exp_apply (exp_name (variable)) (exp_type_application (type_name (type_variable)))))
|
||||
(function (variable) (exp_infix (exp_name (variable)) (operator) (exp_name (variable))))
|
||||
)
|
||||
|
||||
================================================================================
|
||||
varsym: error: ~
|
||||
================================================================================
|
||||
|
||||
f = a ~ a
|
||||
f = a ~~ a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function (variable) (exp_apply (exp_name (variable)) (ERROR) (exp_name (variable))))
|
||||
(function (variable) (exp_infix (exp_name (variable)) (operator) (exp_name (variable))))
|
||||
)
|
||||
|
||||
================================================================================
|
||||
varsym: error: equals
|
||||
================================================================================
|
||||
|
||||
f = a = a
|
||||
f = a == a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function (variable) (exp_apply (exp_name (variable)) (ERROR) (exp_name (variable))))
|
||||
(function (variable) (exp_infix (exp_name (variable)) (operator) (exp_name (variable))))
|
||||
)
|
||||
|
||||
================================================================================
|
||||
varsym: error: leading :
|
||||
================================================================================
|
||||
|
||||
f = a :+ a
|
||||
f = a +: a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function (variable) (exp_infix (exp_name (variable)) (constructor_operator) (exp_name (variable))))
|
||||
(function (variable) (exp_infix (exp_name (variable)) (operator) (exp_name (variable))))
|
||||
)
|
||||
|
||||
================================================================================
|
||||
varsym: dollar operator
|
||||
================================================================================
|
||||
|
||||
f = a $ a
|
||||
f = a $$ a
|
||||
f = a $$$ a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function (variable) (exp_infix (exp_name (variable)) (operator) (exp_name (variable))))
|
||||
(function (variable) (exp_infix (exp_name (variable)) (operator) (exp_name (variable))))
|
||||
(function (variable) (exp_infix (exp_name (variable)) (operator) (exp_name (variable)))))
|
||||
|
||||
================================================================================
|
||||
varsym: two-symbol dollar operator
|
||||
================================================================================
|
||||
|
||||
a = a $! a
|
||||
|
||||
---
|
||||
|
||||
(haskell (function (variable) (exp_infix (exp_name (variable)) (operator) (exp_name (variable)))))
|
||||
|
||||
================================================================================
|
||||
varsym: comment with more than two dashes
|
||||
================================================================================
|
||||
|
||||
a --- a
|
||||
a ----- a
|
||||
|
||||
---
|
||||
|
||||
(haskell (top_splice (exp_name (variable))) (comment) (top_splice (exp_name (variable))) (comment))
|
||||
|
||||
================================================================================
|
||||
varsym: operator with large number of dashes
|
||||
================================================================================
|
||||
|
||||
a = a ------> a ----- %
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_infix (exp_name (variable)) (operator) (exp_name (variable))))
|
||||
(comment))
|
||||
|
||||
================================================================================
|
||||
varsym: implicit parameter
|
||||
================================================================================
|
||||
|
||||
a = ?a
|
||||
(?) = a
|
||||
a = a ? a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_name (implicit_parid)))
|
||||
(function
|
||||
(operator)
|
||||
(exp_name (variable)))
|
||||
(function
|
||||
(variable)
|
||||
(exp_infix (exp_name (variable)) (operator) (exp_name (variable)))))
|
||||
|
||||
================================================================================
|
||||
varsym: dollar terminated by opening bracket
|
||||
================================================================================
|
||||
|
||||
a = a $[a]
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(function
|
||||
(variable)
|
||||
(exp_infix (exp_name (variable)) (operator) (exp_list (exp_name (variable))))))
|
||||
|
||||
================================================================================
|
||||
varsym: bang as operator decl
|
||||
================================================================================
|
||||
|
||||
(!) :: A
|
||||
(!) = a
|
||||
|
||||
---
|
||||
|
||||
(haskell
|
||||
(signature (operator) (type_name (type)))
|
||||
(function (operator) (exp_name (variable))))
|
||||
|
||||
================================================================================
|
||||
varsym: bang as infix
|
||||
================================================================================
|
||||
|
||||
a = a ! a
|
||||
|
||||
---
|
||||
|
||||
(haskell (function (variable) (exp_infix (exp_name (variable)) (operator) (exp_name (variable)))))
|
||||
|
||||
================================================================================
|
||||
varsym: minus as operator decl
|
||||
================================================================================
|
||||
|
||||
(-) = (-)
|
||||
|
||||
---
|
||||
|
||||
(haskell (function (operator) (exp_name (operator))))
|
||||
@ -1,4 +0,0 @@
|
||||
a = \case
|
||||
b -> c
|
||||
|
||||
d = e
|
||||
@ -1,14 +0,0 @@
|
||||
(haskell [0, 0] - [4, 0]
|
||||
(function [0, 0] - [1, 8]
|
||||
name: (variable [0, 0] - [0, 1])
|
||||
rhs: (exp_lambda_case [0, 4] - [1, 8]
|
||||
(alts [1, 2] - [1, 8]
|
||||
(alt [1, 2] - [1, 8]
|
||||
(pat_name [1, 2] - [1, 3]
|
||||
(variable [1, 2] - [1, 3]))
|
||||
(exp_name [1, 7] - [1, 8]
|
||||
(variable [1, 7] - [1, 8]))))))
|
||||
(function [3, 0] - [3, 5]
|
||||
name: (variable [3, 0] - [3, 1])
|
||||
rhs: (exp_name [3, 4] - [3, 5]
|
||||
(variable [3, 4] - [3, 5]))))
|
||||
@ -1,6 +0,0 @@
|
||||
module A where
|
||||
|
||||
data Foo a =
|
||||
Foo
|
||||
deriving (Eq)
|
||||
deriving (Show)
|
||||
@ -1,17 +0,0 @@
|
||||
(haskell [0, 0] - [6, 0]
|
||||
module: (module [0, 7] - [0, 8])
|
||||
(where [0, 9] - [0, 14])
|
||||
(adt [2, 0] - [5, 17]
|
||||
name: (type [2, 5] - [2, 8])
|
||||
(type_variable [2, 9] - [2, 10])
|
||||
(constructors [3, 2] - [3, 5]
|
||||
(data_constructor [3, 2] - [3, 5]
|
||||
(constructor [3, 2] - [3, 5])))
|
||||
(deriving [4, 2] - [4, 15]
|
||||
class: (constraint [4, 12] - [4, 14]
|
||||
class: (class_name [4, 12] - [4, 14]
|
||||
(type [4, 12] - [4, 14]))))
|
||||
(deriving [5, 2] - [5, 17]
|
||||
class: (constraint [5, 12] - [5, 16]
|
||||
class: (class_name [5, 12] - [5, 16]
|
||||
(type [5, 12] - [5, 16]))))))
|
||||
@ -1,6 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
base=$(dirname $0)
|
||||
|
||||
diff <(tree-sitter parse $base/Test.hs) $base/Test.target
|
||||
diff <(tree-sitter parse $base/LambdaCaseEnd.hs) $base/LambdaCaseEnd.target
|
||||
@ -1,9 +0,0 @@
|
||||
module A where
|
||||
|
||||
data A a = A a
|
||||
|
||||
class C a where
|
||||
|
||||
a :: C a => A a -> A a
|
||||
a (A a) =
|
||||
A a
|
||||
Binary file not shown.
@ -1,11 +0,0 @@
|
||||
--- a/lib/binding_web/exports.json
|
||||
+++ b/lib/binding_web/exports.json
|
||||
@@ -3,6 +3,8 @@
|
||||
"_free",
|
||||
"_malloc",
|
||||
|
||||
+ "_realloc",
|
||||
+
|
||||
"__ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm",
|
||||
"__ZNKSt3__220__vector_base_commonILb1EE20__throw_length_errorEv",
|
||||
"__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm",
|
||||
Loading…
Reference in New Issue