I'm also thinking about tuples. Are they supported in sum types?
    
    
    type
      Device = case
        of Mobile: (string, int)
        of Server: (string, int, bool)
    
    let device: Mobile = ("iPhone", 15)
    
    
    Run

How will they be unpacked? Can I do this?
    
    
    case device:
      of Mobile(name, model):
      of Server(name, model, online):
    
    
    Run

OR do I need to do this?
    
    
    case device:
      of Mobile((name, model)):
      of Server((name, model, online)):
    
    
    Run

Regarding your questions, this is how I see them:
    
    
    case x:
      of StrValue(s): # if s is of type string
      of Minus(m):    # then m is of type UnaryOp
      of IfStmt(ifs): # and ifs is of type IfTree
    
    
    Run

Should this even be allowed:
    
    
    of IfStmt(cond, thenPart, elsePart):
    
    
    Run

Wouldn't this be clearer:
    
    
    of IfStmt((cond, thenPart, elsePart)):
    
    
    Run
    
    
    of IfStmt((cond, thenPart, elsePart) as ift):
        doSomething(cond)
        doSomething(ift)
    
    
    Run

There's also this:
    
    
    of IfStmt(IfTree(cond, thenPart, elsePart)):
    
    
    Run

Or this:
    
    
    of IfStmt(IfTree(cond, thenPart, elsePart) as ift):
        doSomething(cond)
        doSomething(ift)
    
    
    Run

Reply via email to