+1 for sum types a la F# (discriminated unions). They're very clean and minimal.
    
    
    type Option<'a> =
      | Some of 'a
      | None
    
    let opt = Some("hello")
    
    match opt with
      | Some x -> printfn "%A" x
      | None -> prinfn "None"
    
    
    Run
    
    
    type Shape =
      | Rectangle of width: float * length: float
      | Circle of radius: float
    
    match shape with
      | Rectangle(width = w) -> w
      | Circle(radius = r) -> r
    
    
    Run

Reply via email to