SafeCastOverNull.yqls 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. (
  2. (let config (DataSource 'config))
  3. (let res_sink (DataSink 'result))
  4. # Null -> Uint16
  5. (let cast (SafeCast (Null) (DataType 'Uint16)))
  6. (let world (Write! world res_sink (Key) cast '('('type))))
  7. # Null -> Uint16?
  8. (let cast (SafeCast (Null) (OptionalType (DataType 'Uint16))))
  9. (let world (Write! world res_sink (Key) cast '('('type))))
  10. # Just(Null) -> Null
  11. (let cast (SafeCast (Just (Null)) (NullType)))
  12. (let world (Write! world res_sink (Key) cast '('('type))))
  13. # Nothing(Null?) -> Null
  14. (let cast (SafeCast (Nothing (OptionalType (NullType))) (NullType)))
  15. (let world (Write! world res_sink (Key) cast '('('type))))
  16. # Uint16 -> Null
  17. (let cast (SafeCast (Uint16 '0) (NullType)))
  18. (let world (Write! world res_sink (Key) cast '('('type))))
  19. # Nothing(Uint16?) -> Null
  20. (let cast (SafeCast (Nothing (OptionalType (DataType 'Uint16))) (NullType)))
  21. (let world (Write! world res_sink (Key) cast '('('type))))
  22. # Null -> Null?
  23. (let cast (SafeCast (Null) (OptionalType (NullType))))
  24. (let world (Write! world res_sink (Key) cast '('('type))))
  25. (let world (Commit! world res_sink))
  26. (return world)
  27. )