Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 7 commits
  • 287 files changed
  • 0 comments
  • 1 contributor
Jul 30, 2012
frabbit frabbit renamed TcRegistry to Registry
renamed TcContext to Resolver
renamed extension classes, trailing 's' like Arrays
added Function monoids and semigroups
clean up registry and resolver
8dee86a
Aug 07, 2012
frabbit frabbit major overhaul, pre cleanup 0440643
Aug 10, 2012
frabbit frabbit Add first new version
Added a few test cases
Error reporting must be improved
1cb8d80
frabbit frabbit add ValidationTApplicative, ValidationTMonad
fixed some ValidationT errors
added ImplicitCasts + Objects
added Identity methods
added ValidationT Test
87cf988
frabbit frabbit removed unnecessary type declaration 599d4e9
frabbit frabbit small resolver fix
some eq tests
ca506b5
Aug 13, 2012
frabbit frabbit removed OfT, seems unnessecary now
added tests
cf27b5e

Showing 287 changed files with 4,395 additions and 4,010 deletions. Show diff stats Hide diff stats

  1. +3 1 .gitignore
  2. +5 4 commonTest.hxml
  3. +2 0  runTestsCpp.bat
  4. +2 0  runTestsCs.bat
  5. +4 0 runTestsCs.hxml
  6. +2 0  runTestsFlash.bat
  7. +4 0 runTestsFlash.hxml
  8. +2 0  runTestsJava.bat
  9. +4 0 runTestsJava.hxml
  10. +2 0  runTestsJs.bat
  11. +4 0 runTestsJs.hxml
  12. +2 0  runTestsNeko.bat
  13. +1 1  runTestsNeko.hxml
  14. +2 0  runTestsPhp.bat
  15. +4 0 runTestsPhp.hxml
  16. +0 55 samples/01_ArrayMonad/ArrayMonadSample.hx
  17. +0 1  samples/01_ArrayMonad/main.hxml
  18. +0 8 samples/01_ArrayMonad/neko.hxml
  19. +0 51 samples/02_MonadTransformer/MonadTransformerSample.hx
  20. +0 5 samples/02_MonadTransformer/all.hxml
  21. +0 9 samples/02_MonadTransformer/cpp.hxml
  22. +0 8 samples/02_MonadTransformer/flash.hxml
  23. +0 7 samples/02_MonadTransformer/js.hxml
  24. +0 1  samples/02_MonadTransformer/main.hxml
  25. +0 9 samples/02_MonadTransformer/neko.hxml
  26. +0 7 samples/02_MonadTransformer/php.hxml
  27. +0 36 samples/03_Foldable/FoldableSample.hx
  28. +0 5 samples/03_Foldable/all.hxml
  29. +0 9 samples/03_Foldable/cpp.hxml
  30. +0 8 samples/03_Foldable/flash.hxml
  31. +0 7 samples/03_Foldable/js.hxml
  32. +0 1  samples/03_Foldable/main.hxml
  33. +0 9 samples/03_Foldable/neko.hxml
  34. +0 7 samples/03_Foldable/php.hxml
  35. +0 51 samples/04_Collection/CollectionSample.hx
  36. +0 5 samples/04_Collection/all.hxml
  37. +0 9 samples/04_Collection/cpp.hxml
  38. +0 8 samples/04_Collection/flash.hxml
  39. +0 7 samples/04_Collection/js.hxml
  40. +0 1  samples/04_Collection/main.hxml
  41. +0 9 samples/04_Collection/neko.hxml
  42. +0 7 samples/04_Collection/php.hxml
  43. +0 145 samples/05_Validation/ValidationSample.hx
  44. +0 1  samples/05_Validation/main.hxml
  45. +0 9 samples/05_Validation/neko.hxml
  46. +0 68 samples/06_Monoid/MonoidSample.hx
  47. +0 5 samples/06_Monoid/all.hxml
  48. +0 9 samples/06_Monoid/cpp.hxml
  49. +0 8 samples/06_Monoid/flash.hxml
  50. +0 7 samples/06_Monoid/js.hxml
  51. +0 1  samples/06_Monoid/main.hxml
  52. +0 9 samples/06_Monoid/neko.hxml
  53. +0 7 samples/06_Monoid/php.hxml
  54. +0 73 samples/07_GenEq/GenEqSample.hx
  55. +0 5 samples/07_GenEq/all.hxml
  56. +0 9 samples/07_GenEq/cpp.hxml
  57. +0 8 samples/07_GenEq/flash.hxml
  58. +0 7 samples/07_GenEq/js.hxml
  59. +0 1  samples/07_GenEq/main.hxml
  60. +0 9 samples/07_GenEq/neko.hxml
  61. +0 7 samples/07_GenEq/php.hxml
  62. +7 0 src/hots/Hots.hx
  63. +94 0 src/hots/Identity.hx
  64. +3 0  src/hots/Implicit.hx
  65. +191 0 src/hots/ImplicitCasts.hx
  66. +6 0 src/hots/ImplicitConversion.hx
  67. +5 0 src/hots/ImplicitObject.hx
  68. +419 0 src/hots/Objects.hx
  69. +21 19 src/hots/Of.hx
  70. +5 0 src/hots/OfOf.hx
  71. +0 8 src/hots/TC.hx
  72. +32 9 src/hots/box/ArrayBox.hx
  73. +28 0 src/hots/box/FastListBox.hx
  74. +20 3 src/hots/box/FunctionBox.hx
  75. +0 21 src/hots/box/FutureBox.hx
  76. +0 1  src/hots/box/ImmutableListBox.hx
  77. +28 0 src/hots/box/IoBox.hx
  78. +28 0 src/hots/box/IterableBox.hx
  79. +10 5 src/hots/box/LazyListBox.hx
  80. +32 8 src/hots/box/OptionBox.hx
  81. +22 0 src/hots/box/PromiseBox.hx
  82. +26 0 src/hots/box/StdListBox.hx
  83. +19 9 src/hots/box/Tup2Box.hx
  84. +15 1 src/hots/box/ValidationBox.hx
  85. +1 4 src/hots/classes/Alternative.hx
  86. +2 2 src/hots/classes/Applicative.hx
  87. +1 1  src/hots/classes/ApplicativeAbstract.hx
  88. +2 2 src/hots/classes/Arrow.hx
  89. +8 10 src/hots/classes/ArrowAbstract.hx
  90. +2 2 src/hots/classes/ArrowZero.hx
  91. +10 10 src/hots/classes/ArrowZeroAbstract.hx
  92. +5 2 src/hots/classes/Category.hx
  93. +1 1  src/hots/classes/CategoryAbstract.hx
  94. +6 4 src/hots/classes/CoMonadAbstract.hx
  95. +2 2 src/hots/classes/CoPointed.hx
  96. +3 3 src/hots/classes/CoPointedAbstract.hx
  97. +2 2 src/hots/classes/Collection.hx
  98. +1 1  src/hots/classes/CollectionAbstract.hx
  99. +3 2 src/hots/classes/Enumeration.hx
  100. +4 3 src/hots/classes/EnumerationAbstract.hx
  101. +4 2 src/hots/classes/Eq.hx
  102. +5 7 src/hots/classes/EqAbstract.hx
  103. +2 2 src/hots/classes/Foldable.hx
  104. +24 24 src/hots/classes/FoldableAbstract.hx
  105. +2 2 src/hots/classes/Functor.hx
  106. +1 1  src/hots/classes/FunctorAbstract.hx
  107. +2 2 src/hots/classes/Monad.hx
  108. +11 8 src/hots/classes/MonadAbstract.hx
  109. +8 8 src/hots/classes/MonadFailAbstract.hx
  110. +9 9 src/hots/classes/MonadOrAbstract.hx
  111. +0 3  src/hots/classes/MonadPlus.hx
  112. +19 10 src/hots/classes/MonadPlusAbstract.hx
  113. +6 3 src/hots/classes/MonadTrans.hx
  114. +2 4 src/hots/classes/MonadTransAbstract.hx
  115. +16 9 src/hots/classes/MonadZeroAbstract.hx
  116. +5 2 src/hots/classes/Monoid.hx
  117. +7 3 src/hots/classes/MonoidAbstract.hx
  118. +6 5 src/hots/classes/NumAbstract.hx
  119. +19 11 src/hots/classes/OrdAbstract.hx
  120. +2 2 src/hots/classes/Pointed.hx
  121. +5 2 src/hots/classes/PointedAbstract.hx
  122. +3 2 src/hots/classes/Read.hx
  123. +2 1  src/hots/classes/ReadAbstract.hx
  124. +2 2 src/hots/classes/Semigroup.hx
  125. +1 2  src/hots/classes/SemigroupAbstract.hx
  126. +3 2 src/hots/classes/Show.hx
  127. +2 1  src/hots/classes/ShowAbstract.hx
  128. +10 9 src/hots/classes/TraversableAbstract.hx
  129. +3 6 src/hots/extensions/{ApplicativeExt.hx → Applicatives.hx}
  130. +0 35 src/hots/extensions/ArrayOfExt.hx
  131. +0 27 src/hots/extensions/ArrowExt.hx
  132. +32 0 src/hots/extensions/Arrows.hx
  133. +0 12 src/hots/extensions/EqExt.hx
  134. +26 0 src/hots/extensions/Eqs.hx
  135. +0 23 src/hots/extensions/FoldableExt.hx
  136. +25 0 src/hots/extensions/Foldables.hx
  137. +10 0 src/hots/extensions/Functors.hx
  138. +0 255 src/hots/extensions/MonadExt.hx
  139. +31 0 src/hots/extensions/MonadTs.hx
  140. +15 0 src/hots/extensions/MonadZeros.hx
  141. +154 0 src/hots/extensions/Monads.hx
  142. +34 0 src/hots/extensions/Monoids.hx
  143. +0 22 src/hots/extensions/OptionEnumExt.hx
  144. +0 43 src/hots/extensions/OptionOfExt.hx
  145. +17 1 src/hots/extensions/{OrdExt.hx → Ords.hx}
  146. +0 8 src/hots/extensions/ShowExt.hx
  147. +23 0 src/hots/extensions/Shows.hx
  148. +0 13 src/hots/extensions/StringClassExt.hx
  149. +3 4 src/hots/instances/ArrayEq.hx
  150. +2 1  src/hots/instances/ArrayMonoid.hx
  151. +8 3 src/hots/instances/ArrayOfApplicative.hx
  152. +18 25 src/hots/instances/ArrayOfCollection.hx
  153. +4 2 src/hots/instances/ArrayOfFoldable.hx
  154. +1 2  src/hots/instances/ArrayOfFunctor.hx
  155. +12 3 src/hots/instances/ArrayOfMonad.hx
  156. +7 4 src/hots/instances/ArrayOfMonadZero.hx
  157. +0 18 src/hots/instances/ArrayOfMonoid.hx
  158. +3 1 src/hots/instances/ArrayOfPointed.hx
  159. +4 3 src/hots/instances/ArrayOfSemigroup.hx
  160. +6 3 src/hots/instances/ArrayRead.hx
  161. +2 1  src/hots/instances/ArraySemigroup.hx
  162. +6 3 src/hots/instances/ArrayShow.hx
  163. +14 12 src/hots/instances/ArrayTOfApplicative.hx
  164. +9 13 src/hots/instances/ArrayTOfFunctor.hx
  165. +10 9 src/hots/instances/ArrayTOfMonad.hx
  166. +4 4 src/hots/instances/ArrayTOfPointed.hx
  167. +1 1  src/hots/instances/BoolMonoid.hx
  168. +1 4 src/hots/instances/BoolOrd.hx
  169. +0 1  src/hots/instances/BoolSemigroup.hx
  170. +2 1  src/hots/instances/BoolShow.hx
  171. +10 8 src/hots/instances/DateEq.hx
  172. +6 3 src/hots/instances/DateInDaysEnumeration.hx
  173. +6 3 src/hots/instances/DateInWeeksEnumeration.hx
  174. +18 9 src/hots/instances/DateOrd.hx
  175. +5 3 src/hots/instances/DualMonoid.hx
  176. +5 2 src/hots/instances/DualSemigroup.hx
  177. +7 4 src/hots/instances/EitherApplicative.hx
  178. +4 7 src/hots/instances/EitherEq.hx
  179. +5 3 src/hots/instances/EitherMonad.hx
  180. +6 4 src/hots/instances/EitherPointed.hx
  181. +27 0 src/hots/instances/EitherSemigroup.hx
  182. +8 2 src/hots/instances/EndoMonoid.hx
  183. +2 1  src/hots/instances/EndoSemigroup.hx
  184. +8 3 src/hots/instances/EnumByIndexEq.hx
  185. +5 3 src/hots/instances/EnumByIndexOrd.hx
  186. +5 3 src/hots/instances/FastListFoldable.hx
  187. +2 3 src/hots/instances/FloatEq.hx
  188. +29 11 src/hots/instances/FloatOrd.hx
  189. +12 0 src/hots/instances/FloatShow.hx
  190. +24 0 src/hots/instances/Function0Monoid.hx
  191. +22 0 src/hots/instances/Function0Semigroup.hx
  192. +20 0 src/hots/instances/Function1Functor.hx
  193. +23 0 src/hots/instances/Function1Monoid.hx
  194. +21 0 src/hots/instances/Function1Semigroup.hx
  195. +9 7 src/hots/instances/FunctionArrow.hx
  196. +9 7 src/hots/instances/FunctionCategory.hx
  197. +1 1  src/hots/instances/{FunctionOf.hx → FunctionOfOf.hx}
  198. +0 25 src/hots/instances/FutureMonoid.hx
  199. +0 7 src/hots/instances/FutureOf.hx
  200. +0 18 src/hots/instances/FutureOfFunctor.hx
  201. +4 2 src/hots/instances/HashShow.hx
  202. +0 11 src/hots/instances/IO.hx
  203. +5 1 src/hots/instances/IntNum.hx
  204. +1 1  src/hots/instances/IntOrd.hx
  205. +2 1  src/hots/instances/IntProductMonoid.hx
  206. +2 1  src/hots/instances/IntSumMonoid.hx
  207. +8 2 src/hots/instances/IntSumSemigroup.hx
  208. +9 0 src/hots/instances/IoOf.hx
  209. +26 0 src/hots/instances/IoOfApplicative.hx
  210. +19 0 src/hots/instances/IoOfFunctor.hx
  211. +20 0 src/hots/instances/IoOfMonad.hx
  212. +25 0 src/hots/instances/IoOfPointed.hx
  213. +1 1  src/hots/instances/IterableOfFoldable.hx
  214. +2 2 src/hots/instances/KleisliArrow.hx
  215. +7 5 src/hots/instances/LazyListOfFoldable.hx
  216. +7 0 src/hots/instances/LazyListTOf.hx
  217. +1 1  src/hots/instances/ListOf.hx
  218. +7 7 src/hots/instances/ListOfCollection.hx
  219. +4 4 src/hots/instances/ListOfFoldable.hx
  220. +2 6 src/hots/instances/OptionMonoid.hx
  221. +8 7 src/hots/instances/OptionOfApplicative.hx
  222. +2 1  src/hots/instances/OptionOfMonad.hx
  223. +4 4 src/hots/instances/OptionOfMonadZero.hx
  224. +3 2 src/hots/instances/OptionOfPointed.hx
  225. +6 9 src/hots/instances/OptionSemigroup.hx
  226. +22 0 src/hots/instances/OptionShow.hx
  227. +2 2 src/hots/instances/OptionTOf.hx
  228. +20 19 src/hots/instances/OptionTOfApplicative.hx
  229. +5 4 src/hots/instances/OptionTOfFunctor.hx
  230. +11 10 src/hots/instances/OptionTOfMonad.hx
  231. +3 3 src/hots/instances/OptionTOfMonadZero.hx
  232. +4 4 src/hots/instances/OptionTOfPointed.hx
  233. +4 2 src/hots/instances/Predicate1Monoid.hx
  234. +2 1  src/hots/instances/Predicate1Semigroup.hx
  235. +24 0 src/hots/instances/PromiseMonoid.hx
  236. +7 0 src/hots/instances/PromiseOf.hx
  237. +23 0 src/hots/instances/PromiseOfApplicative.hx
  238. +19 0 src/hots/instances/PromiseOfFunctor.hx
  239. +4 6 src/hots/instances/{FutureSemigroup.hx → PromiseSemigroup.hx}
  240. +2 1  src/hots/instances/StringMonoid.hx
  241. +1 1  src/hots/instances/StringOrd.hx
  242. +25 0 src/hots/instances/Tup2Eq.hx
  243. +0 19 src/hots/instances/Tup2LeftFunctor.hx
  244. +1 1  src/hots/instances/Tup2Monoid.hx
  245. +4 2 src/hots/instances/Tup2Semigroup.hx
  246. +19 0 src/hots/instances/Tup2_1Functor.hx
  247. +1 1  src/hots/instances/{Tup2LeftOf.hx → Tup2_1Of.hx}
  248. +1 1  src/hots/instances/{Tup2RightOf.hx → Tup2_2Of.hx}
  249. +0 1  src/hots/instances/Tup3Monoid.hx
  250. +1 1  src/hots/instances/Tup4Monoid.hx
  251. +0 1  src/hots/instances/Tup4Semigroup.hx
  252. +28 0 src/hots/instances/ValidationEq.hx
  253. +7 3 src/hots/instances/{ValidationApplicative.hx → ValidationOfApplicative.hx}
  254. +1 1  src/hots/instances/{ValidationFunctor.hx → ValidationOfFunctor.hx}
  255. +8 4 src/hots/instances/{ValidationMonad.hx → ValidationOfMonad.hx}
  256. +7 6 src/hots/instances/{ValidationMonadPlus.hx → ValidationOfMonadPlus.hx}
  257. +5 3 src/hots/instances/{ValidationMonadZero.hx → ValidationOfMonadZero.hx}
  258. +9 6 src/hots/instances/{ValidationPointed.hx → ValidationOfPointed.hx}
  259. +2 2 src/hots/instances/ValidationSemigroup.hx
  260. +9 0 src/hots/instances/ValidationTOf.hx
  261. +52 0 src/hots/instances/ValidationTOfApplicative.hx
  262. +31 0 src/hots/instances/ValidationTOfFunctor.hx
  263. +39 0 src/hots/instances/ValidationTOfMonad.hx
  264. +38 0 src/hots/instances/ValidationTOfPointed.hx
  265. +0 277 src/hots/macros/Box.hx
  266. +0 35 src/hots/macros/Data.hx
  267. +35 0 src/hots/macros/HotsMacros.hx
  268. +46 0 src/hots/macros/ImplicitInternal.hx
  269. +943 0 src/hots/macros/ImplicitResolver.hx
  270. +0 268 src/hots/macros/TcContext.hx
  271. +0 333 src/hots/macros/TcRegistry.hx
  272. +39 46 src/hots/macros/{ → generators}/GenEq.hx
  273. +4 4 src/hots/macros/generators/GenEqAnon.hx
  274. +33 24 src/hots/macros/generators/GenEqEnum.hx
  275. +0 3  src/hots/macros/internal/UsingScope.hx
  276. +173 0 src/hots/macros/syntax/DoGenForMonads.hx
  277. +0 17 src/hots/macros/utils/Constants.hx
  278. +0 666 src/hots/macros/utils/Utils.hx
  279. +25 32 test/AllTests.hx
  280. +41 0 test/hots/EqTest.hx
  281. +79 0 test/hots/ImplicitScopeTests.hx
  282. +116 0 test/hots/MonadTransformersTest.hx
  283. +49 0 test/hots/MonadsTest.hx
  284. +85 0 test/hots/UnderscoreTests.hx
  285. +40 0 test/hots/instances/ArrayOfMonadTest.hx
  286. +0 117 test/hots/macros/BoxTest.hx
  287. +0 308 test/hots/macros/utils/UtilsTest.hx
