blob: 33421380cb57bc51f66a5b335f979b0ff4fc92fb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
(
(let config (DataSource 'config))
(let world (Configure! world config 'PureDataSource 'yt))
(let res_sink (DataSink 'result))
(let targetType (TupleType (DataType 'Uint8) (DataType 'Utf8)))
# (Int32, String) -> (Uint8, Utf8) [good]
(let value '((Int32 '1) (String 'one)))
(let cast (SafeCast value targetType))
(let world (Write! world res_sink (Key) cast '('('type))))
# (Int32, String) -> (Uint8, Utf8)? [null]
(let value '((Int32 '1) (String '"garbage\xff")))
(let cast (SafeCast value targetType))
(let world (Write! world res_sink (Key) cast '('('type))))
# (Int32?, String???) -> (Uint8??, Utf8?)? [good]
(let targetType (TupleType (OptionalType (OptionalType (DataType 'Uint8))) (OptionalType (DataType 'Utf8))))
(let value '((Just (Int32 '1)) (Just (Nothing (OptionalType (DataType 'String))))))
(let cast (SafeCast value targetType))
(let world (Write! world res_sink (Key) cast '('('type))))
# (Int32?, String???) -> (Uint8??, Utf8?)? [null]
(let value '((Just (Int32 '1)) (Nothing (OptionalType (OptionalType (DataType 'String))))))
(let cast (SafeCast value targetType))
(let world (Write! world res_sink (Key) cast '('('type))))
# (Int32?, String???) -> (Uint8??, Utf8?)? [null]
(let value '((Just (Int32 '-1)) (Just (Nothing (OptionalType (DataType 'String))))))
(let cast (SafeCast value targetType))
(let world (Write! world res_sink (Key) cast '('('type))))
(let world (Commit! world res_sink))
(return world)
)
|