( (library "alterto.yql") (import alterto_module '"alterto.yql") (let config (DataSource 'config)) ### Tuple (let srcType (VariantType (TupleType (DataType 'Int32) (DataType 'String)))) (let targetType (VariantType (TupleType (DataType 'Uint8) (DataType 'Utf8)))) (let failValue (Variant (Utf8 '"not converted") '1 targetType)) # Variant> -> Variant> (let value (Variant (String 'one) '1 srcType)) (let world (Apply (bind alterto_module 'doAlterTo) world value targetType failValue)) # Variant> -> Variant> (fail) (let value (Variant (String '"garbage\xff") '1 srcType)) (let world (Apply (bind alterto_module 'doAlterTo) world value targetType failValue)) ### Struct (let srcType (VariantType (StructType '('a (DataType 'Int32)) '('b (DataType 'String))))) (let targetType (VariantType (StructType '('a (DataType 'Uint8)) '('b (DataType 'Utf8))))) (let failValue (Variant (Uint8 '123) 'a targetType)) # Variant> -> Variant> (let value (Variant (Int32 '1) 'a srcType)) (let world (Apply (bind alterto_module 'doAlterTo) world value targetType failValue)) # Variant> -> Variant> (fail) (let value (Variant (Int32 '"-1") 'a srcType)) (let world (Apply (bind alterto_module 'doAlterTo) world value targetType failValue)) (return world) )