@glutinum/cli 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (273) hide show
  1. package/README.md +19 -1
  2. package/dist/Glutinum.Converter/Abbreviations.js +246 -0
  3. package/dist/Glutinum.Converter/FsharpAST.js +87 -28
  4. package/dist/Glutinum.Converter/Generate.js +55 -8
  5. package/dist/Glutinum.Converter/GlueAST.js +333 -34
  6. package/dist/Glutinum.Converter/Log.js +7 -8
  7. package/dist/Glutinum.Converter/Merge.js +683 -31
  8. package/dist/Glutinum.Converter/Packages.js +308 -0
  9. package/dist/Glutinum.Converter/Printer.js +323 -186
  10. package/dist/Glutinum.Converter/Read.js +279 -6
  11. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +13 -7
  12. package/dist/Glutinum.Converter/Reader/Declaration.js +102 -17
  13. package/dist/Glutinum.Converter/Reader/Documentation.js +168 -73
  14. package/dist/Glutinum.Converter/Reader/EnumDeclaration.js +7 -51
  15. package/dist/Glutinum.Converter/Reader/ExportAssignment.js +64 -15
  16. package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +165 -0
  17. package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +30 -5
  18. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +122 -4
  19. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +83 -7
  20. package/dist/Glutinum.Converter/Reader/MappedTypeNode.js +8 -8
  21. package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js +11 -9
  22. package/dist/Glutinum.Converter/Reader/NamedTupleMember.js +3 -2
  23. package/dist/Glutinum.Converter/Reader/Node.js +24 -10
  24. package/dist/Glutinum.Converter/Reader/Parameters.js +110 -7
  25. package/dist/Glutinum.Converter/Reader/Report.js +31 -12
  26. package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js +4 -3
  27. package/dist/Glutinum.Converter/Reader/TypeNode.js +1524 -253
  28. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +75 -20
  29. package/dist/Glutinum.Converter/Reader/TypeParameters.js +8 -5
  30. package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +184 -50
  31. package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +32 -13
  32. package/dist/Glutinum.Converter/Reader/Types.js +180 -0
  33. package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +99 -43
  34. package/dist/Glutinum.Converter/Reader/Utils.js +1143 -55
  35. package/dist/Glutinum.Converter/Reader/VariableStatement.js +59 -14
  36. package/dist/Glutinum.Converter/Transform.js +8292 -1119
  37. package/dist/Glutinum.Converter/TypeScript.Extensions.js +3 -3
  38. package/dist/Glutinum.Converter/TypeScript.js +3 -3
  39. package/dist/Glutinum.Converter/Utils/Keywords.js +6 -6
  40. package/dist/Glutinum.Converter/Utils/List.js +3 -3
  41. package/dist/Glutinum.Converter/Utils/Naming.js +61 -12
  42. package/dist/Glutinum.Converter/Utils/String.js +7 -3
  43. package/dist/Program.js +230 -72
  44. package/package.json +4 -4
  45. package/src/Glutinum.Converter/js/bootstrap.js +109 -2
  46. package/src/Glutinum.Converter/js/host.js +144 -0
  47. package/src/Glutinum.Converter/js/npm.js +137 -0
  48. package/src/Glutinum.Converter/js/resolve.js +402 -0
  49. package/dist/Glutinum.Converter/FsharpAST.js.map +0 -1
  50. package/dist/Glutinum.Converter/Generate.js.map +0 -1
  51. package/dist/Glutinum.Converter/GlueAST.js.map +0 -1
  52. package/dist/Glutinum.Converter/Log.js.map +0 -1
  53. package/dist/Glutinum.Converter/Merge.js.map +0 -1
  54. package/dist/Glutinum.Converter/Printer.js.map +0 -1
  55. package/dist/Glutinum.Converter/Read.js.map +0 -1
  56. package/dist/Glutinum.Converter/Reader/ClassDeclaration.js.map +0 -1
  57. package/dist/Glutinum.Converter/Reader/Declaration.js.map +0 -1
  58. package/dist/Glutinum.Converter/Reader/Documentation.js.map +0 -1
  59. package/dist/Glutinum.Converter/Reader/EnumDeclaration.js.map +0 -1
  60. package/dist/Glutinum.Converter/Reader/ExportAssignment.js.map +0 -1
  61. package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js.map +0 -1
  62. package/dist/Glutinum.Converter/Reader/IndexedAccessType.js.map +0 -1
  63. package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js.map +0 -1
  64. package/dist/Glutinum.Converter/Reader/MappedTypeNode.js.map +0 -1
  65. package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js.map +0 -1
  66. package/dist/Glutinum.Converter/Reader/NamedTupleMember.js.map +0 -1
  67. package/dist/Glutinum.Converter/Reader/Node.js.map +0 -1
  68. package/dist/Glutinum.Converter/Reader/Parameters.js.map +0 -1
  69. package/dist/Glutinum.Converter/Reader/Report.js.map +0 -1
  70. package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js.map +0 -1
  71. package/dist/Glutinum.Converter/Reader/TypeNode.js.map +0 -1
  72. package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js.map +0 -1
  73. package/dist/Glutinum.Converter/Reader/TypeParameters.js.map +0 -1
  74. package/dist/Glutinum.Converter/Reader/TypeQueryNode.js.map +0 -1
  75. package/dist/Glutinum.Converter/Reader/TypeScriptReader.js.map +0 -1
  76. package/dist/Glutinum.Converter/Reader/UnionTypeNode.js.map +0 -1
  77. package/dist/Glutinum.Converter/Reader/Utils.js.map +0 -1
  78. package/dist/Glutinum.Converter/Reader/VariableStatement.js.map +0 -1
  79. package/dist/Glutinum.Converter/Transform.js.map +0 -1
  80. package/dist/Glutinum.Converter/TypeScript.Extensions.js.map +0 -1
  81. package/dist/Glutinum.Converter/TypeScript.js.map +0 -1
  82. package/dist/Glutinum.Converter/Utils/Keywords.js.map +0 -1
  83. package/dist/Glutinum.Converter/Utils/List.js.map +0 -1
  84. package/dist/Glutinum.Converter/Utils/Naming.js.map +0 -1
  85. package/dist/Glutinum.Converter/Utils/String.js.map +0 -1
  86. package/dist/Program.js.map +0 -1
  87. package/dist/fable_modules/Fable.Promise.3.2.0/AsyncIterable.fs +0 -57
  88. package/dist/fable_modules/Fable.Promise.3.2.0/AsyncIterable.fs.js +0 -105
  89. package/dist/fable_modules/Fable.Promise.3.2.0/AsyncIterable.fs.js.map +0 -1
  90. package/dist/fable_modules/Fable.Promise.3.2.0/Fable.Promise.fableproj +0 -20
  91. package/dist/fable_modules/Fable.Promise.3.2.0/Promise.fs +0 -766
  92. package/dist/fable_modules/Fable.Promise.3.2.0/Promise.fs.js +0 -218
  93. package/dist/fable_modules/Fable.Promise.3.2.0/Promise.fs.js.map +0 -1
  94. package/dist/fable_modules/Fable.Promise.3.2.0/PromiseImpl.fs +0 -31
  95. package/dist/fable_modules/Fable.Promise.3.2.0/PromiseImpl.fs.js +0 -20
  96. package/dist/fable_modules/Fable.Promise.3.2.0/PromiseImpl.fs.js.map +0 -1
  97. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AssemblyInfo.fs +0 -19
  98. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Async.fs +0 -207
  99. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Async.fs.js +0 -127
  100. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Async.fs.js.map +0 -1
  101. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncOption.fs +0 -81
  102. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncOptionCE.fs +0 -183
  103. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncOptionCE.fs.js +0 -37
  104. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncOptionCE.fs.js.map +0 -1
  105. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncOptionOp.fs +0 -24
  106. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResult.fs +0 -439
  107. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultCE.fs +0 -217
  108. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultCE.fs.js +0 -18
  109. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultCE.fs.js.map +0 -1
  110. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultOp.fs +0 -24
  111. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultOption.fs +0 -75
  112. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultOption.fs.js +0 -26
  113. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultOption.fs.js.map +0 -1
  114. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultOptionCE.fs +0 -238
  115. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultOptionCE.fs.js +0 -18
  116. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultOptionCE.fs.js.map +0 -1
  117. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncResultOptionOp.fs +0 -24
  118. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncValidation.fs +0 -190
  119. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncValidationCE.fs +0 -194
  120. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncValidationCE.fs.js +0 -18
  121. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncValidationCE.fs.js.map +0 -1
  122. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/AsyncValidationOp.fs +0 -35
  123. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/FsToolkit.ErrorHandling.fableproj +0 -51
  124. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/List.fs +0 -218
  125. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/List.fs.js +0 -358
  126. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/List.fs.js.map +0 -1
  127. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Option.fs +0 -331
  128. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/OptionCE.fs +0 -186
  129. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/OptionCE.fs.js +0 -18
  130. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/OptionCE.fs.js.map +0 -1
  131. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/OptionOp.fs +0 -21
  132. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Result.fs +0 -644
  133. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Result.fs.js +0 -45
  134. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Result.fs.js.map +0 -1
  135. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultCE.fs +0 -155
  136. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultCE.fs.js +0 -23
  137. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultCE.fs.js.map +0 -1
  138. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultOp.fs +0 -45
  139. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultOption.fs +0 -201
  140. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultOption.fs.js +0 -65
  141. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultOption.fs.js.map +0 -1
  142. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultOptionCE.fs +0 -146
  143. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultOptionCE.fs.js +0 -18
  144. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultOptionCE.fs.js.map +0 -1
  145. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ResultOptionOp.fs +0 -57
  146. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Seq.fs +0 -19
  147. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Seq.fs.js +0 -31
  148. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Seq.fs.js.map +0 -1
  149. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Shims.fs +0 -22
  150. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Shims.fs.js +0 -18
  151. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Shims.fs.js.map +0 -1
  152. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/Validation.fs +0 -172
  153. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ValidationCE.fs +0 -148
  154. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ValidationCE.fs.js +0 -18
  155. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ValidationCE.fs.js.map +0 -1
  156. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ValidationOp.fs +0 -35
  157. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ValueOption.fs +0 -151
  158. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/ValueOptionCE.fs +0 -165
  159. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/obj/Debug/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +0 -3
  160. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/obj/Debug/netstandard2.1/FsToolkit.ErrorHandling.AssemblyInfo.fs +0 -20
  161. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/obj/Release/netstandard2.0/.NETStandard,Version=v2.0.AssemblyAttributes.fs +0 -3
  162. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/obj/Release/netstandard2.0/FsToolkit.ErrorHandling.AssemblyInfo.fs +0 -20
  163. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/obj/Release/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +0 -3
  164. package/dist/fable_modules/FsToolkit.ErrorHandling.4.16.0/obj/Release/netstandard2.1/FsToolkit.ErrorHandling.AssemblyInfo.fs +0 -20
  165. package/dist/fable_modules/fable-library-js.4.14.0/Array.d.ts +0 -123
  166. package/dist/fable_modules/fable-library-js.4.14.0/Array.js +0 -1242
  167. package/dist/fable_modules/fable-library-js.4.14.0/Async.d.ts +0 -32
  168. package/dist/fable_modules/fable-library-js.4.14.0/Async.js +0 -158
  169. package/dist/fable_modules/fable-library-js.4.14.0/AsyncBuilder.d.ts +0 -59
  170. package/dist/fable_modules/fable-library-js.4.14.0/AsyncBuilder.js +0 -183
  171. package/dist/fable_modules/fable-library-js.4.14.0/BigInt.d.ts +0 -115
  172. package/dist/fable_modules/fable-library-js.4.14.0/BigInt.js +0 -282
  173. package/dist/fable_modules/fable-library-js.4.14.0/BitConverter.d.ts +0 -27
  174. package/dist/fable_modules/fable-library-js.4.14.0/BitConverter.js +0 -138
  175. package/dist/fable_modules/fable-library-js.4.14.0/Boolean.d.ts +0 -3
  176. package/dist/fable_modules/fable-library-js.4.14.0/Boolean.js +0 -21
  177. package/dist/fable_modules/fable-library-js.4.14.0/CHANGELOG.md +0 -37
  178. package/dist/fable_modules/fable-library-js.4.14.0/Char.d.ts +0 -65
  179. package/dist/fable_modules/fable-library-js.4.14.0/Char.js +0 -169
  180. package/dist/fable_modules/fable-library-js.4.14.0/Choice.d.ts +0 -121
  181. package/dist/fable_modules/fable-library-js.4.14.0/Choice.js +0 -184
  182. package/dist/fable_modules/fable-library-js.4.14.0/Date.d.ts +0 -70
  183. package/dist/fable_modules/fable-library-js.4.14.0/Date.js +0 -749
  184. package/dist/fable_modules/fable-library-js.4.14.0/DateOffset.d.ts +0 -63
  185. package/dist/fable_modules/fable-library-js.4.14.0/DateOffset.js +0 -268
  186. package/dist/fable_modules/fable-library-js.4.14.0/DateOnly.d.ts +0 -18
  187. package/dist/fable_modules/fable-library-js.4.14.0/DateOnly.js +0 -124
  188. package/dist/fable_modules/fable-library-js.4.14.0/Decimal.d.ts +0 -45
  189. package/dist/fable_modules/fable-library-js.4.14.0/Decimal.js +0 -212
  190. package/dist/fable_modules/fable-library-js.4.14.0/Double.d.ts +0 -11
  191. package/dist/fable_modules/fable-library-js.4.14.0/Double.js +0 -46
  192. package/dist/fable_modules/fable-library-js.4.14.0/Encoding.d.ts +0 -12
  193. package/dist/fable_modules/fable-library-js.4.14.0/Encoding.js +0 -173
  194. package/dist/fable_modules/fable-library-js.4.14.0/Event.d.ts +0 -31
  195. package/dist/fable_modules/fable-library-js.4.14.0/Event.js +0 -93
  196. package/dist/fable_modules/fable-library-js.4.14.0/FSharp.Collections.d.ts +0 -7
  197. package/dist/fable_modules/fable-library-js.4.14.0/FSharp.Collections.js +0 -27
  198. package/dist/fable_modules/fable-library-js.4.14.0/FSharp.Core.CompilerServices.d.ts +0 -12
  199. package/dist/fable_modules/fable-library-js.4.14.0/FSharp.Core.CompilerServices.js +0 -27
  200. package/dist/fable_modules/fable-library-js.4.14.0/FSharp.Core.d.ts +0 -17
  201. package/dist/fable_modules/fable-library-js.4.14.0/FSharp.Core.js +0 -69
  202. package/dist/fable_modules/fable-library-js.4.14.0/Global.d.ts +0 -24
  203. package/dist/fable_modules/fable-library-js.4.14.0/Global.js +0 -8
  204. package/dist/fable_modules/fable-library-js.4.14.0/Guid.d.ts +0 -10
  205. package/dist/fable_modules/fable-library-js.4.14.0/Guid.js +0 -142
  206. package/dist/fable_modules/fable-library-js.4.14.0/Int32.d.ts +0 -28
  207. package/dist/fable_modules/fable-library-js.4.14.0/Int32.js +0 -135
  208. package/dist/fable_modules/fable-library-js.4.14.0/List.d.ts +0 -143
  209. package/dist/fable_modules/fable-library-js.4.14.0/List.js +0 -1273
  210. package/dist/fable_modules/fable-library-js.4.14.0/Long.d.ts +0 -3
  211. package/dist/fable_modules/fable-library-js.4.14.0/Long.js +0 -46
  212. package/dist/fable_modules/fable-library-js.4.14.0/MailboxProcessor.d.ts +0 -25
  213. package/dist/fable_modules/fable-library-js.4.14.0/MailboxProcessor.js +0 -93
  214. package/dist/fable_modules/fable-library-js.4.14.0/Map.d.ts +0 -178
  215. package/dist/fable_modules/fable-library-js.4.14.0/Map.js +0 -1396
  216. package/dist/fable_modules/fable-library-js.4.14.0/MapUtil.d.ts +0 -10
  217. package/dist/fable_modules/fable-library-js.4.14.0/MapUtil.js +0 -112
  218. package/dist/fable_modules/fable-library-js.4.14.0/MutableMap.d.ts +0 -52
  219. package/dist/fable_modules/fable-library-js.4.14.0/MutableMap.js +0 -327
  220. package/dist/fable_modules/fable-library-js.4.14.0/MutableSet.d.ts +0 -39
  221. package/dist/fable_modules/fable-library-js.4.14.0/MutableSet.js +0 -233
  222. package/dist/fable_modules/fable-library-js.4.14.0/Native.d.ts +0 -2
  223. package/dist/fable_modules/fable-library-js.4.14.0/Native.js +0 -8
  224. package/dist/fable_modules/fable-library-js.4.14.0/Numeric.d.ts +0 -19
  225. package/dist/fable_modules/fable-library-js.4.14.0/Numeric.js +0 -71
  226. package/dist/fable_modules/fable-library-js.4.14.0/Observable.d.ts +0 -32
  227. package/dist/fable_modules/fable-library-js.4.14.0/Observable.js +0 -113
  228. package/dist/fable_modules/fable-library-js.4.14.0/Option.d.ts +0 -28
  229. package/dist/fable_modules/fable-library-js.4.14.0/Option.js +0 -96
  230. package/dist/fable_modules/fable-library-js.4.14.0/README.md +0 -3
  231. package/dist/fable_modules/fable-library-js.4.14.0/Random.d.ts +0 -37
  232. package/dist/fable_modules/fable-library-js.4.14.0/Random.js +0 -170
  233. package/dist/fable_modules/fable-library-js.4.14.0/Range.d.ts +0 -12
  234. package/dist/fable_modules/fable-library-js.4.14.0/Range.js +0 -45
  235. package/dist/fable_modules/fable-library-js.4.14.0/Reflection.d.ts +0 -119
  236. package/dist/fable_modules/fable-library-js.4.14.0/Reflection.js +0 -461
  237. package/dist/fable_modules/fable-library-js.4.14.0/RegExp.d.ts +0 -10
  238. package/dist/fable_modules/fable-library-js.4.14.0/RegExp.js +0 -132
  239. package/dist/fable_modules/fable-library-js.4.14.0/Result.d.ts +0 -37
  240. package/dist/fable_modules/fable-library-js.4.14.0/Result.js +0 -165
  241. package/dist/fable_modules/fable-library-js.4.14.0/Seq.d.ts +0 -165
  242. package/dist/fable_modules/fable-library-js.4.14.0/Seq.js +0 -1379
  243. package/dist/fable_modules/fable-library-js.4.14.0/Seq2.d.ts +0 -18
  244. package/dist/fable_modules/fable-library-js.4.14.0/Seq2.js +0 -111
  245. package/dist/fable_modules/fable-library-js.4.14.0/Set.d.ts +0 -190
  246. package/dist/fable_modules/fable-library-js.4.14.0/Set.js +0 -1789
  247. package/dist/fable_modules/fable-library-js.4.14.0/String.d.ts +0 -50
  248. package/dist/fable_modules/fable-library-js.4.14.0/String.js +0 -543
  249. package/dist/fable_modules/fable-library-js.4.14.0/System.Collections.Generic.d.ts +0 -79
  250. package/dist/fable_modules/fable-library-js.4.14.0/System.Collections.Generic.js +0 -317
  251. package/dist/fable_modules/fable-library-js.4.14.0/System.Text.d.ts +0 -38
  252. package/dist/fable_modules/fable-library-js.4.14.0/System.Text.js +0 -162
  253. package/dist/fable_modules/fable-library-js.4.14.0/SystemException.d.ts +0 -5
  254. package/dist/fable_modules/fable-library-js.4.14.0/SystemException.js +0 -5
  255. package/dist/fable_modules/fable-library-js.4.14.0/TimeOnly.d.ts +0 -15
  256. package/dist/fable_modules/fable-library-js.4.14.0/TimeOnly.js +0 -122
  257. package/dist/fable_modules/fable-library-js.4.14.0/TimeSpan.d.ts +0 -34
  258. package/dist/fable_modules/fable-library-js.4.14.0/TimeSpan.js +0 -177
  259. package/dist/fable_modules/fable-library-js.4.14.0/Timer.d.ts +0 -19
  260. package/dist/fable_modules/fable-library-js.4.14.0/Timer.js +0 -67
  261. package/dist/fable_modules/fable-library-js.4.14.0/Types.d.ts +0 -58
  262. package/dist/fable_modules/fable-library-js.4.14.0/Types.js +0 -208
  263. package/dist/fable_modules/fable-library-js.4.14.0/Unicode.13.0.0.d.ts +0 -2
  264. package/dist/fable_modules/fable-library-js.4.14.0/Unicode.13.0.0.js +0 -4
  265. package/dist/fable_modules/fable-library-js.4.14.0/Uri.d.ts +0 -29
  266. package/dist/fable_modules/fable-library-js.4.14.0/Uri.js +0 -142
  267. package/dist/fable_modules/fable-library-js.4.14.0/Util.d.ts +0 -207
  268. package/dist/fable_modules/fable-library-js.4.14.0/Util.js +0 -770
  269. package/dist/fable_modules/fable-library-js.4.14.0/big.d.ts +0 -338
  270. package/dist/fable_modules/fable-library-js.4.14.0/lib/big.d.ts +0 -5
  271. package/dist/fable_modules/fable-library-js.4.14.0/lib/big.js +0 -826
  272. package/dist/fable_modules/fable-library-js.4.14.0/package.json +0 -24
  273. package/dist/fable_modules/project_cracked.json +0 -1