4 .gitignore
@@ -19,4 +19,6 @@
19 19 /samples/07_GenEq/_scuts_cache
20 20 /samples/05_Validation/_scuts_cache
21 21 /samples/05_Validation/bin
22   -/samples/06_Monoid/bin
  22 +/samples/06_Monoid/bin
  23 +/samples/08_Underscore/_scuts_cache
  24 +/samples/08_Underscore/bin
9 commonTest.hxml
@@ -3,8 +3,9 @@
3 3 -cp ./../scutsMcore/src
4 4 -cp ./../scutsCore/src
5 5 -cp ./../scutsMacros/src
  6 +-cp ./../scutsData/src
6 7 -lib utest
7   -#--connect 127.0.0.1:8889
8   -
9   ---times
10   --D macrotimes
  8 +--connect 127.0.0.1:1978
  9 +#-D scutsDebug
  10 +#--times
  11 +#-D macrotimes
2  runTestsCpp.bat
... ... @@ -0,0 +1,2 @@
  1 +cd hots
  2 +haxe runTestsCpp.hxml
2  runTestsCs.bat
... ... @@ -0,0 +1,2 @@
  1 +cd hots
  2 +haxe runTestsCs.hxml
4 runTestsCs.hxml
... ... @@ -0,0 +1,4 @@
  1 +commonTest.hxml
  2 +-main AllTests
  3 +-cs bin/test/cs
  4 +
