toTuple :: [T.Canonical] -> Expression () -> Expression ()
toTuple types x =
    check x JSArray (ObjectLit () fields)
  where
    fields =
        (prop "ctor", ctor) : zipWith convert [0..] types

    ctor =
        StringLit () ("_Tuple" ++ show (length types))

    convert n t =
        ( prop ('_':show n)
        , toType t (BracketRef () x (IntLit () n))
        )


-- OUTBOUND
toTuple :: [T.Canonical] -> Expression () -> Expression ()
toTuple types x =
    check x JSArray (ObjectLit () fields)
  where
    fields =
        (prop "ctor", ctor) : zipWith convert [0..] types

    ctor =
        StringLit () ("_Tuple" ++ show (length types))

    convert n t =
        ( prop ('_':show n)
        , toType t (BracketRef () x (IntLit () n))
        )


-- OUTBOUND
toTuple types x =
    check x JSArray (ObjectLit () fields)
  where
    fields =
        (prop "ctor", ctor) : zipWith convert [0..] types

    ctor =
        StringLit () ("_Tuple" ++ show (length types))

    convert n t =
        ( prop ('_':show n)
        , toType t (BracketRef () x (IntLit () n))
        )


-- OUTBOUND