@@ -1,644 +0,0 @@
1
- namespace FsToolkit.ErrorHandling
2
-
3
- /// <summary>
4
- /// Helper functions for working with <c>Result</c> values.
5
- /// </summary>
6
- [<RequireQualifiedAccess>]
7
- module Result =
8
-
9
- /// <summary>
10
- /// Applies a transformation to the value of a <c>Result</c> to a new value using the specified mapper function.
11
- ///
12
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/map</href>
13
- /// </summary>
14
- /// <param name="mapper">The function to apply to the value of the <c>Result</c> if it is <c>Ok</c>.</param>
15
- /// <param name="input">The <c>Result</c> to map.</param>
16
- /// <returns>A new <c>Result</c>with the mapped value if the input <c>Result</c> is <c>Ok</c>, otherwise the original <c>Error</c>.</returns>
17
- let inline map
18
- ([<InlineIfLambda>] mapper: 'okInput -> 'okOutput)
19
- (input: Result<'okInput, 'error>)
20
- : Result<'okOutput, 'error> =
21
- match input with
22
- | Ok x -> Ok(mapper x)
23
- | Error e -> Error e
24
-
25
- /// <summary>
26
- /// Maps the error value of a <c>Result</c>to a new error value using the specified error mapper function.
27
- ///
28
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/maperror</href>
29
- /// </summary>
30
- /// <param name="errorMapper">The function that maps the input error value to the output error value.</param>
31
- /// <param name="input">The <c>Result</c>value to map the error value of.</param>
32
- /// <returns>A new <c>Result</c>with the same Ok value and the mapped error value.</returns>
33
- let inline mapError
34
- ([<InlineIfLambda>] errorMapper: 'errorInput -> 'errorOutput)
35
- (input: Result<'ok, 'errorInput>)
36
- : Result<'ok, 'errorOutput> =
37
- match input with
38
- | Ok x -> Ok x
39
- | Error e -> Error(errorMapper e)
40
-
41
- /// <summary>
42
- /// Takes a transformation function and applies it to the <c>Result</c> if it is <c>Ok</c>.
43
- ///
44
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/bind</href>
45
- /// </summary>
46
- /// <param name="binder">The transformation function</param>
47
- /// <param name="input">The input result</param>
48
- /// <typeparam name="'okInput">The type of the successful result.</typeparam>
49
- /// <typeparam name="'okOutput">The type of the result after binding.</typeparam>
50
- /// <typeparam name="'error">The type of the error.</typeparam>
51
- /// <returns>Returns a new <c>Result</c> if the input is <c>Ok</c>, otherwise returns the original <c>Result</c></returns>
52
- let inline bind
53
- ([<InlineIfLambda>] binder: 'okInput -> Result<'okOutput, 'error>)
54
- (input: Result<'okInput, 'error>)
55
- : Result<'okOutput, 'error> =
56
- match input with
57
- | Ok x -> binder x
58
- | Error e -> Error e
59
-
60
- /// <summary>
61
- /// Determines whether the specified <c>Result</c> is in a successful state.
62
- ///
63
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/others#isok</href>
64
- /// </summary>
65
- /// <param name="value">The result to check.</param>
66
- /// <returns>True if the result is in a successful state; otherwise, false.</returns>
67
- let inline isOk (value: Result<'ok, 'error>) : bool =
68
- match value with
69
- | Ok _ -> true
70
- | Error _ -> false
71
-
72
- /// <summary>
73
- /// Determines whether the specified <c>Result</c> is an error.
74
- ///
75
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/others#iserror</href>
76
- /// </summary>
77
- /// <param name="value">The result to check.</param>
78
- /// <returns>True if the result is an error; otherwise, false.</returns>
79
- let inline isError (value: Result<'ok, 'error>) : bool =
80
- match value with
81
- | Ok _ -> false
82
- | Error _ -> true
83
-
84
- /// <summary>
85
- /// Applies the appropriate function based on the result of the input.
86
- ///
87
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/eitherfunctions#result.either</href>
88
- /// </summary>
89
- /// <param name="onOk">The function to apply if the input is <c>Ok</c></param>
90
- /// <param name="onError">The function to apply if the input is <c>Error</c></param>
91
- /// <param name="input">The input result</param>
92
- /// <returns>The result of applying the appropriate function.</returns>
93
- let inline either
94
- ([<InlineIfLambda>] onOk: 'okInput -> 'output)
95
- ([<InlineIfLambda>] onError: 'errorInput -> 'output)
96
- (input: Result<'okInput, 'errorInput>)
97
- : 'output =
98
- match input with
99
- | Ok x -> onOk x
100
- | Error err -> onError err
101
-
102
- /// <summary>
103
- /// Maps the values of a Result to a new Result using the provided functions.
104
- ///
105
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/eitherfunctions#result.eithermap</href>
106
- /// </summary>
107
- /// <param name="onOk">The function to apply to the 'ok' value of the input Result.</param>
108
- /// <param name="onError">The function to apply to the 'error' value of the input Result.</param>
109
- /// <param name="input">The input <c>Result</c>to map.</param>
110
- /// <returns>A new Result with the mapped values.</returns>
111
- let inline eitherMap
112
- ([<InlineIfLambda>] onOk: 'okInput -> 'okOutput)
113
- ([<InlineIfLambda>] onError: 'errorInput -> 'errorOutput)
114
- (input: Result<'okInput, 'errorInput>)
115
- : Result<'okOutput, 'errorOutput> =
116
- match input with
117
- | Ok x -> Ok(onOk x)
118
- | Error err -> Error(onError err)
119
-
120
- /// <summary>
121
- /// Applies a function to the value within a <c>Result</c> and returns a new <c>Result</c> with the output of the function.
122
- ///
123
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/apply</href>
124
- /// </summary>
125
- /// <param name="applier">The <c>Result</c>containing the function to apply.</param>
126
- /// <param name="input">The <c>Result</c>containing the input to apply the function to.</param>
127
- /// <returns>A <c>Result</c>containing the output of applying the function to the input, or an <c>Error</c> if either <c>Result</c>is an <c>Error</c></returns>
128
- let inline apply
129
- (applier: Result<'okInput -> 'okOutput, 'error>)
130
- (input: Result<'okInput, 'error>)
131
- : Result<'okOutput, 'error> =
132
- match (applier, input) with
133
- | Ok f, Ok x -> Ok(f x)
134
- | Error e, _
135
- | _, Error e -> Error e
136
-
137
- /// <summary>
138
- /// Applies a mapper function to two input Results, producing a new <c>Result</c>.
139
- ///
140
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/map2</href>
141
- /// </summary>
142
- /// <param name="mapper">The function to apply to the inputs.</param>
143
- /// <param name="input1">The first input Result.</param>
144
- /// <param name="input2">The second input Result.</param>
145
- /// <returns>A new <c>Result</c>containing the output of the mapper function if both input Results are Ok, otherwise an Error Result.</returns>
146
- let inline map2
147
- ([<InlineIfLambda>] mapper: 'okInput1 -> 'okInput2 -> 'okOutput)
148
- (input1: Result<'okInput1, 'error>)
149
- (input2: Result<'okInput2, 'error>)
150
- : Result<'okOutput, 'error> =
151
- match (input1, input2) with
152
- | Ok x, Ok y -> Ok(mapper x y)
153
- | Error e, _
154
- | _, Error e -> Error e
155
-
156
- /// <summary>
157
- /// Applies a mapper function to three input Results, producing a new <c>Result</c>.
158
- ///
159
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/map3</href>
160
- /// </summary>
161
- /// <param name="mapper">The function to apply to the input results.</param>
162
- /// <param name="input1">The first input result.</param>
163
- /// <param name="input2">The second input result.</param>
164
- /// <param name="input3">The third input result.</param>
165
- /// <returns>A new <c>Result</c> with the output of the mapper function applied to the input results, if all Results are <c>Ok</c>, otherwise returns the original <c>Error</c></returns>
166
- let inline map3
167
- ([<InlineIfLambda>] mapper: 'okInput1 -> 'okInput2 -> 'okInput3 -> 'okOutput)
168
- (input1: Result<'okInput1, 'error>)
169
- (input2: Result<'okInput2, 'error>)
170
- (input3: Result<'okInput3, 'error>)
171
- : Result<'okOutput, 'error> =
172
- match (input1, input2, input3) with
173
- | Ok x, Ok y, Ok z -> Ok(mapper x y z)
174
- | Error e, _, _
175
- | _, Error e, _
176
- | _, _, Error e -> Error e
177
-
178
- /// <summary>
179
- /// Converts a <c>Choice</c> to a <c>Result</c>
180
- ///
181
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/transforms/ofchoice</href>
182
- /// </summary>
183
- /// <param name="input">The <c>Choice</c> value to convert.</param>
184
- /// <returns>A <c>Result</c> matching the types of the input <c>Choice</c></returns>
185
- let inline ofChoice (input: Choice<'ok, 'error>) : Result<'ok, 'error> =
186
- match input with
187
- | Choice1Of2 x -> Ok x
188
- | Choice2Of2 e -> Error e
189
-
190
- /// <summary>
191
- /// Calls a <c>TryCreate</c> member function on a value passed in, returning a <c>Result</c> containing the value or an error tuple
192
- ///
193
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/trycreate</href>
194
- /// </summary>
195
- /// <param name="fieldName">The name of the field</param>
196
- /// <param name="x">The value to create a result from.</param>
197
- /// <returns>A <c>Result</c> containing the value or an error tuple of the field name and the original error type</returns>
198
- let inline tryCreate (fieldName: string) (x: 'a) : Result< ^b, (string * 'c) > =
199
- let tryCreate' x =
200
- (^b: (static member TryCreate: 'a -> Result< ^b, 'c >) x)
201
-
202
- tryCreate' x
203
- |> mapError (fun z -> (fieldName, z))
204
-
205
- /// <summary>
206
- /// Returns <paramref name="result"/> if it is <c>Ok</c>, otherwise returns <paramref name="ifError"/>
207
- ///
208
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/orelsefunctions#result.orelse</href>
209
- /// </summary>
210
- /// <param name="ifError">The value to use if <paramref name="result"/> is <c>Error</c></param>
211
- /// <param name="result">The input result.</param>
212
- /// <remarks>
213
- /// </remarks>
214
- /// <example>
215
- /// <code>
216
- /// Error ("First") |> Result.orElse (Error ("Second")) // evaluates to Error ("Second")
217
- /// Error ("First") |> Result.orElseWith (Ok ("Second")) // evaluates to Ok ("Second")
218
- /// Ok ("First") |> Result.orElseWith (Error ("Second")) // evaluates to Ok ("First")
219
- /// Ok ("First") |> Result.orElseWith (Ok ("Second")) // evaluates to Ok ("First")
220
- /// </code>
221
- /// </example>
222
- /// <returns>
223
- /// The result if the result is Ok, else returns <paramref name="ifError"/>.
224
- /// </returns>
225
- let inline orElse
226
- (ifError: Result<'ok, 'errorOutput>)
227
- (result: Result<'ok, 'error>)
228
- : Result<'ok, 'errorOutput> =
229
- match result with
230
- | Ok x -> Ok x
231
- | Error _ -> ifError
232
-
233
- /// <summary>
234
- /// Returns <paramref name="result"/> if it is <c>Ok</c>, otherwise executes <paramref name="ifErrorFunc"/> and returns the result.
235
- ///
236
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/orelsefunctions#result.orelsewith</href>
237
- /// </summary>
238
- /// <param name="ifErrorFunc">A function that provides an alternate result when evaluated.</param>
239
- /// <param name="result">The input result.</param>
240
- /// <remarks>
241
- /// <paramref name="ifErrorFunc"/> is not executed unless <paramref name="result"/> is an <c>Error</c>.
242
- /// </remarks>
243
- /// <example>
244
- /// <code>
245
- /// Error ("First") |> Result.orElseWith (fun _ -> Error ("Second")) // evaluates to Error ("Second")
246
- /// Error ("First") |> Result.orElseWith (fun _ -> Ok ("Second")) // evaluates to Ok ("Second")
247
- /// Ok ("First") |> Result.orElseWith (fun _ -> Error ("Second")) // evaluates to Ok ("First")
248
- /// Ok ("First") |> Result.orElseWith (fun _ -> Ok ("Second")) // evaluates to Ok ("First")
249
- /// </code>
250
- /// </example>
251
- /// <returns>
252
- /// The result if the result is Ok, else the result of executing <paramref name="ifErrorFunc"/>.
253
- /// </returns>
254
- let inline orElseWith
255
- ([<InlineIfLambda>] ifErrorFunc: 'error -> Result<'ok, 'errorOutput>)
256
- (result: Result<'ok, 'error>)
257
- : Result<'ok, 'errorOutput> =
258
- match result with
259
- | Ok x -> Ok x
260
- | Error e -> ifErrorFunc e
261
-
262
- /// <summary>
263
- /// Ignores the value of a <c>Result</c> and returns a new <c>Result</c> with unit as the success value.
264
- ///
265
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/others#ignore</href>
266
- /// </summary>
267
- /// <param name="result">The <c>Result</c> to ignore.</param>
268
- /// <returns>A new <c>Result</c> with unit as the success value.</returns>
269
- let inline ignore<'ok, 'error> (result: Result<'ok, 'error>) : Result<unit, 'error> =
270
- match result with
271
- | Ok _ -> Ok()
272
- | Error e -> Error e
273
-
274
- /// <summary>
275
- /// Requires a boolean value to be true, otherwise returns an error result.
276
- ///
277
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/requirefunctions#requiretrue</href>
278
- /// </summary>
279
- /// <param name="error">The error value to return if the condition is false.</param>
280
- /// <param name="value">The boolean value to check.</param>
281
- /// <returns>An <c>Ok</c> result if the condition is true, otherwise an Error result with the specified error value.</returns>
282
- let inline requireTrue (error: 'error) (value: bool) : Result<unit, 'error> =
283
- if value then Ok() else Error error
284
-
285
- /// <summary>
286
- /// Requires a boolean value to be false, otherwise returns an error result.
287
- ///
288
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/requirefunctions#requirefalse</href>
289
- /// </summary>
290
- /// <param name="error">The error value to return if the condition is true.</param>
291
- /// <param name="value">The boolean value to check.</param>
292
- /// <returns>An <c>Ok</c> result if the condition is false, otherwise an Error result with the specified error value.</returns>
293
- let inline requireFalse (error: 'error) (value: bool) : Result<unit, 'error> =
294
- if not value then Ok() else Error error
295
-
296
- /// <summary>
297
- /// Requires a value to be <c>Some</c>, otherwise returns an error result.
298
- ///
299
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/requirefunctions#requiresome</href>
300
- /// </summary>
301
- /// <param name="error">The error value to return if the value is <c>None</c>.</param>
302
- /// <param name="option">The <c>Option</c> value to check.</param>
303
- /// <returns>An <c>Ok</c> result if the value is <c>Some</c>, otherwise an Error result with the specified error value.</returns>
304
- let inline requireSome (error: 'error) (option: 'ok option) : Result<'ok, 'error> =
305
- match option with
306
- | Some x -> Ok x
307
- | None -> Error error
308
-
309
- /// <summary>
310
- /// Requires a value to be <c>None</c>, otherwise returns an error result.
311
- ///
312
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/requirefunctions#requirenone</href>
313
- /// </summary>
314
- /// <param name="error">The error value to return if the value is <c>Some</c>.</param>
315
- /// <param name="option">The <c>Option</c> value to check.</param>
316
- /// <returns>An <c>Ok</c> result if the value is <c>None</c>, otherwise an Error result with the specified error value.</returns>
317
- let inline requireNone (error: 'error) (option: 'value option) : Result<unit, 'error> =
318
- match option with
319
- | Some _ -> Error error
320
- | None -> Ok()
321
-
322
- /// <summary>
323
- /// Requires a value to be <c>ValueSome</c>, otherwise returns an error result.
324
- ///
325
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/requirefunctions#requirevaluesome</href>
326
- /// </summary>
327
- /// <param name="error">The error value to return if the value is <c>ValueNone</c>.</param>
328
- /// <param name="voption">The <c>ValueOption</c> value to check.</param>
329
- /// <returns>An <c>Ok</c> result if the value is <c>ValueSome</c>, otherwise an <c>Error</c> result with the specified error value.</returns>
330
- let inline requireValueSome (error: 'error) (voption: 'ok voption) : Result<'ok, 'error> =
331
- match voption with
332
- | ValueSome x -> Ok x
333
- | ValueNone -> Error error
334
-
335
- /// <summary>
336
- /// Requires a value to be <c>ValueNone</c>, otherwise returns an error result.
337
- ///
338
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/requirefunctions#requirevaluenone</href>
339
- /// </summary>
340
- /// <param name="error">The error value to return if the value is <c>ValueSome</c>.</param>
341
- /// <param name="voption">The <c>ValueOption</c> value to check.</param>
342
- /// <returns>An <c>Ok</c> result if the value is <c>ValueNone</c>, otherwise an <c>Error</c> result with the specified error value.</returns>
343
- let inline requireValueNone (error: 'error) (voption: 'value voption) : Result<unit, 'error> =
344
- match voption with
345
- | ValueSome _ -> Error error
346
- | ValueNone -> Ok()
347
-
348
- /// <summary>
349
- /// Converts a nullable value into a <c>Result</c>, using the given error if null
350
- ///
351
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/requirefunctions#requirenotnull</href>
352
- /// </summary>
353
- /// <param name="error">The error value to return if the value is null.</param>
354
- /// <param name="value">The nullable value to check.</param>
355
- /// <returns>An <c>Ok</c> result if the value is not null, otherwise an <c>Error</c> result with the specified error value.</returns>
356
- let inline requireNotNull (error: 'error) (value: 'ok) : Result<'ok, 'error> =
357
- match value with
358
- | null -> Error error
359
- | nonnull -> Ok nonnull
360
-
361
- /// <summary>
362
- /// Returns <c>Ok</c> if the two values are equal, or the specified error if not.
363
- /// Same as <c>requireEqual</c>, but with a signature that fits piping better than normal function application.
364
- ///
365
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/requirefunctions#requireequalto</href>
366
- /// </summary>
367
- /// <param name="other">The value to compare to.</param>
368
- /// <param name="error">The error value to return if the values are not equal.</param>
369
- /// <param name="this">The value to compare.</param>
370
- /// <returns>An <c>Ok</c> result if the values are equal, otherwise an <c>Error</c> result with the specified error value.</returns>
371
- let inline requireEqualTo
372
- (other: 'value)
373
- (error: 'error)
374
- (this: 'value)
375
- : Result<unit, 'error> =
376
- if this = other then Ok() else Error error
377
-
378
- /// <summary>
379
- /// Returns <c>Ok</c> if the two values are equal, or the specified error if not.
380
- /// Same as <c>requireEqualTo</c>, but with a signature that fits normal function application better than piping.
381
- ///
382
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/requirefunctions#requireequal</href>
383
- /// </summary>
384
- /// <param name="x1">The first value to compare.</param>
385
- /// <param name="x2">The second value to compare.</param>
386
- /// <param name="error">The error value to return if the values are not equal.</param>
387
- /// <returns>An <c>Ok</c> result if the values are equal, otherwise an <c>Error</c> result with the specified error value.</returns>
388
- let inline requireEqual (x1: 'value) (x2: 'value) (error: 'error) : Result<unit, 'error> =
389
- if x1 = x2 then Ok() else Error error
390
-
391
- /// <summary>
392
- /// Returns <c>Ok</c> if the sequence is empty, or the specified error if not.
393
- ///
394
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/requirefunctions#requireempty</href>
395
- /// </summary>
396
- /// <param name="error">The error value to return if the sequence is not empty.</param>
397
- /// <param name="xs">The sequence to check.</param>
398
- /// <returns>An <c>Ok</c> result if the sequence is empty, otherwise an <c>Error</c> result with the specified error value.</returns>
399
- let inline requireEmpty (error: 'error) (xs: #seq<'value>) : Result<unit, 'error> =
400
- if Seq.isEmpty xs then Ok() else Error error
401
-
402
- /// <summary>
403
- /// Returns <c>Ok</c> if the sequence is not empty, or the specified error if it is.
404
- ///
405
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/requirefunctions#requirenotempty</href>
406
- /// </summary>
407
- /// <param name="error">The error value to return if the sequence is empty.</param>
408
- /// <param name="xs">The sequence to check.</param>
409
- /// <returns>An <c>Ok</c> result if the sequence is not empty, otherwise an <c>Error</c> result with the specified error value.</returns>
410
- let inline requireNotEmpty (error: 'error) (xs: #seq<'value>) : Result<unit, 'error> =
411
- if Seq.isEmpty xs then Error error else Ok()
412
-
413
- /// <summary>
414
- /// Returns the first item of the sequence if it exists, or the specified error if the sequence is empty.
415
- ///
416
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/requirefunctions#requirehead</href>
417
- /// </summary>
418
- /// <param name="error">The error value to return if the sequence is empty.</param>
419
- /// <param name="xs">The sequence to check.</param>
420
- /// <returns>An <c>Ok</c> result containing the first item of the sequence if it exists, otherwise an <c>Error</c> result with the specified error value.</returns>
421
- let inline requireHead (error: 'error) (xs: #seq<'ok>) : Result<'ok, 'error> =
422
- match Seq.tryHead xs with
423
- | Some x -> Ok x
424
- | None -> Error error
425
-
426
- /// <summary>
427
- /// Replaces an error value with a custom error value.
428
- ///
429
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/others#seterror</href>
430
- /// </summary>
431
- /// <param name="error">The error value to replace the original error value with.</param>
432
- /// <param name="result">The input result.</param>
433
- /// <returns>A new <c>Result</c> with the same Ok value and the new error value.</returns>
434
- let inline setError (error: 'error) (result: Result<'ok, 'errorIgnored>) : Result<'ok, 'error> =
435
- result
436
- |> mapError (fun _ -> error)
437
-
438
- /// <summary>
439
- /// Replaces a unit error value with a custom error value. Safer than setError
440
- /// since you're not losing any information.
441
- ///
442
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/others#witherror</href>
443
- /// </summary>
444
- /// <param name="error">The error value to replace the original error value with.</param>
445
- /// <param name="result">The input result.</param>
446
- /// <returns>A new <c>Result</c> with the same Ok value and the new error value.</returns>
447
- let inline withError (error: 'error) (result: Result<'ok, unit>) : Result<'ok, 'error> =
448
- result
449
- |> mapError (fun () -> error)
450
-
451
- /// <summary>
452
- /// Returns the contained value if <c>Ok</c>, otherwise returns the provided value
453
- ///
454
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/others#defaultvalue</href>
455
- /// </summary>
456
- /// <param name="ifError">The value to use if the result is <c>Error</c>.</param>
457
- /// <param name="result">The input result.</param>
458
- /// <returns>The contained value if <c>Ok</c>, otherwise <paramref name="ifError"/>.</returns>
459
- let inline defaultValue (ifError: 'ok) (result: Result<'ok, 'error>) : 'ok =
460
- match result with
461
- | Ok x -> x
462
- | Error _ -> ifError
463
-
464
- /// <summary>
465
- /// Returns the contained value if <c>Error</c>, otherwise returns the provided value
466
- ///
467
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/others#defaulterror</href>
468
- /// </summary>
469
- /// <param name="ifOk">The value to use if the result is <c>Ok</c>.</param>
470
- /// <param name="result">The input result.</param>
471
- /// <returns>The contained value if <c>Error</c>, otherwise <paramref name="ifOk"/>.</returns>
472
- let inline defaultError (ifOk: 'error) (result: Result<'ok, 'error>) : 'error =
473
- match result with
474
- | Error error -> error
475
- | Ok _ -> ifOk
476
-
477
- /// <summary>
478
- /// Returns the contained value if <c>Ok</c>, otherwise evaluates <param name="ifErrorThunk"/> and returns the value.
479
- ///
480
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/others#defaultwith</href>
481
- /// </summary>
482
- /// <param name="ifErrorThunk">The function to evaluate if the result is <c>Error</c>.</param>
483
- /// <param name="result">The input result.</param>
484
- /// <returns>The contained value if <c>Ok</c>, otherwise the result of evaluating <paramref name="ifErrorThunk"/>.</returns>
485
- let inline defaultWith
486
- ([<InlineIfLambda>] ifErrorThunk: 'error -> 'ok)
487
- (result: Result<'ok, 'error>)
488
- : 'ok =
489
- match result with
490
- | Ok x -> x
491
- | Error e -> ifErrorThunk e
492
-
493
- /// <summary>
494
- /// Same as <c>defaultValue</c> for a result where the Ok value is unit. The name
495
- /// describes better what is actually happening in this case.
496
- ///
497
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/others#ignoreerror</href>
498
- /// </summary>
499
- /// <param name="result">The input result.</param>
500
- /// <returns>Unit if <c>Ok</c>, otherwise the provided value.</returns>
501
- let inline ignoreError<'error> (result: Result<unit, 'error>) : unit = defaultValue () result
502
-
503
- /// <summary>
504
- /// If the result is <c>Ok</c> and the predicate returns true, executes the function on the <c>Ok</c> value. Passes through the input value.
505
- ///
506
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/teefunctions#teeif</href>
507
- /// </summary>
508
- /// <param name="predicate">The predicate to evaluate on the <c>Ok</c> value.</param>
509
- /// <param name="sideEffect">The function to execute on the <c>Ok</c> value if the predicate returns true.</param>
510
- /// <param name="result">The input result.</param>
511
- /// <returns>The input result.</returns>
512
- let inline teeIf
513
- ([<InlineIfLambda>] predicate: 'ok -> bool)
514
- ([<InlineIfLambda>] sideEffect: 'ok -> unit)
515
- (result: Result<'ok, 'error>)
516
- : Result<'ok, 'error> =
517
- match result with
518
- | Ok x ->
519
- if predicate x then
520
- sideEffect x
521
- | Error _ -> ()
522
-
523
- result
524
-
525
- /// <summary>
526
- /// If the result is <c>Error</c> and the predicate returns true, executes the
527
- /// function on the <c>Error</c> value. Passes through the input value.
528
- ///
529
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/teefunctions#teeerrorif</href>
530
- /// </summary>
531
- /// <param name="predicate">The predicate to evaluate on the <c>Error</c> value.</param>
532
- /// <param name="sideEffect">The function to execute on the <c>Error</c> value if the predicate returns true.</param>
533
- /// <param name="result">The input result.</param>
534
- /// <returns>The input result.</returns>
535
- let inline teeErrorIf
536
- ([<InlineIfLambda>] predicate: 'error -> bool)
537
- ([<InlineIfLambda>] sideEffect: 'error -> unit)
538
- (result: Result<'ok, 'error>)
539
- : Result<'ok, 'error> =
540
- match result with
541
- | Ok _ -> ()
542
- | Error x ->
543
- if predicate x then
544
- sideEffect x
545
-
546
- result
547
-
548
- /// <summary>
549
- /// If the result is <c>Ok</c>, executes the function on the <c>Ok</c> value. Passes through the input value.
550
- ///
551
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/teefunctions#tee</href>
552
- /// </summary>
553
- /// <param name="sideEffect">The function to execute on the <c>Ok</c> value.</param>
554
- /// <param name="result">The input result.</param>
555
- /// <returns>The input result.</returns>
556
- let inline tee
557
- ([<InlineIfLambda>] sideEffect: 'ok -> unit)
558
- (result: Result<'ok, 'error>)
559
- : Result<'ok, 'error> =
560
- teeIf (fun _ -> true) sideEffect result
561
-
562
- /// <summary>
563
- /// If the result is <c>Error</c>, executes the function on the <c>Error</c> value. Passes through the input value.
564
- ///
565
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/teefunctions#teeerror</href>
566
- /// </summary>
567
- /// <param name="sideEffect">The function to execute on the <c>Error</c> value.</param>
568
- /// <param name="result">The input result.</param>
569
- /// <returns>The input result.</returns>
570
- let inline teeError
571
- ([<InlineIfLambda>] sideEffect: 'error -> unit)
572
- (result: Result<'ok, 'error>)
573
- : Result<'ok, 'error> =
574
- teeErrorIf (fun _ -> true) sideEffect result
575
-
576
- /// Converts a Result<Async<_>,_> to an Async<Result<_,_>>
577
- let inline sequenceAsync (resAsync: Result<Async<'ok>, 'error>) : Async<Result<'ok, 'error>> =
578
- async {
579
- match resAsync with
580
- | Ok asnc ->
581
- let! x = asnc
582
- return Ok x
583
- | Error err -> return Error err
584
- }
585
-
586
- /// <summary>
587
- /// Maps an Async function over a Result, returning an Async Result.
588
- /// </summary>
589
- /// <param name="f">The function to map over the Result.</param>
590
- /// <param name="res">The Result to map over.</param>
591
- /// <returns>An Async Result with the mapped value.</returns>
592
- let inline traverseAsync
593
- ([<InlineIfLambda>] f: 'okInput -> Async<'okOutput>)
594
- (res: Result<'okInput, 'error>)
595
- : Async<Result<'okOutput, 'error>> =
596
- sequenceAsync ((map f) res)
597
-
598
-
599
- /// <summary>
600
- /// Returns the <c>Ok</c> value or runs the specified function over the error value.
601
- ///
602
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/others#valueor</href>
603
- /// </summary>
604
- /// <param name="f">The function to run over the error value.</param>
605
- /// <param name="res">The input result.</param>
606
- /// <returns>The <c>Ok</c> value if the result is <c>Ok</c>, otherwise the result of running the function over the error value.</returns>
607
- let inline valueOr ([<InlineIfLambda>] f: 'error -> 'ok) (res: Result<'ok, 'error>) : 'ok =
608
- match res with
609
- | Ok x -> x
610
- | Error x -> f x
611
-
612
- /// <summary>
613
- /// Takes two results and returns a tuple of the pair
614
- ///
615
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/zip</href>
616
- /// </summary>
617
- /// <param name="left">The first input result.</param>
618
- /// <param name="right">The second input result.</param>
619
- /// <returns>A tuple of the pair of the input results.</returns>
620
- let zip
621
- (left: Result<'leftOk, 'error>)
622
- (right: Result<'rightOk, 'error>)
623
- : Result<'leftOk * 'rightOk, 'error> =
624
- match left, right with
625
- | Ok x1res, Ok x2res -> Ok(x1res, x2res)
626
- | Error e, _ -> Error e
627
- | _, Error e -> Error e
628
-
629
- /// <summary>
630
- /// Takes two results and returns a tuple of the error pair
631
- ///
632
- /// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/ziperror</href>
633
- /// </summary>
634
- /// <param name="left">The first input result.</param>
635
- /// <param name="right">The second input result.</param>
636
- /// <returns>A tuple of the error pair of the input results.</returns>
637
- let zipError
638
- (left: Result<'ok, 'leftError>)
639
- (right: Result<'ok, 'rightError>)
640
- : Result<'ok, 'leftError * 'rightError> =
641
- match left, right with
642
- | Error x1res, Error x2res -> Error(x1res, x2res)
643
- | Ok e, _ -> Ok e
644
- | _, Ok e -> Ok e