// Inside a GADT arm, inference decides fields and HTML holes from the // refined type; Core follows those decisions, since the stored type is the // arm's unrefined rigid (issue #235). import std/html.{type Html} import std/io type Point { Point(x: Int, y: Int, label: String) } type Is { IsPoint -> Is , IsInt -> Is , IsBool -> Is , IsString -> Is , IsList -> Is> } fn second :: w: Is v: a -> Int { match w { IsPoint -> v.y, _ -> 0 } } fn label :: w: Is v: a -> String { match w { IsPoint -> v.label, _ -> "" } } fn attr :: w: Is v: a -> Html { match w { IsInt ->

{v}

, IsBool -> , IsString ->

{v}

, IsList -> , IsPoint ->

{v.x}

} } pub fn main :: -> () / { io.println (show (second IsPoint Point(1, 2, "p"))) io.println (label IsPoint Point(1, 2, "p")) io.println (html.render (attr IsInt 42)) io.println (html.render (attr IsBool True)) io.println (html.render (attr IsString "aone,
  • two
  • ])) io.println (html.render (attr IsPoint Point(7, 8, "q"))) } //> 2 //> p //>

    42

    //> //>

    a<b

    //>
    • one
    • two
    //>

    7