Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

removed OfT, seems unnessecary now

added tests
  • Loading branch information...
commit cf27b5e6b04e5f3fa872d7507b35733e18a73e87 1 parent ca506b5
@frabbit frabbit authored
View
6 src/hots/Objects.hx
@@ -328,19 +328,19 @@ private typedef ValidationIn<F> = Validation<F,In>
class OptionTOf_Monad_Obj
{
- public static inline function implicitObj <M>(_:IOMonad<OfT<M,OptionIn>>, base: IMonad<M>):Monad<OfT<M,OptionIn>> return O.optionTMonad(base)
+ public static inline function implicitObj <M>(_:IOMonad<Of<M,OptionIn>>, base: IMonad<M>):Monad<Of<M,OptionIn>> return O.optionTMonad(base)
}
class ValidationTOf_Monad_Obj
{
- public static inline function implicitObj <M,F>(_:IOMonad<OfT<M,ValidationIn<F>>>, base: IMonad<M>):Monad<OfT<M,ValidationIn<F>>> return O.validationTMonad(base)
+ public static inline function implicitObj <M,F>(_:IOMonad<Of<M,ValidationIn<F>>>, base: IMonad<M>):Monad<Of<M,ValidationIn<F>>> return O.validationTMonad(base)
}
class ArrayTOf_Monad_Obj
{
- public static inline function implicitObj <M>(_:IOMonad<OfT<M,ArrayIn>>, base: IMonad<M>):Monad<OfT<M,ArrayIn>> return O.arrayTMonad(base)
+ public static inline function implicitObj <M>(_:IOMonad<Of<M,ArrayIn>>, base: IMonad<M>):Monad<Of<M,ArrayIn>> return O.arrayTMonad(base)
}
private typedef IArrow<X> = ImplicitObject<Arrow<X>>;
View
6 src/hots/Of.hx
@@ -15,11 +15,13 @@ class Of<M,A> { }
@:native('Dynamic')
#end
*/
-//typedef OfT<M,A> = Of<M,A>;
+//typedef Of<M,A> = Of<M,A>;
+/*
#if flash
@:native('Object')
#else
@:native('Dynamic')
#end
-class OfT<M,A> { }
+*/
+//class OfT<M,A> { }
View
2  src/hots/OfOf.hx
@@ -9,7 +9,7 @@ import hots.Of;
#else
@:native('Dynamic')
#end
-typedef OfOf<M,A,B> = Of<OfT<M, A>, B>;
+typedef OfOf<M,A,B> = Of<Of<M, A>, B>;
View
2  src/hots/instances/ArrayTOfApplicative.hx
@@ -14,7 +14,7 @@ using hots.box.ArrayBox;
-class ArrayTOfApplicative<M> extends ApplicativeAbstract<OfT<M,Array<In>>> {
+class ArrayTOfApplicative<M> extends ApplicativeAbstract<Of<M,Array<In>>> {
var appM:Applicative<M>;
View
2  src/hots/instances/ArrayTOfFunctor.hx
@@ -11,7 +11,7 @@ using hots.box.ArrayBox;
-class ArrayTOfFunctor<M> extends FunctorAbstract<OfT<M,Array<In>>>
+class ArrayTOfFunctor<M> extends FunctorAbstract<Of<M,Array<In>>>
{
var functorM:Functor<M>;
View
2  src/hots/instances/ArrayTOfMonad.hx
@@ -10,7 +10,7 @@ import scuts.core.extensions.Arrays;
using hots.box.ArrayBox;
-class ArrayTOfMonad<M> extends MonadAbstract<OfT<M,Array<In>>> {
+class ArrayTOfMonad<M> extends MonadAbstract<Of<M,Array<In>>> {
var monadM:Monad<M>;
View
2  src/hots/instances/ArrayTOfPointed.hx
@@ -13,7 +13,7 @@ import hots.classes.Functor;
using hots.box.ArrayBox;
-class ArrayTOfPointed<M> extends PointedAbstract<OfT<M,Array<In>>>
+class ArrayTOfPointed<M> extends PointedAbstract<Of<M,Array<In>>>
{
var pointedM:Pointed<M>;
View
2  src/hots/instances/OptionTOfApplicative.hx
@@ -14,7 +14,7 @@ using hots.box.OptionBox;
-class OptionTOfApplicative<M> extends ApplicativeAbstract<OfT<M,Option<In>>> {
+class OptionTOfApplicative<M> extends ApplicativeAbstract<Of<M,Option<In>>> {
var applicativeM:Applicative<M>;
View
2  src/hots/instances/OptionTOfFunctor.hx
@@ -10,7 +10,7 @@ import scuts.core.types.Option;
private typedef B = hots.box.OptionBox;
-class OptionTOfFunctor<M> extends FunctorAbstract<OfT<M, Option<In>>> {
+class OptionTOfFunctor<M> extends FunctorAbstract<Of<M, Option<In>>> {
var functorM:Functor<M>;
View
2  src/hots/instances/OptionTOfMonad.hx
@@ -12,7 +12,7 @@ import hots.classes.MonadAbstract;
using hots.box.OptionBox;
-class OptionTOfMonad<M> extends MonadAbstract<OfT<M, Option<In>>> {
+class OptionTOfMonad<M> extends MonadAbstract<Of<M, Option<In>>> {
var base:Monad<M>;
View
2  src/hots/instances/OptionTOfMonadZero.hx
@@ -9,7 +9,7 @@ import hots.classes.Monad;
using hots.box.OptionBox;
-class OptionTOfMonadZero<M> extends MonadZeroAbstract<OfT<M, Option<In>>> {
+class OptionTOfMonadZero<M> extends MonadZeroAbstract<Of<M, Option<In>>> {
var monadM:Monad<M>;
View
2  src/hots/instances/OptionTOfPointed.hx
@@ -14,7 +14,7 @@ using hots.box.OptionBox;
-class OptionTOfPointed<M> extends PointedAbstract<OfT<M,Option<In>>> {
+class OptionTOfPointed<M> extends PointedAbstract<Of<M,Option<In>>> {
var pointedM:Pointed<M>;
View
2  src/hots/instances/ValidationTOfApplicative.hx
@@ -15,7 +15,7 @@ using hots.box.ValidationBox;
-class ValidationTOfApplicative<M,F> extends ApplicativeAbstract<OfT<M,Validation<F,In>>>
+class ValidationTOfApplicative<M,F> extends ApplicativeAbstract<Of<M,Validation<F,In>>>
{
var applicativeM:Applicative<M>;
View
2  src/hots/instances/ValidationTOfFunctor.hx
@@ -12,7 +12,7 @@ import scuts.core.types.Option;
using hots.box.ValidationBox;
-class ValidationTOfFunctor<M, F> extends FunctorAbstract<OfT<M, Validation<F, In>>>
+class ValidationTOfFunctor<M, F> extends FunctorAbstract<Of<M, Validation<F, In>>>
{
var functorM:Functor<M>;
View
2  src/hots/instances/ValidationTOfMonad.hx
@@ -13,7 +13,7 @@ import hots.classes.MonadAbstract;
using hots.box.ValidationBox;
-class ValidationTOfMonad<M,F> extends MonadAbstract<OfT<M, Validation<F,In>>> {
+class ValidationTOfMonad<M,F> extends MonadAbstract<Of<M, Validation<F,In>>> {
var base:Monad<M>;
View
2  src/hots/instances/ValidationTOfPointed.hx
@@ -15,7 +15,7 @@ using scuts.core.extensions.Validations;
using hots.box.ValidationBox;
-class ValidationTOfPointed<F, M> extends PointedAbstract<OfT<M,Validation<F, In>>>
+class ValidationTOfPointed<F, M> extends PointedAbstract<Of<M,Validation<F, In>>>
{
var pointedM:Pointed<M>;
View
28 src/hots/macros/ImplicitResolver.hx
@@ -1,5 +1,12 @@
package hots.macros;
+// unwanted dependecies
+import scuts.mcore.Check;
+
+import scuts.mcore.Print;
+
+
+
import haxe.Log;
import haxe.macro.Expr;
import haxe.macro.Context;
@@ -10,11 +17,7 @@ import hots.Implicit;
import scuts.core.extensions.Arrays;
import scuts.core.types.Tup2;
import scuts.core.types.Validation;
-import scuts.mcore.Check;
-import scuts.mcore.extensions.Exprs;
-import scuts.mcore.MContext;
-import scuts.mcore.Print;
import scuts.Scuts;
using scuts.core.extensions.Arrays;
import scuts.core.types.Option;
@@ -314,13 +317,20 @@ class ImplicitResolver
- var f = simplifyFunction(f, params);
- //f = f;
- //printExpr(f);
- //printExprs(params);
+ //f = f;
+ #if scutsDebug
+ trace("-------------passed function-------------");
+ printExpr(f, "Pre Simplify");
+ var f = simplifyFunction(f, params);
+ printExpr(f, "Post Simplify");
+ trace("-------------passed function-------------");
+ #else
+ var f = simplifyFunction(f, params);
+ #end
+ //printExprs(params);
if (params.any(function (x) return Check.isUnsafeCast(x))) {
@@ -334,7 +344,7 @@ class ImplicitResolver
Scuts.error("null is not allowed as paramter for function" + prettyTypeOfExpr(f));
}
- #if secutsDebug
+ #if scutsDebug1
trace("------------ Apply Started After Simplify -------------");
printTypeOfExpr(f, "function Type");
printTypeOfExprs(params, "param Types");
View
2  test/AllTests.hx
@@ -4,6 +4,7 @@ package;
import hots.EqTest;
+import hots.instances.ArrayOfMonadTest;
import hots.MonadTransformersTest;
import hots.ImplicitScopeTests;
@@ -29,6 +30,7 @@ class AllTests
runner.addCase(new MonadsTest());
runner.addCase(new MonadTransformersTest());
runner.addCase(new EqTest());
+ runner.addCase(new ArrayOfMonadTest());
View
41 test/hots/EqTest.hx
@@ -0,0 +1,41 @@
+package hots;
+import scuts.core.types.Option;
+import scuts.core.types.Tup2;
+
+using hots.Identity;
+using hots.ImplicitCasts;
+using hots.Objects;
+
+import scuts.core.types.Validation;
+
+private typedef A = utest.Assert;
+
+class EqTest
+{
+
+ public function new() { }
+
+
+ public static function testNestedStructure ()
+ {
+ var a = Some([Tup2.create(1,2), Tup2.create(2,3)]);
+ var b = Some([Tup2.create(1,2), Tup2.create(2,3)]);
+ var c = Some([Tup2.create(3,2), Tup2.create(2,3)]);
+
+ A.isTrue(a.eq(b));
+ A.isTrue(!a.eq(c));
+ }
+ public static function testNestedStructure2 ()
+ {
+ var d:Validation<String,String> = Success("gh");
+
+ var a = Some([Tup2.create(1,Some(Tup2.create(d,1.1))), Tup2.create(3,Some(Tup2.create(d,1.1)))]);
+ var b = Some([Tup2.create(1,Some(Tup2.create(d,1.1))), Tup2.create(3,Some(Tup2.create(d,1.1)))]);
+ var c = Some([Tup2.create(1,Some(Tup2.create(d,1.1))), Tup2.create(3,Some(Tup2.create(d,1.2)))]);
+
+ A.isTrue(a.eq(b));
+ A.isTrue(!a.eq(c));
+ }
+
+
+}
View
40 test/hots/instances/ArrayOfMonadTest.hx
@@ -0,0 +1,40 @@
+package hots.instances;
+import hots.Objects;
+import scuts.Assert;
+import utest.Assert;
+
+using hots.Identity;
+using hots.ImplicitCasts;
+using hots.Objects;
+
+class ArrayOfMonadTest
+{
+
+ public function new()
+ {
+
+ }
+
+ /*
+ (return x) >>= f == f x
+ m >>= return == m
+ (m >>= f) >>= g == m >>= (\x -> f x >>= g)
+ */
+
+ //TODO this currently fails because m.pure(3) gets inlined and accesses a private field (m.applicative.pure),
+ //see MonadAbstract and this causes the known inlining problem
+ public function testLaws () {
+
+
+ /*
+ var m = Objects.arrayMonad;
+
+ var val = 3;
+ var f = function (x) return [x + 1];
+
+ Assert.equals(f(val), m.pure(3).flatMap(f));
+ */
+ Assert.fail();
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.