Commit | Line | Data |
---|---|---|
7f918cf1 CE |
1 | (* Copyright (C) 2017 Matthew Fluet. |
2 | * Copyright (C) 1999-2007 Henry Cejtin, Matthew Fluet, Suresh | |
3 | * Jagannathan, and Stephen Weeks. | |
4 | * Copyright (C) 1997-2000 NEC Research Institute. | |
5 | * | |
6 | * MLton is released under a BSD-style license. | |
7 | * See the file MLton-LICENSE for details. | |
8 | *) | |
9 | ||
10 | signature NESTED_PAT_STRUCTS = | |
11 | sig | |
12 | include ATOMS | |
13 | structure Type: | |
14 | sig | |
15 | type t | |
16 | ||
17 | val layout: t -> Layout.t | |
18 | val tuple: t vector -> t | |
19 | end | |
20 | end | |
21 | ||
22 | signature NESTED_PAT = | |
23 | sig | |
24 | include NESTED_PAT_STRUCTS | |
25 | ||
26 | datatype t = T of {pat: node, ty: Type.t} | |
27 | and node = | |
28 | Con of {arg: t option, | |
29 | con: Con.t, | |
30 | targs: Type.t vector} | |
31 | | Const of {const: Const.t, | |
32 | isChar: bool, | |
33 | isInt: bool} | |
34 | | Layered of Var.t * t | |
35 | | Or of t vector | |
36 | | Record of t SortedRecord.t | |
37 | | Var of Var.t | |
38 | | Vector of t vector | |
39 | | Wild | |
40 | ||
41 | val flatten: t -> t vector | |
42 | (* isRefutable p iff p contains a constant, constructor or variable. *) | |
43 | val isRefutable: t -> bool | |
44 | val isVarOrWild: t -> bool | |
45 | val layout: t -> Layout.t | |
46 | val make: node * Type.t -> t | |
47 | val node: t -> node | |
48 | val removeOthersReplace: t * {new: Var.t, old: Var.t} -> t | |
49 | val removeVars: t -> t | |
50 | val replaceTypes: t * (Type.t -> Type.t) -> t | |
51 | val tuple: t vector -> t | |
52 | val ty: t -> Type.t | |
53 | (* varsAndTypes returns a list of the variables in the pattern, along with | |
54 | * their types. It is used for match compilation in order to build a | |
55 | * function that abstracts over the expression of a case rule p => e. | |
56 | * See infer.fun. | |
57 | *) | |
58 | val varsAndTypes: t -> (Var.t * Type.t) list | |
59 | end |