-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust Sail options to use the more typical style
- Loading branch information
Showing
7 changed files
with
408 additions
and
112 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
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,57 @@ | ||
default Order dec | ||
|
||
$include <prelude.sail> | ||
|
||
struct rectangle = { | ||
width : int, | ||
height : int, | ||
} | ||
|
||
$span start SHAPE | ||
struct circle = { radius : int } | ||
|
||
union shape = { | ||
Rectangle : rectangle, | ||
Circle : circle, | ||
} | ||
$span end | ||
|
||
val example : unit -> unit | ||
|
||
function example() = { | ||
// Construct a shape using the Rectangle constructor | ||
let r : shape = Rectangle(struct { width = 30, height = 20 }); | ||
|
||
// Construct a shape using the Circle constructor | ||
// Note that we can allow the 'shape' type to be inferred | ||
let c = Circle(struct { radius = 15 }); | ||
} | ||
|
||
$span start EX_UNIT | ||
union example_unit_constructor = { | ||
Foo : (int, string), | ||
Bar : unit, | ||
} | ||
|
||
// Using a constructor with a tuple type | ||
let x1 = Foo(2, "a string") | ||
|
||
// Note that the above is equivalent to | ||
let x2 = Foo((2, "a string")) | ||
|
||
// Using a unit-type constructor | ||
let y1 = Bar() | ||
|
||
// Similarly, equivalent to | ||
let y2 = Bar(()) | ||
$span end | ||
|
||
union shape2 = { | ||
Rectangle2 : { width : int, height : int }, | ||
Circle2 : { radius : int }, | ||
} | ||
|
||
union either('a, 'b) = { | ||
Left : 'a, | ||
Right : 'b, | ||
} |
Oops, something went wrong.