diff options
| author | Cody <cody@codyq.dev> | 2023-01-29 20:58:04 -0600 |
|---|---|---|
| committer | Cody <cody@codyq.dev> | 2023-01-29 20:58:04 -0600 |
| commit | a653a6602fe5ae5eb4739755db7b34bc92ecdadf (patch) | |
| tree | 2d99c570ccd77767e1d5fcf9b098d45c79cbe6e4 /tour/types.sloth | |
| parent | b856e5c7226e71e500be5eff7079c5d3b0e9e2f4 (diff) | |
| download | sloth-a653a6602fe5ae5eb4739755db7b34bc92ecdadf.tar.gz | |
More stuffs
Diffstat (limited to 'tour/types.sloth')
| -rw-r--r-- | tour/types.sloth | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tour/types.sloth b/tour/types.sloth index c7ef2f5..0fdae33 100644 --- a/tour/types.sloth +++ b/tour/types.sloth @@ -32,12 +32,24 @@ type Option<T> = type Class = Archer | Mage | Tank; type Operation = - | Add = (Operation, Operation) - | Literal = i32; + | Add = (Operation, Operation) + | Lit = i32; + +# Untagged Union Type +# +# Unlike tagged unions if all variants of a untagged union implement a specific +# trait you will be able to call those trait methods without getting the variant +# first. +type Untagged = i32 + String; # Type Alias type OptionPos = Option<Position>; +# You can define untagged union types and tuple types inline without a name, this +# may be useful for one-off types only used by a single function. +val example: String + i32 = 52; +val example: (i32, i32) = (5, 5); + # Functions can be associated with types using 'impl' blocks. type Color = (f64, f64, f64); |