2  runTestsFlash.bat
... ... @@ -0,0 +1,2 @@
  1 +cd hots
  2 +haxe runTestsFlash.hxml
4 runTestsFlash.hxml
... ... @@ -0,0 +1,4 @@
  1 +commonTest.hxml
  2 +-main AllTests
  3 +-swf bin/test/testFlash.swf
  4 +
2  runTestsJava.bat
... ... @@ -0,0 +1,2 @@
  1 +cd hots
  2 +haxe runTestsJava.hxml
4 runTestsJava.hxml
... ... @@ -0,0 +1,4 @@
  1 +commonTest.hxml
  2 +-main AllTests
  3 +-java bin/test/java
  4 +
2  runTestsJs.bat
... ... @@ -0,0 +1,2 @@
  1 +cd hots
  2 +haxe runTestsJs.hxml
4 runTestsJs.hxml
... ... @@ -0,0 +1,4 @@
  1 +commonTest.hxml
  2 +-main AllTests
  3 +-js bin/test/testJs.js
  4 +
2  runTestsNeko.bat
... ... @@ -0,0 +1,2 @@
  1 +cd hots
  2 +haxe runTestsNeko.hxml
2  runTestsNeko.hxml
... ... @@ -1,4 +1,4 @@
1 1 commonTest.hxml
2 2 -main AllTests
3   --neko bin/test/testNeko.n
  3 +-x bin/test/testNeko.n
