Taking inspiration from F# is always a great idea. One issue is going to be the 
meaning of `:`. I think in variant type definitions, it should always be 
followed by a type and there should never be a code block, while when pattern 
matching, it should always be a code block and never a type.

Maybe differentiate between `variant` (new keyword where each variant is paired 
with a named tuple) and `case`. For example:
    
    
    type RequestResult = variant
        of Success: string
        of Failure: (int, string)
    
    let response = case make_request()
        of Success(payload):
            echo payload
        of Failure(err_no, err_msg):
            echo &"Failed with error {err_no}: {err_msg}"
    
    # Alternatively?
    
    type RequestResult = variant
        of Success: string
        of Failure: tuple[err_no: int, err_msg: string]
    
    let response = case make_request()
        of Success as payload:
            echo payload
        of Failure as f:
            echo &"Failed with error {f.err_no}: {f.err_msg}"
    
    
    Run

@ingo The biggest issue I see with your sample is `either`, which I'd imagine 
artificially limits the number of variants of what should be "unbounded" 
variant functionality.

Reply via email to