-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redefine Sugartypes as ordinary variants
This patch changes AST definitions in Sugartypes from polymorphic variants to ordinary variants. Some constructors are renamed to avoid name clashes. Others are placed inside modules. Common datatypes used throughout the compiler are placed in a new CommonTypes module. Operators are placed in a separate module to avoid import cycles with lens code. Closes #487
- Loading branch information
Showing
56 changed files
with
3,306 additions
and
3,103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
module Linearity = struct | ||
type t = Any | Unl | ||
[@@deriving eq,show] | ||
|
||
let is_any = function | ||
| Any -> true | ||
| _ -> false | ||
|
||
let is_nonlinear = function | ||
| Unl -> true | ||
| _ -> false | ||
|
||
let to_string = function | ||
| Any -> "Any" | ||
| Unl -> "Unl" | ||
end | ||
|
||
(* Convenient aliases for constructing values *) | ||
let lin_any = Linearity.Any | ||
let lin_unl = Linearity.Unl | ||
|
||
module DeclaredLinearity = struct | ||
type t = Lin | Unl | ||
[@@deriving show] | ||
|
||
let is_linear = function | ||
| Lin -> true | ||
| _ -> false | ||
|
||
let is_nonlinear = function | ||
| Unl -> true | ||
| _ -> false | ||
end | ||
|
||
(* Convenient aliases for constructing values *) | ||
let dl_lin = DeclaredLinearity.Lin | ||
let dl_unl = DeclaredLinearity.Unl | ||
|
||
module Restriction = struct | ||
type t = | ||
| Any | ||
| Base | ||
| Session | ||
| Effect | ||
[@@deriving eq,show] | ||
|
||
let is_any = function | ||
| Any -> true | ||
| _ -> false | ||
|
||
let is_base = function | ||
| Base -> true | ||
| _ -> false | ||
|
||
let is_session = function | ||
| Session -> true | ||
| _ -> false | ||
|
||
let is_effect = function | ||
| Effect -> true | ||
| _ -> false | ||
|
||
let to_string = function | ||
| Any -> "Any" | ||
| Base -> "Base" | ||
| Session -> "Session" | ||
| Effect -> "Eff" | ||
end | ||
|
||
(* Convenient aliases for constructing values *) | ||
let res_any = Restriction.Any | ||
let res_base = Restriction.Base | ||
let res_session = Restriction.Session | ||
let res_effect = Restriction.Effect | ||
|
||
module PrimaryKind = struct | ||
type t = | ||
| Type | ||
| Row | ||
| Presence | ||
[@@deriving show,eq] | ||
|
||
let to_string = function | ||
| Type -> "Type" | ||
| Row -> "Row" | ||
| Presence -> "Presence" | ||
end | ||
|
||
(* Convenient aliases for constructing values *) | ||
let pk_type = PrimaryKind.Type | ||
let pk_row = PrimaryKind.Row | ||
let pk_presence = PrimaryKind.Presence | ||
|
||
module Location = struct | ||
type t = Client | Server | Native | Unknown | ||
[@@deriving show] | ||
|
||
let is_client = function | ||
| Client -> true | ||
| _ -> false | ||
|
||
let is_server = function | ||
| Server -> true | ||
| _ -> false | ||
|
||
let is_native = function | ||
| Native -> true | ||
| _ -> false | ||
|
||
let is_unknown = function | ||
| Unknown -> true | ||
| _ -> false | ||
|
||
let to_string = function | ||
| Client -> "client" | ||
| Server -> "server" | ||
| Native -> "native" | ||
| Unknown -> "unknown" | ||
end | ||
|
||
(* Convenient aliases for constructing values *) | ||
let loc_client = Location.Client | ||
let loc_server = Location.Server | ||
let loc_native = Location.Native | ||
let loc_unknown = Location.Unknown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.