4 4
2  runTestsPhp.bat
... ... @@ -0,0 +1,2 @@
  1 +cd hots
  2 +haxe runTestsPhp.hxml
4 runTestsPhp.hxml
... ... @@ -0,0 +1,4 @@
  1 +commonTest.hxml
  2 +-main AllTests
  3 +-php bin/test/php
  4 +
55 samples/01_ArrayMonad/ArrayMonadSample.hx
... ... @@ -1,55 +0,0 @@
1   -package ;
2   -
3   -
4   -
5   -import hots.classes.Monad;
6   -import hots.classes.MonadZero;
7   -import hots.In;
8   -import hots.instances.ArrayOfMonad;
9   -import hots.instances.ArrayOfMonadZero;
10   -
11   -using hots.extensions.MonadExt;
12   -using hots.macros.TcContext;
13   -using hots.macros.Box;
14   -
15   -class ArrayMonadSample
16   -{
17   -
18   -
19   - public static function main ()
20   - {
21   - var a = [1,2,3].box();
22   - var b = [3,4,5].box();
23   -
24   - var m = a.tc(Monad); // ArrayMonad.get()
25   -
26   - var res = m.runDo(
27   - x <= a,
28   - y <= b,
29   - return x + y
30   - );
31   - /*
32   - m.flatMap(a, function (x) {
33   - return m.flatMap(b, function (y) {
34   - return m.pure(x + y);
35   - })
36   - });
37   - */
38   -
39   - trace(res);
40   -
41   - var mz = a.tc(MonadZero);
42   -
43   - var res2 = mz.runDo(
44   - x <= a,
45   - filter(x > 2),
46   - y <= b,
47   - return x + y
48   - );
49   -
50   - trace(res2);
51   -
52   - }
53   -
54   -
55   -}
1  samples/01_ArrayMonad/main.hxml
... ... @@ -1 +0,0 @@
1   --main ArrayMonadSample
8 samples/01_ArrayMonad/neko.hxml
... ... @@ -1,8 +0,0 @@
1   -main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   --cp ../../../hots/src
5   --cp ../../../scutsMacros/src
6   --cp ../../../scutsMCore/src
7   --cp .
8   --x bin/Example
51 samples/02_MonadTransformer/MonadTransformerSample.hx
... ... @@ -1,51 +0,0 @@
1   -package ;
2   -
3   -
4   -using hots.macros.Box;
5   -using hots.macros.TcContext;
6   -
7   -import scuts.core.extensions.Options;
8   -import scuts.core.types.Option;
9   -import hots.classes.Monad;
10   -import hots.classes.MonadZero;
11   -import hots.instances.ArrayOfMonad;
12   -import hots.instances.ArrayOfMonadZero;
13   -import hots.instances.OptionTOfMonad;
14   -import hots.instances.OptionTOfMonadZero;
15   -
16   -using hots.extensions.MonadExt;
17   -
18   -class MonadTransformerSample
19   -{
20   -
21   - public static function main () {
22   - var a = [Some(5), Some(7), Some(2)].box(2);
23   - var b = [Some(2), Some(3), Some(1)].box(2);
24   -
25   - var m = a.tc(Monad); // ArrayTMonad.get(OptionMonad.get())
26   -
27   - var res = m.runDo(
28   - x <= a,
29   - y <= b,
30   - return x + y
31   - );
32   -
33   -
34   - trace(res);
35   -
36   - var mz = a.tc(MonadZero);
37   -
38   - var res2 = mz.runDo(
39   - x <= a,
40   - filter(x > 2),
41   - y <= b,
42   - return x + y
43   - );
44   -
45   - trace(res2);
46   -
47   -
48   - }
49   -
50   -
51   -}
5 samples/02_MonadTransformer/all.hxml
... ... @@ -1,5 +0,0 @@
1   -neko.hxml
2   -cpp.hxml
3   -flash.hxml
4   -js.hxml
5   -php.hxml
9 samples/02_MonadTransformer/cpp.hxml
... ... @@ -1,9 +0,0 @@
1   -main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   --cp ../../../hots/src
5   --cp ../../../scutsMacros/src
6   --cp ../../../scutsMCore/src
7   --cpp bin/cpp
8   ---next
9   --cmd bin\cpp\ListSample.exe
8 samples/02_MonadTransformer/flash.hxml
... ... @@ -1,8 +0,0 @@
1   -main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   --cp ../../../hots/src
5   --cp ../../../scutsMacros/src
6   --cp ../../../scutsMCore/src
7   --swf-header 1200:900:31:FFFFFF
8   --swf bin/Example.swf
7 samples/02_MonadTransformer/js.hxml
... ... @@ -1,7 +0,0 @@
1   -main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   --cp ../../../hots/src
5   --cp ../../../scutsMacros/src
6   --cp ../../../scutsMCore/src
7   --js bin/Example.js
1  samples/02_MonadTransformer/main.hxml
... ... @@ -1 +0,0 @@
1   --main MonadTransformerSample
9 samples/02_MonadTransformer/neko.hxml
... ... @@ -1,9 +0,0 @@
1   -main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   -
5   --cp ../../../hots/src
6   --cp ../../../scutsMacros/src
7   --cp ../../../scutsMCore/src
8   --cp .
9   --x bin/Example
7 samples/02_MonadTransformer/php.hxml
... ... @@ -1,7 +0,0 @@
1   --main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   --cp ../../../hots/src
5   --cp ../../../scutsMacros/src
6   --cp ../../../scutsMCore/src
7   --php bin/php
36 samples/03_Foldable/FoldableSample.hx
... ... @@ -1,36 +0,0 @@
1   -package ;
2   -
3   -
4   -import hots.classes.Foldable;
5   -import hots.Of;
6   -import hots.instances.ArrayOfFoldable;
7   -import hots.instances.ListOfFoldable;
8   -
9   -using hots.macros.TcContext;
10   -using hots.macros.Box;
11   -
12   -class FoldableSample
13   -{
14   -
15   - public static function genericFoldLeft <M,T, Acc>(of:Of<M,T>, f:Foldable<M>, fn:Acc->T->Acc, acc:Acc):Acc
16   - {
17   - return f.foldLeft(of, acc, fn);
18   - }
19   -
20   - public static function main () {
21   - var arrOf = [2,3,4].box();
22   -
23   - var list = new List();
24   - list.add(3); list.add(2); list.add(1);
25   -
26   - var listOf = list.box();
27   -
28   - var fn = function (acc, e) return acc + e;
29   -
30   - trace(genericFoldLeft(arrOf, arrOf.tc(Foldable), fn, 0));
31   - trace(genericFoldLeft(listOf, listOf.tc(Foldable), fn, 0));
32   -
33   - }
34   -
35   -
36   -}
5 samples/03_Foldable/all.hxml
... ... @@ -1,5 +0,0 @@
1   -neko.hxml
2   -cpp.hxml
3   -flash.hxml
4   -js.hxml
5   -php.hxml
9 samples/03_Foldable/cpp.hxml
... ... @@ -1,9 +0,0 @@
1   -main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   --cp ../../../hots/src
5   --cp ../../../scutsMacros/src
6   --cp ../../../scutsMCore/src
7   --cpp bin/cpp
8   ---next
9   --cmd bin\cpp\ListSample.exe
8 samples/03_Foldable/flash.hxml
... ... @@ -1,8 +0,0 @@
1   -main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   --cp ../../../hots/src
5   --cp ../../../scutsMacros/src
6   --cp ../../../scutsMCore/src
7   --swf-header 1200:900:31:FFFFFF
8   --swf bin/Example.swf
7 samples/03_Foldable/js.hxml
... ... @@ -1,7 +0,0 @@
1   -main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   --cp ../../../hots/src
5   --cp ../../../scutsMacros/src
6   --cp ../../../scutsMCore/src
7   --js bin/Example.js
1  samples/03_Foldable/main.hxml
... ... @@ -1 +0,0 @@
1   --main FoldableSample
9 samples/03_Foldable/neko.hxml
... ... @@ -1,9 +0,0 @@
1   -main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   -
5   --cp ../../../hots/src
6   --cp ../../../scutsMacros/src
7   --cp ../../../scutsMCore/src
8   --cp .
9   --x bin/Example.n
7 samples/03_Foldable/php.hxml
... ... @@ -1,7 +0,0 @@
1   --main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   --cp ../../../hots/src
5   --cp ../../../scutsMacros/src
6   --cp ../../../scutsMCore/src
7   --php bin/php
51 samples/04_Collection/CollectionSample.hx
... ... @@ -1,51 +0,0 @@
1   -package ;
2   -
3   -import hots.classes.Collection;
4   -import hots.classes.Foldable;
5   -import hots.Of;
6   -import hots.instances.ArrayOfCollection;
7   -import hots.instances.ListOfCollection;
8   -
9   -using hots.macros.TcContext;
10   -using hots.macros.Box;
11   -
12   -
13   -class CollectionSample
14   -{
15   -
16   -
17   -
18   - public static function main ()
19   - {
20   - var arrOf = [2,3,4].box();
21   -
22   - var list = new List();
23   - list.add(3); list.add(2); list.add(1);
24   -
25   - var listOf = list.box();
26   -
27   -
28   -
29   - trace(insertIntoCollection(arrOf, arrOf.tc(Collection), 7));
30   - trace(insertIntoCollection(listOf, listOf.tc(Collection), 10));
31   -
32   -
33   -
34   - }
35   -
36   -
37   - public static function insertIntoCollection <M,T>(of:Of<M,T>, c:Collection<M>, el:T):Of<M,T>
38   - {
39   - return c.insert(of, el);
40   - }
41   -
42   - public static function removeFromCollection <M,T>(of:Of<M,T>, c:Collection<M>, remove:T->Bool):Of<M,T>
43   - {
44   - return c.remove(of, remove);
45   - }
46   -
47   -}
48   -// hots.instances.ArrayTOf<hots.Of<scuts.core.types.Option<hots.In>, scuts.core.types.Option<hots.In>>, Int>
49   -
50   -
51   -
5 samples/04_Collection/all.hxml
... ... @@ -1,5 +0,0 @@
1   -neko.hxml
2   -cpp.hxml
3   -flash.hxml
4   -js.hxml
5   -php.hxml
9 samples/04_Collection/cpp.hxml
... ... @@ -1,9 +0,0 @@
1   -main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   --cp ../../../hots/src
5   --cp ../../../scutsMacros/src
6   --cp ../../../scutsMCore/src
7   --cpp bin/cpp
8   ---next
9   --cmd bin\cpp\ListSample.exe
8 samples/04_Collection/flash.hxml
... ... @@ -1,8 +0,0 @@
1   -main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   --cp ../../../hots/src
5   --cp ../../../scutsMacros/src
6   --cp ../../../scutsMCore/src
7   --swf-header 1200:900:31:FFFFFF
8   --swf bin/Example.swf
7 samples/04_Collection/js.hxml
... ... @@ -1,7 +0,0 @@
1   -main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   --cp ../../../hots/src
5   --cp ../../../scutsMacros/src
6   --cp ../../../scutsMCore/src
7   --js bin/Example.js
1  samples/04_Collection/main.hxml
... ... @@ -1 +0,0 @@
1   --main CollectionSample
9 samples/04_Collection/neko.hxml
... ... @@ -1,9 +0,0 @@
1   -main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   -
5   --cp ../../../hots/src
6   --cp ../../../scutsMacros/src
7   --cp ../../../scutsMCore/src
8   --cp .
9   --x bin/Example.n
7 samples/04_Collection/php.hxml
... ... @@ -1,7 +0,0 @@
1   --main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   --cp ../../../hots/src
5   --cp ../../../scutsMacros/src
6   --cp ../../../scutsMCore/src
7   --php bin/php
145 samples/05_Validation/ValidationSample.hx
... ... @@ -1,145 +0,0 @@
1   -package ;
2   -
3   -
4   -using hots.macros.TcContext;
5   -
6   -using scuts.core.extensions.Arrays;
7   -
8   -import hots.classes.Monad;
9   -import hots.classes.MonoidAbstract;
10   -import hots.classes.Semigroup;
11   -import hots.instances.ValidationMonad;
12   -import hots.instances.ValidationSemigroup;
13   -
14   -//import hots.instances.ValidationMonadPlus;
15   -import scuts.core.types.Validation;
16   -import hots.classes.SemigroupAbstract;
17   -
18   -import hots.instances.ArrayMonoid;
19   -import hots.Of;
20   -
21   -using scuts.core.extensions.Validations;
22   -
23   -using hots.extensions.MonadExt;
24   -
25   -using hots.box.ValidationBox;
26   -
27   -enum MultiError<T> {
28   - Simple(e:T);
29   - Multiple(a:Array<T>);
30   -}
31   -
32   -class MultiErrorSemigroup<X> extends SemigroupAbstract<MultiError<X>> {
33   - public function new () { }
34   -
35   - override public function append (e1:MultiError<X>, e2:MultiError<X>):MultiError<X> {
36   - return switch (e1) {
37   - case Multiple(a1): switch (e2)
38   - {
39   - case Multiple(a2): Multiple(a1.concat(a2));
40   - case Simple(a2): Multiple(a1.append(a2));
41   - }
42   - case Simple(a1): switch (e2)
43   - {
44   - case Multiple(a2): Multiple(a2.cons(a1));
45   - case Simple(a2): Multiple([a1,a2]);
46   - }
47   - }
48   - }
49   -}
50   -
51   -class FirstSemigroup<X> extends SemigroupAbstract<X> {
52   - public function new () { }
53   -
54   - override public function append (e1:X, e2:X):X {
55   - return e1;
56   - }
57   -}
58   -
59   -
60   -enum FormError {
61   - InvalidUserName(userName:String);
62   - InvalidEmail(email:String);
63   - InvalidAge(age:Int);
64   -}
65   -
66   -typedef Person = { name : String, email : String, age : Int };
67   -
68   -
69   -
70   -
71   -class ValidationSample
72   -{
73   -
74   - public static function validUserName(name:String):Bool
75   - {
76   - return name == "admin";
77   - }
78   -
79   - public static function validEmail(email:String):Bool
80   - {
81   - return email.indexOf("@") != -1;
82   - }
83   -
84   - public static function validAge(age:Int):Bool
85   - {
86   - return age >= 18;
87   - }
88   -
89   -
90   - public static function main ()
91   - {
92   - var loginInfo = { name : "admin", email : "foo", age : 13 };
93   -
94   - // lifting into Validation<MultiError<FormError>>, Success>
95   - var success = function (x:Person) return x.toSuccess();
96   - var fail = function (x) return Simple(x).toFail();
97   -
98   - var validEmail = function (p:Person) return if (validEmail(p.email)) success(p) else fail(InvalidEmail(p.email));
99   - var validAge = function (p:Person) return if (validAge(p.age)) success(p) else fail(InvalidAge(p.age));
100   - var validName = function (p:Person) return if (validUserName(p.name)) success(p) else fail(InvalidUserName(p.name));
101   -
102   - // we initialize with success
103   -
104   -
105   - // monad
106   - var vv:Validation<MultiError<FormError>, Person> = null;
107   - type(vv);
108   - //var m = Tc.forType('ValidationSemigroup<MultiErrorSemigroup<FormError>, Person>');
109   -
110   - var s:Semigroup<Person> = FirstSemigroup.get();
111   -
112   - var mon1 = vv.tc(Semigroup, [s]);
113   -
114   -
115   - var mon = ValidationSemigroup.get(MultiErrorSemigroup.get(), FirstSemigroup.get());
116   -
117   -
118   -
119   - var e1 = validEmail(loginInfo);
120   - var e2 = validAge(loginInfo);
121   - var e3 = validName(loginInfo);
122   -
123   - trace(mon.append(mon.append(e1,e2), e3));
124   -
125   -
126   - var m = ValidationMonad.get(MultiErrorSemigroup.get());
127   -
128   - var res = m.runDo(
129   - x <= validEmail(loginInfo).box(),
130   - y <= validAge(x).box(),
131   - z <= validName(y).box(),
132   - return z
133   - );
134   -
135   -
136   - trace(res);
137   -
138   - //m.
139   -
140   -
141   -
142   - }
143   -
144   -
145   -}
1  samples/05_Validation/main.hxml
... ... @@ -1 +0,0 @@
1   --main ValidationSample
9 samples/05_Validation/neko.hxml
... ... @@ -1,9 +0,0 @@
1   -main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   -
5   --cp ../../../hots/src
6   --cp ../../../scutsMacros/src
7   --cp ../../../scutsMCore/src
8   --cp .
9   --x bin/Example
68 samples/06_Monoid/MonoidSample.hx
... ... @@ -1,68 +0,0 @@
1   -package ;
2   -
3   -import hots.classes.Collection;
4   -import hots.classes.Foldable;
5   -import hots.classes.Monoid;
6   -import hots.instances.IntProductMonoid;
7   -import hots.Of;
8   -import hots.instances.OptionMonoid;
9   -import hots.instances.OptionSemigroup;
10   -import hots.instances.ArrayMonoid;
11   -import hots.instances.ArraySemigroup;
12   -import hots.instances.Tup2Monoid;
13   -import hots.instances.StringMonoid;
14   -import hots.instances.StringSemigroup;
15   -import hots.instances.IntSumMonoid;
16   -import hots.instances.IntSumSemigroup;
17   -
18   -import scuts.core.types.Tup2;
19   -
20   -using hots.macros.TcContext;
21   -using hots.macros.Box;
22   -
23   -import scuts.core.types.Option;
24   -
25   -class MonoidSample
26   -{
27   -
28   -
29   -
30   - public static function main ()
31   - {
32   - {
33   - var a = Some([1,2,3]);
34   - var b = Some([4,5,6]);
35   -
36   - var m = a.tc(Monoid);
37   -
38   - trace(m.append(a,b));
39   - }
40   - {
41   - var a = Some(7);
42   - var b = Some(9);
43   -
44   -
45   - var m = a.tc(Monoid);
46   -
47   - trace(m.append(a,b));
48   - }
49   -
50   - {
51   - var a = Some(7);
52   - var b = Some(9);
53   -
54   - var productMonoid = IntProductMonoid.get();
55   -
56   - var m = a.tc(Monoid, [productMonoid]);
57   -
58   - trace(m.append(a,b));
59   - }
60   -
61   -
62   -
63   - }
64   -
65   -
66   -}
67   -
68   -
5 samples/06_Monoid/all.hxml
... ... @@ -1,5 +0,0 @@
1   -neko.hxml
2   -cpp.hxml
3   -flash.hxml
4   -js.hxml
5   -php.hxml
9 samples/06_Monoid/cpp.hxml
... ... @@ -1,9 +0,0 @@
1   -main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   --cp ../../../hots/src
5   --cp ../../../scutsMacros/src
6   --cp ../../../scutsMCore/src
7   --cpp bin/cpp
8   ---next
9   --cmd bin\cpp\ListSample.exe
8 samples/06_Monoid/flash.hxml
... ... @@ -1,8 +0,0 @@
1   -main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   --cp ../../../hots/src
5   --cp ../../../scutsMacros/src
6   --cp ../../../scutsMCore/src
7   --swf-header 1200:900:31:FFFFFF
8   --swf bin/Example.swf
7 samples/06_Monoid/js.hxml
... ... @@ -1,7 +0,0 @@
1   -main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   --cp ../../../hots/src
5   --cp ../../../scutsMacros/src
6   --cp ../../../scutsMCore/src
7   --js bin/Example.js
1  samples/06_Monoid/main.hxml
... ... @@ -1 +0,0 @@
1   --main MonoidSample
9 samples/06_Monoid/neko.hxml
... ... @@ -1,9 +0,0 @@
1   -main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   -
5   --cp ../../../hots/src
6   --cp ../../../scutsMacros/src
7   --cp ../../../scutsMCore/src
8   --cp .
9   --x bin/Example.n
7 samples/06_Monoid/php.hxml
... ... @@ -1,7 +0,0 @@
1   --main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   --cp ../../../hots/src
5   --cp ../../../scutsMacros/src
6   --cp ../../../scutsMCore/src
7   --php bin/php
73 samples/07_GenEq/GenEqSample.hx
... ... @@ -1,73 +0,0 @@
1   -package ;
2   -
3   -import haxe.macro.MacroType;
4   -import hots.classes.Collection;
5   -import hots.classes.Eq;
6   -import hots.classes.Foldable;
7   -import hots.classes.Monoid;
8   -import hots.instances.IntProductMonoid;
9   -
10   -import hots.Of;
11   -import hots.instances.OptionMonoid;
12   -import hots.instances.OptionSemigroup;
13   -import hots.instances.ArrayMonoid;
14   -import hots.instances.ArraySemigroup;
15   -import hots.instances.Tup2Monoid;
16   -import hots.instances.StringMonoid;
17   -import hots.instances.StringSemigroup;
18   -import hots.instances.IntSumMonoid;
19   -import hots.instances.IntSumSemigroup;
20   -
21   -import hots.instances.StringEq;
22   -
23   -
24   -
25   -import scuts.core.types.Tup2;
26   -
27   -using hots.macros.TcContext;
28   -using hots.macros.Box;
29   -
30   -import scuts.core.types.Option;
31   -
32   -enum MyEnum {
33   - Password(s:String);
34   - User(s:String);
35   - Rec(a:MyEnum);
36   -}
37   -
38   -typedef MyEnumEq = MacroType<[ hots.macros.GenEq.forType(MyEnum) ]>
39   -
40   -class GenEqSample
41   -{
42   -
43   -
44   -
45   - public static function main ()
46   - {
47   - {
48   - var a = Password("foo");
49   - var b = Password("bar");
50   - var c = Password("foo");
51   - var d = User("test");
52   - var e = User("test2");
53   - var f = Rec(a);
54   - var g = Rec(c);
55   -
56   - var eq = a.tc(Eq);
57   -
58   - trace(eq.eq(a,b));
59   - trace(eq.eq(a,c));
60   - trace(eq.eq(d,a));
61   - trace(eq.eq(f,g));
62   -
63   -
64   - }
65   -
66   -
67   -
68   - }
69   -
70   -
71   -}
72   -
73   -
5 samples/07_GenEq/all.hxml
... ... @@ -1,5 +0,0 @@
1   -neko.hxml
2   -cpp.hxml
3   -flash.hxml
4   -js.hxml
5   -php.hxml
9 samples/07_GenEq/cpp.hxml
... ... @@ -1,9 +0,0 @@
1   -main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   --cp ../../../hots/src
5   --cp ../../../scutsMacros/src
6   --cp ../../../scutsMCore/src
7   --cpp bin/cpp
8   ---next
9   --cmd bin\cpp\ListSample.exe
8 samples/07_GenEq/flash.hxml
... ... @@ -1,8 +0,0 @@
1   -main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   --cp ../../../hots/src
5   --cp ../../../scutsMacros/src
6   --cp ../../../scutsMCore/src
7   --swf-header 1200:900:31:FFFFFF
8   --swf bin/Example.swf
7 samples/07_GenEq/js.hxml
... ... @@ -1,7 +0,0 @@
1   -main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   --cp ../../../hots/src
5   --cp ../../../scutsMacros/src
6   --cp ../../../scutsMCore/src
7   --js bin/Example.js
1  samples/07_GenEq/main.hxml
... ... @@ -1 +0,0 @@
1   --main GenEqSample
9 samples/07_GenEq/neko.hxml
... ... @@ -1,9 +0,0 @@
1   -main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   -
5   --cp ../../../hots/src
6   --cp ../../../scutsMacros/src
7   --cp ../../../scutsMCore/src
8   --cp .
9   --x bin/Example.n
7 samples/07_GenEq/php.hxml
... ... @@ -1,7 +0,0 @@
1   --main.hxml
2   --cp ../../src
3   --cp ../../../scutsCore/src
4   --cp ../../../hots/src
5   --cp ../../../scutsMacros/src
6   --cp ../../../scutsMCore/src
7   --php bin/php
7 src/hots/Hots.hx
... ... @@ -0,0 +1,7 @@
  1 +package hots;
  2 +
  3 +import hots.macros.HotsMacros;
  4 +
  5 +typedef Hots = HotsMacros;
  6 +
  7 +
