From e282b085970b7e30efbab5c23ece70b3db40933d Mon Sep 17 00:00:00 2001 From: LordBaryhobal Date: Wed, 20 May 2026 14:14:01 +0200 Subject: [PATCH] fix: tweak syntax examples - move operation definitions outside GeoLocation type - add nullable type - list syntax choices for complex refinement --- .../03_custom_types_v2.midas | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/examples/00_syntax_prototype/03_custom_types_v2.midas b/examples/00_syntax_prototype/03_custom_types_v2.midas index c908ae7..31b0f53 100644 --- a/examples/00_syntax_prototype/03_custom_types_v2.midas +++ b/examples/00_syntax_prototype/03_custom_types_v2.midas @@ -12,7 +12,10 @@ type Difference[T](T) type GeoLocation { lat: Latitude lon: Longitude +} +// Define operations on our custom type +extend GeoLocation { // This type is compatible with the `-` operation with another GeoLocation // i.e. you can subtract a GeoLocation from another GeoLocation, resulting // in a Difference of GeoLocations @@ -45,14 +48,26 @@ type Person { name: str // Property with an inline constraint - age: int where (0 <= _ < 150) + age: int? where (0 <= _ < 150) // Property referencing a predicate height: float where StrictlyPositive - home_loc: GeoLocation + home: GeoLocation } // Custom complex type derived from another complex type, with a constraint // on a property -type EquatorialPerson(Person) where _.home_loc is Equatorial +// Multiple proposed syntaxes, not yet defined + +// Explicit, but new keyword +type EquatorialPerson refines Person where Equatorial(_.home) + +// Explicit with existing keyword, might be confusing if expectations regarding 'is' +type EquatorialPerson is Person where Equatorial(_.home) + +// Consistent and Python-friendly but can be confused with structural extension +type EquatorialPerson(Person) where Equatorial(_.home) + +// Allow new properties, probably not useful +type EquatorialPerson extends Person where Equatorial(_.home)