Thread
#arrow-meta
    mattmoore

    mattmoore

    2 years ago
    This is awesome! Really looking forward to this.
    Fudge

    Fudge

    2 years ago
    Is it not possible to have a syntax of the form
    String | Int
    instead of
    Union2<String, Int>
    ?
    fun f(): Union2<String, Union2<Int, Double>> = 2
               fun y(): Union3<String, Int, Double> = f()
               fun x(): Int? = y()
    Shouldn’t
    x()
    produce a type mismatch compilation error since
    y()
    may return types that are not
    Int?
    ?
    Imran/Malic

    Imran/Malic

    2 years ago
    Shouldn’t 
    x()
     produce a type mismatch compilation error since 
    y()
     may return types that are not 
    Int?
    ?
    If they do it simply results in null. That is one of the proofs defined in the prelude.
    In other words there is a proof to unbox a Union to a given type, if it is part of the union.
    raulraja

    raulraja

    2 years ago
    It won’t let you unbox to a type that is not in the union, but if the type is in the union you access it safely with its nullable type without matching or folding in all cases
    Imran/Malic

    Imran/Malic

    2 years ago
    A bit poorly phrased from my side. 😄 I get why that could be misunderstood.