94 src/hots/Identity.hx
... ... @@ -0,0 +1,94 @@
  1 +package hots;
  2 +#if macro
  3 +private typedef IR = hots.macros.ImplicitResolver;
  4 +import haxe.macro.Expr;
  5 +
  6 +#end
  7 +
  8 +import scuts.core.types.Option;
  9 +
  10 +private typedef Of_<M,A> = Dynamic;
  11 +private typedef OfOf_<M,A,B> = Dynamic;
  12 +
  13 +
  14 +
  15 +class Identity
  16 +{
  17 +
  18 + @:macro public static function pure <M,A,B>(e:String):ExprOf<Of_<M,B>>
  19 + {
  20 + return IR.implicitByType("hots.classes.Pointed<"+e+">");
  21 + }
  22 +
  23 + @:macro public static function flatMap <M,A,B>(e:ExprOf<Of_<M,A>>, f:ExprOf<A->Of_<M,B>>):ExprOf<Of_<M,B>>
  24 + {
  25 + return IR.apply(macro hots.extensions.Monads.flatMap, [e,f]);
  26 + }
  27 +
  28 + @:macro public static function filter <M,A>(e:ExprOf<Of_<M,A>>, f:ExprOf<A->Bool>):ExprOf<Of_<M,A>>
  29 + {
  30 + return IR.apply(macro hots.extensions.MonadZeros.filter, [e,f]);
  31 + }
  32 +
  33 + @:macro public static function map <M,A,B>(e:ExprOf<Of_<M,A>>, f:ExprOf<A->B>):ExprOf<Of_<M,B>>
  34 + {
  35 + return IR.apply(macro hots.extensions.Monads.map, [e,f]);
  36 + }
  37 +
  38 +
  39 + @:macro public static function eq <T>(e1:ExprOf<T>, e2:ExprOf<T>):ExprOf<Bool>
  40 + {
  41 + return IR.apply(macro hots.extensions.Eqs.eq, [e1,e2]);
  42 + }
  43 +
  44 + @:macro public static function show <T>(e1:ExprOf<T>):ExprOf<String>
  45 + {
  46 + return IR.apply(macro hots.extensions.Shows.show, [e1]);
  47 + }
  48 +
  49 + @:macro public static function append <T>(e1:ExprOf<T>, e2:ExprOf<T>):ExprOf<T>
  50 + {
  51 + return IR.apply(macro hots.extensions.Monoids.append, [e1,e2]);
  52 + }
  53 +
  54 + @:macro public static function next <M,A,B,C>(e1:ExprOf<OfOf<M,A,B>>, e2:ExprOf<OfOf<M,B,C>>):ExprOf<OfOf<M,A,C>>
  55 + {
  56 + return IR.apply(macro hots.extensions.Arrows.next, [e1,e2]);
  57 + }
  58 +
  59 + @:macro public static function optionT (e1:ExprOf<Dynamic>):ExprOf<Dynamic>
  60 + {
  61 + return IR.apply(macro hots.box.OptionBox.optionT, [e1]);
  62 + }
  63 +
  64 + @:macro public static function optionFT (e1:ExprOf<Dynamic>):ExprOf<Dynamic>
  65 + {
  66 + return IR.apply(macro hots.box.OptionBox.boxFT, [e1]);
  67 + }
  68 +
  69 +
  70 + @:macro public static function arrayT (e1:ExprOf<Dynamic>):ExprOf<Dynamic>
  71 + {
  72 + return IR.apply(macro hots.box.ArrayBox.arrayT, [e1]);
  73 + }
  74 +
  75 + @:macro public static function arrayFT (e1:ExprOf<Dynamic>):ExprOf<Dynamic>
  76 + {
  77 + return IR.apply(macro hots.box.ArrayBox.boxFT, [e1]);
  78 + }
  79 +
  80 + @:macro public static function validationT (e1:ExprOf<Dynamic>):ExprOf<Dynamic>
  81 + {
  82 + return IR.apply(macro hots.box.ValidationBox.validationT, [e1]);
  83 + }
  84 +
  85 + @:macro public static function validationFT (e1:ExprOf<Dynamic>):ExprOf<Dynamic>
  86 + {
  87 + return IR.apply(macro hots.box.ValidationBox.boxFT, [e1]);
  88 + }
  89 +
  90 +
  91 +
  92 +
  93 +
  94 +}
