NamedApply.yqls 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. (
  2. #comment
  3. (let config (DataSource 'config))
  4. (let res_sink (DataSink 'result))
  5. (let f1 (lambda '(x y) (block '(
  6. (return (+ x (Coalesce y (Uint32 '100))))
  7. ))))
  8. (let f1dep (lambda '(x dep) (block '(
  9. (return (+ x x))
  10. ))))
  11. (let tuple (lambda '() '((Uint32 '1) (Uint32 '2))))
  12. (let tuple_ctype (CallableType '() '((TupleType (DataType 'Uint32) (DataType 'Uint32)))))
  13. (let tuple_call (Callable tuple_ctype tuple))
  14. (let ctype (CallableType '() '((DataType 'Uint32)) '((DataType 'Uint32) 'Arg1) '((DataType 'Uint32) 'Arg2)))
  15. (let call (Callable ctype f1))
  16. (let optTuple1 (lambda '() '((Uint32 '1) (Just (Uint32 '2)))))
  17. (let optTuple2 (lambda '() '((Uint32 '1) (Nothing (OptionalType (DataType 'Uint32))))))
  18. (let optCtype (CallableType '('1)
  19. '((DataType 'Uint32))
  20. '((DataType 'Uint32) 'Arg1)
  21. '((OptionalType (DataType 'Uint32)) 'Arg2)))
  22. (let optCall (Callable optCtype f1))
  23. (let s1 (AsStruct '('Arg2 (Uint32 '2)) '('Arg1 (Uint32 '1))))
  24. (let strType (CallableType '() '((TypeOf s1))))
  25. (let strCall (Callable strType (lambda '() s1)))
  26. # lambdas
  27. (let world (Write! world res_sink (Key) (NamedApply f1 '((Uint32 '1) (Uint32 '2)) (AsStruct)) '('('type))))
  28. (let world (Write! world res_sink (Key) (NamedApply f1dep '((Uint32 '1)) (AsStruct) (DependsOn (Uint32 '2))) '('('type))))
  29. # callables
  30. (let world (Write! world res_sink (Key) (NamedApply call '((Uint32 '1) (Uint32 '2)) (AsStruct)) '('('type))))
  31. (let world (Write! world res_sink (Key) (NamedApply call (Apply tuple_call) (AsStruct)) '('('type))))
  32. # opt. positional
  33. (let world (Write! world res_sink (Key) (NamedApply optCall '((Uint32 '1) (Uint32 '2)) (AsStruct)) '('('type))))
  34. (let world (Write! world res_sink (Key) (NamedApply optCall (Apply optTuple1) (AsStruct)) '('('type))))
  35. (let world (Write! world res_sink (Key) (NamedApply optCall (Apply optTuple2) (AsStruct)) '('('type))))
  36. (let world (Write! world res_sink (Key) (NamedApply optCall '((Uint32 '1)) (AsStruct)) '('('type))))
  37. # named
  38. (let world (Write! world res_sink (Key) (NamedApply call '((Uint32 '1)) (AsStruct
  39. '('Arg2 (Uint32 '2))
  40. )) '('('type))))
  41. (let world (Write! world res_sink (Key) (NamedApply call '() (AsStruct
  42. '('Arg2 (Uint32 '2)) '('Arg1 (Uint32 '1))
  43. )) '('('type))))
  44. (let world (Write! world res_sink (Key) (NamedApply call '() (Apply strCall)) '('('type))))
  45. #opt. named
  46. (let world (Write! world res_sink (Key) (NamedApply optCall '() (AsStruct
  47. '('Arg1 (Uint32 '1))
  48. )) '('('type))))
  49. (let world (Commit! world res_sink))
  50. (return world)
  51. )