dreamstack/examples/refined-types.ds

28 lines
715 B
Text
Raw Normal View History

-- DreamStack Dependent Types Example
-- Demonstrates refinement types, type aliases, and type annotations
-- Type aliases with refinement predicates
type PositiveInt = Int where value > 0
type Percentage = Float where value >= 0.0
-- Basic type annotations
let count: Int = 0
let name: String = "hello"
-- Annotated with refinement type alias
let priority: PositiveInt = 1
let progress: Percentage = 75.0
-- Derived values don't need annotation (inferred)
let doubled = count * 2
let greeting = "Welcome, {name}!"
view main = column [
text "Count: {count}"
text "Priority: {priority}"
text "Progress: {progress}%"
text greeting
button "+" { click: count += 1 }
button "-" { click: count -= 1 }
]