3  src/hots/Implicit.hx
... ... @@ -0,0 +1,3 @@
  1 +package hots;
  2 +
  3 +typedef Implicit<T> = T;
191 src/hots/ImplicitCasts.hx
... ... @@ -0,0 +1,191 @@
  1 +package hots;
  2 +import hots.box.ArrayBox;
  3 +import hots.box.FunctionBox;
  4 +import hots.box.OptionBox;
  5 +import hots.box.ValidationBox;
  6 +import hots.instances.ArrayOf;
  7 +import hots.instances.ArrayTOf;
  8 +import hots.instances.FunctionOfOf;
  9 +import hots.instances.OptionOf;
  10 +import hots.instances.OptionTOf;
  11 +import hots.instances.ValidationOf;
  12 +import hots.instances.ValidationTOf;
  13 +import scuts.core.types.Option;
  14 +import scuts.core.types.Validation;
  15 +
  16 +// Option Casts
  17 +
  18 +class OptionOf_Casts
  19 +{
  20 + public static inline function implicitUpcast <T>(a:Option<T>):OptionOf<T>
  21 + {
  22 + return OptionBox.box(a);
  23 + }
  24 +
  25 + public static inline function implicitDowncast <T>(a:OptionOf<T>):Option<T>
  26 + {
  27 + return OptionBox.unbox(a);
  28 + }
  29 +}
  30 +
  31 +class OptionOf_Function_Casts
  32 +{
  33 + public static inline function implicitUpcast <T,X>(a:X->Option<T>):X->OptionOf<T>
  34 + {
  35 + return OptionBox.boxF(a);
  36 + }
  37 +
  38 + public static inline function implicitDowncast <T,X>(a:X->OptionOf<T>):X->Option<T>
  39 + {
  40 + return OptionBox.unboxF(a);
  41 + }
  42 +}
  43 +
  44 +class OptionTOf_Function_Casts
  45 +{
  46 + public static inline function implicitUpcast <M,T,X>(a:X->Of<M, Option<T>>)
  47 + {
  48 + return OptionBox.boxFT(a);
  49 + }
  50 + public static inline function implicitDowncast <M,T,X>(a:X->OptionTOf<M,T> ):X->Of<M, Option<T>>
  51 + {
  52 + return OptionBox.unboxFT(a);
  53 + }
  54 +}
  55 +
  56 +class OptionTOf_Casts
  57 +{
  58 + public static inline function implicitUpcast <M, T>(a:Of<M, Option<T>>):OptionTOf<M,T>
  59 + {
  60 + return OptionBox.boxT(a);
  61 + }
  62 +
  63 + public static inline function implicitDowncast <M, T>(a:OptionTOf<M,T>):Of<M, Option<T>>
  64 + {
  65 + return OptionBox.unboxT(a);
  66 + }
  67 +}
  68 +
  69 +// Validation Casts
  70 +
  71 +class ValidationOf_Casts
  72 +{
  73 + public static inline function implicitUpcast <F,S>(a:Validation<F,S>):ValidationOf<F,S>
  74 + {
  75 + return ValidationBox.box(a);
  76 + }
  77 +
  78 + public static inline function implicitDowncast <F,S>(a:ValidationOf<F,S>):Validation<F,S>
  79 + {
  80 + return ValidationBox.unbox(a);
  81 + }
  82 +}
  83 +
  84 +class ValidationOf_Function_Casts
  85 +{
  86 + public static inline function implicitUpcast <F,S,X>(a:X->Validation<F,S>):X->ValidationOf<F,S>
  87 + {
  88 + return ValidationBox.boxF(a);
  89 + }
  90 +
  91 + public static inline function implicitDowncast <F,S,X>(a:X->ValidationOf<F,S>):X->Validation<F,S>
  92 + {
  93 + return ValidationBox.unboxF(a);
  94 + }
  95 +}
  96 +
  97 +class ValidationTOf_Function_Casts
  98 +{
  99 + public static inline function implicitUpcast <M,F,S,X>(a:X->Of<M, Validation<F,S>>)
  100 + {
  101 + return ValidationBox.boxFT(a);
  102 + }
  103 + public static inline function implicitDowncast <M,F,S,X>(a:X->ValidationTOf<M,F,S> ):X->Of<M, Validation<F,S>>
  104 + {
  105 + return ValidationBox.unboxFT(a);
  106 + }
  107 +}
  108 +
  109 +class ValidationTOf_Casts
  110 +{
  111 + public static inline function implicitUpcast <M, F,S>(a:Of<M, Validation<F,S>>):ValidationTOf<M,F,S>
  112 + {
  113 + return ValidationBox.boxT(a);
  114 + }
  115 +
  116 + public static inline function implicitDowncast <M, F,S>(a:ValidationTOf<M,F,S>):Of<M, Validation<F,S>>
  117 + {
  118 + return ValidationBox.unboxT(a);
  119 + }
  120 +}
  121 +
  122 +
  123 +// Array Casts
  124 +
  125 +class ArrayTOf_Casts
  126 +{
  127 + public static inline function implicitUpcast <M,T>(a:Of<M, Array<T>>):ArrayTOf<M,T>
  128 + {
  129 + return ArrayBox.boxT(a);
  130 + }
  131 + public static inline function implicitDowncast <M,T>(a:ArrayTOf<M,T> ):Of<M, Array<T>>
  132 + {
  133 + return ArrayBox.unboxT(a);
  134 + }
  135 +
  136 +
  137 +}
  138 +
  139 +
  140 +
  141 +
  142 +class ArrayTOf_Function_Casts
  143 +{
  144 + public static inline function implicitUpcast <M,T,X>(a:X->Of<M, Array<T>>)
  145 + {
  146 + return ArrayBox.boxFT(a);
  147 + }
  148 +
  149 +}
  150 +
  151 +
  152 +
  153 +
  154 +
  155 +
  156 +class ArrayOf_Casts
  157 +{
  158 + public static inline function implicitUpcast <T>(a:Array<T>):ArrayOf<T>
  159 + {
  160 + return ArrayBox.box(a);
  161 + }
  162 +
  163 + public static inline function implicitDowncast <T>(a:ArrayOf<T>):Array<T>
  164 + {
  165 + return ArrayBox.unbox(a);
  166 + }
  167 +}
  168 +
  169 +class ArrayOf_Function_Casts
  170 +{
  171 + public static inline function implicitUpcast <X,T>(a:X->Array<T>):X->ArrayOf<T>
  172 + {
  173 + return ArrayBox.boxF(a);
  174 + }
  175 + public static inline function implicitDowncast <X,T>(a:X->ArrayOf<T>):X->Array<T>
  176 + {
  177 + return ArrayBox.unboxF(a);
  178 + }
  179 +}
  180 +
  181 +class Function_Arrow_Casts
  182 +{
  183 + public static inline function implicitUpcast <A,B>(f:A->B):FunctionOfOf<A, B>
  184 + {
  185 + return FunctionBox.asArrow(f);
  186 + }
  187 + public static inline function implicitDowncast <A,B>(f:FunctionOfOf<A, B>):A->B
  188 + {
  189 + return FunctionBox.runArrow(f);
  190 + }
  191 +}
6 src/hots/ImplicitConversion.hx
... ... @@ -0,0 +1,6 @@
  1 +package hots;
  2 +
  3 +
  4 +
  5 +
  6 +typedef ImplicitConversion<A,B > = { __impFrom:Void->A, __impTo:Void->B }
5 src/hots/ImplicitObject.hx
... ... @@ -0,0 +1,5 @@
  1 +package hots;
  2 +
  3 +class ImplicitGetter {}
  4 +
  5 +typedef ImplicitObject<A> = ImplicitGetter -> A;
419 src/hots/Objects.hx
... ... @@ -0,0 +1,419 @@
  1 +package hots;
  2 +import hots.classes.Applicative;
  3 +import hots.classes.Applicative;
  4 +import hots.classes.Arrow;
  5 +import hots.classes.Eq;
  6 +import hots.classes.Functor;
  7 +import hots.classes.Monad;
  8 +import hots.classes.MonadZero;
  9 +import hots.classes.Monoid;
  10 +import hots.classes.Pointed;
  11 +import hots.classes.Semigroup;
  12 +import hots.classes.Show;
  13 +import hots.extensions.Shows;
  14 +import hots.instances.ArrayEq;
  15 +import hots.instances.ArrayMonoid;
  16 +import hots.instances.ArrayOfApplicative;
  17 +import hots.instances.ArrayOfFoldable;
  18 +import hots.instances.ArrayOfFunctor;
  19 +import hots.instances.ArrayOfMonad;
  20 +import hots.instances.ArrayOfMonadZero;
  21 +import hots.instances.ArrayOfPointed;