Skip to content

Commit c2a8761

Browse files
author
Oron Port
authored
Merge pull request #133 from soronpo/caching
Introduce Caching + some other changes
2 parents a2f58c5 + 3ef31f1 commit c2a8761

File tree

20 files changed

+497
-568
lines changed

20 files changed

+497
-568
lines changed

src/main/scala/singleton/ops/impl/GeneralMacros.scala

Lines changed: 482 additions & 484 deletions
Large diffs are not rendered by default.

src/main/scala/singleton/ops/impl/Op.scala

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ trait Op extends HasOut {
1717
type OutDouble <: Double with Singleton
1818
type OutString <: String with Singleton
1919
type OutBoolean <: Boolean with Singleton
20-
type OutSymbol <: Symbol
2120
val value: Out
2221
val isLiteral : Boolean
2322
val valueWide: OutWide
@@ -95,11 +94,3 @@ object OpBoolean {
9594
implicit def impl[O <: Op](implicit o: O) : Aux[O, o.OutBoolean] = new OpBoolean[O] {type Out = o.OutBoolean; val value = o.value.asInstanceOf[o.OutBoolean]}
9695
implicit def conv[O <: Op](op : OpBoolean[O]) : Boolean = op.value
9796
}
98-
99-
@scala.annotation.implicitNotFound(msg = "Unable to prove type argument is a Symbol.")
100-
trait OpSymbol[O <: Op] extends OpCast[Symbol, O]
101-
object OpSymbol {
102-
type Aux[O <: Op, Ret_Out <: Symbol] = OpSymbol[O] {type Out = Ret_Out}
103-
implicit def impl[O <: Op](implicit o: O) : Aux[O, o.OutSymbol] = new OpSymbol[O] {type Out = o.OutSymbol; val value = o.value.asInstanceOf[o.OutSymbol]}
104-
implicit def conv[O <: Op](op : OpSymbol[O]) : Symbol = op.value
105-
}

src/main/scala/singleton/ops/impl/OpId.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ object OpId {
2121
sealed trait ToFloat extends OpId
2222
sealed trait ToDouble extends OpId
2323
sealed trait ToString extends OpId
24-
sealed trait ToSymbol extends OpId
2524
sealed trait IsNat extends OpId
2625
sealed trait IsChar extends OpId
2726
sealed trait IsInt extends OpId
@@ -30,7 +29,6 @@ object OpId {
3029
sealed trait IsDouble extends OpId
3130
sealed trait IsString extends OpId
3231
sealed trait IsBoolean extends OpId
33-
sealed trait IsSymbol extends OpId
3432
sealed trait IsNonLiteral extends OpId
3533
sealed trait GetType extends OpId
3634
sealed trait Reverse extends OpId

src/main/scala/singleton/ops/impl/OpMacros.scala

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ object OpMacro {
2222
OutFloat0 <: Float with Singleton,
2323
OutDouble0 <: Double with Singleton,
2424
OutString0 <: String with Singleton,
25-
OutBoolean0 <: Boolean with Singleton,
26-
OutSymbol0 <: Symbol
25+
OutBoolean0 <: Boolean with Singleton
2726
] = OpMacro[N, S1, S2, S3] {
2827
type OutWide = OutWide0
2928
type Out = Out0
@@ -35,7 +34,6 @@ object OpMacro {
3534
type OutDouble = OutDouble0
3635
type OutString = OutString0
3736
type OutBoolean = OutBoolean0
38-
type OutSymbol = OutSymbol0
3937
}
4038

4139
implicit def call[
@@ -52,8 +50,7 @@ object OpMacro {
5250
OutFloat <: Float with Singleton,
5351
OutDouble <: Double with Singleton,
5452
OutString <: String with Singleton,
55-
OutBoolean <: Boolean with Singleton,
56-
OutSymbol <: Symbol
53+
OutBoolean <: Boolean with Singleton
5754
]: Aux[
5855
N,
5956
S1,
@@ -68,8 +65,7 @@ object OpMacro {
6865
OutFloat,
6966
OutDouble,
7067
OutString,
71-
OutBoolean,
72-
OutSymbol
68+
OutBoolean
7369
] = macro Macro.impl[N, S1, S2, S3]
7470

7571
final class Macro(val c: whitebox.Context) extends GeneralMacros {

src/main/scala/singleton/ops/impl/util.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,4 @@ object std {
1717
type Double = scala.Double
1818
type String = java.lang.String
1919
type Boolean = scala.Boolean
20-
type Symbol = scala.Symbol
2120
}

src/main/scala/singleton/ops/package.scala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package object ops {
1919
type XDouble = Double with Singleton
2020
type XString = String with Singleton
2121
type XBoolean = Boolean with Singleton
22-
type XSymbol = Symbol with Singleton
2322
/////////////////////////////////////////////////
2423

2524
/////////////////////////////////////////////////
@@ -33,7 +32,6 @@ package object ops {
3332
type SafeDouble[P1] = impl.OpDouble[Require[IsDouble[P1]] ==> P1]
3433
type SafeString[P1] = impl.OpString[Require[IsString[P1]] ==> P1]
3534
type SafeBoolean[P1] = impl.OpBoolean[Require[IsBoolean[P1]] ==> P1]
36-
type SafeSymbol[P1] = impl.OpSymbol[ToSymbol[Require[IsSymbol[P1]] ==> P1]]
3735
/////////////////////////////////////////////////
3836

3937
/////////////////////////////////////////////////
@@ -48,7 +46,6 @@ package object ops {
4846
type OpAuxDouble[O <: Op, Ret_Out <: XDouble] = OpDouble.Aux[O, Ret_Out]
4947
type OpAuxString[O <: Op, Ret_Out <: XString] = OpString.Aux[O, Ret_Out]
5048
type OpAuxBoolean[O <: Op, Ret_Out <: XBoolean] = OpBoolean.Aux[O, Ret_Out]
51-
type OpAuxSymbol[O <: Op, Ret_Out <: Symbol] = OpSymbol.Aux[O, Ret_Out]
5249
/////////////////////////////////////////////////
5350

5451
private val NP = W(0)
@@ -103,7 +100,6 @@ package object ops {
103100
type ToFloat[P1] = OpMacro[OpId.ToFloat, P1, NP, NP]
104101
type ToDouble[P1] = OpMacro[OpId.ToDouble, P1, NP, NP]
105102
type ToString[P1] = OpMacro[OpId.ToString, P1, NP, NP]
106-
type ToSymbol[P1] = OpMacro[OpId.ToSymbol, P1, NP, NP]
107103
type IsNat[P1] = OpMacro[OpId.IsNat, P1, NP, NP]
108104
type IsChar[P1] = OpMacro[OpId.IsChar, P1, NP, NP]
109105
type IsInt[P1] = OpMacro[OpId.IsInt, P1, NP, NP]
@@ -112,7 +108,6 @@ package object ops {
112108
type IsDouble[P1] = OpMacro[OpId.IsDouble, P1, NP, NP]
113109
type IsString[P1] = OpMacro[OpId.IsString, P1, NP, NP]
114110
type IsBoolean[P1] = OpMacro[OpId.IsBoolean, P1, NP, NP]
115-
type IsSymbol[P1] = OpMacro[OpId.IsSymbol, P1, NP, NP]
116111
type IsNonLiteral[P1] = OpMacro[OpId.IsNonLiteral, P1, NP, NP]
117112
type Reverse[P1] = OpMacro[OpId.Reverse, P1, NP, NP]
118113
type Negate[P1] = OpMacro[OpId.Negate, P1, NP, NP]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package singleton.ops.impl
2+
3+
object ListZipper {
4+
def apply[T](list1 : List[T], list2 : List[T]) = list1 lazyZip list2
5+
}

src/main/scala_2.13+/singleton/twoface/impl/TwoFaceAny.scala

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ object TwoFaceAny {
158158
def toFloat(implicit tfs : Float.Shell1[ToFloat, T, std.Char]) = tfs(this.getValue)
159159
def toDouble(implicit tfs : Double.Shell1[ToDouble, T, std.Char]) = tfs(this.getValue)
160160
def toStringTF(implicit tfs : String.Shell1[ToString, T, std.Char]) = tfs(this.getValue)
161-
def toSymbol(implicit sym : SafeSymbol[ToSymbol[T]]) : sym.Out = sym.value
162161

163162
def simplify(implicit tfs : Char.Shell1[Id, T, std.Char]) = tfs(this.getValue)
164163
}
@@ -253,7 +252,6 @@ object TwoFaceAny {
253252
def toFloat(implicit tfs : Float.Shell1[ToFloat, T, std.Int]) = tfs(this.getValue)
254253
def toDouble(implicit tfs : Double.Shell1[ToDouble, T, std.Int]) = tfs(this.getValue)
255254
def toStringTF(implicit tfs : String.Shell1[ToString, T, std.Int]) = tfs(this.getValue)
256-
def toSymbol(implicit sym : SafeSymbol[ToSymbol[T]]) : sym.Out = sym.value
257255

258256
def simplify(implicit tfs : Int.Shell1[Id, T, std.Int]) = tfs(this.getValue)
259257
}
@@ -349,7 +347,6 @@ object TwoFaceAny {
349347
def toFloat(implicit tfs : Float.Shell1[ToFloat, T, std.Long]) = tfs(this.getValue)
350348
def toDouble(implicit tfs : Double.Shell1[ToDouble, T, std.Long]) = tfs(this.getValue)
351349
def toStringTF(implicit tfs : String.Shell1[ToString, T, std.Long]) = tfs(this.getValue)
352-
def toSymbol(implicit sym : SafeSymbol[ToSymbol[T]]) : sym.Out = sym.value
353350

354351
def simplify(implicit tfs : Long.Shell1[Id, T, std.Long]) = tfs(this.getValue)
355352
}
@@ -446,7 +443,6 @@ object TwoFaceAny {
446443
def toLong(implicit tfs : Long.Shell1[ToLong, T, std.Float]) = tfs(this.getValue)
447444
def toDouble(implicit tfs : Double.Shell1[ToDouble, T, std.Float]) = tfs(this.getValue)
448445
def toStringTF(implicit tfs : String.Shell1[ToString, T, std.Float]) = tfs(this.getValue)
449-
def toSymbol(implicit sym : SafeSymbol[ToSymbol[T]]) : sym.Out = sym.value
450446

451447
def simplify(implicit tfs : Float.Shell1[Id, T, std.Float]) = tfs(this.getValue)
452448
}
@@ -541,7 +537,6 @@ object TwoFaceAny {
541537
def toLong(implicit tfs : Long.Shell1[ToLong, T, std.Double]) = tfs(this.getValue)
542538
def toFloat(implicit tfs : Float.Shell1[ToFloat, T, std.Double]) = tfs(this.getValue)
543539
def toStringTF(implicit tfs : String.Shell1[ToString, T, std.Double]) = tfs(this.getValue)
544-
def toSymbol(implicit sym : SafeSymbol[ToSymbol[T]]) : sym.Out = sym.value
545540

546541
def simplify(implicit tfs : Double.Shell1[Id, T, std.Double]) = tfs(this.getValue)
547542
}
@@ -577,8 +572,7 @@ object TwoFaceAny {
577572
def toLong(implicit tfs : Long.Shell1[ToLong, T, std.String]) = tfs(this.getValue)
578573
def toFloat(implicit tfs : Float.Shell1[ToFloat, T, std.String]) = tfs(this.getValue)
579574
def toDouble(implicit tfs : Double.Shell1[ToDouble, T, std.String]) = tfs(this.getValue)
580-
def toSymbol(implicit sym : SafeSymbol[ToSymbol[T]]) : sym.Out = sym.value
581-
575+
582576
def simplify(implicit tfs : String.Shell1[Id, T, std.String]) = tfs(this.getValue)
583577
}
584578
final class _String[T](val value : std.String) extends AnyVal with String[T] {
@@ -606,7 +600,6 @@ object TwoFaceAny {
606600
def || [R](r : Boolean[R])(implicit tfs : Boolean.Shell2[||, T, std.Boolean, R, std.Boolean]) = tfs(this.getValue, r.getValue)
607601
def unary_!(implicit tfs : Boolean.Shell1[!, T, std.Boolean]) = tfs(this.getValue)
608602
def toStringTF(implicit tfs : String.Shell1[ToString, T, std.Boolean]) = tfs(this.getValue)
609-
def toSymbol(implicit sym : SafeSymbol[ToSymbol[T]]) : sym.Out = sym.value
610603

611604
def simplify(implicit tfs : Boolean.Shell1[Id, T, std.Boolean]) = tfs(this.getValue)
612605
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package singleton.ops.impl
2+
3+
object ListZipper {
4+
def apply[T](list1 : List[T], list2 : List[T]) = (list1, list2).zipped
5+
}

src/main/scala_2.13-/singleton/twoface/impl/TwoFaceAny.scala

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ object TwoFaceAny {
172172
def toFloat(implicit tfs : Float.Shell1[ToFloat, T, std.Char]) = tfs(this.getValue)
173173
def toDouble(implicit tfs : Double.Shell1[ToDouble, T, std.Char]) = tfs(this.getValue)
174174
def toStringTF(implicit tfs : String.Shell1[ToString, T, std.Char]) = tfs(this.getValue)
175-
def toSymbol(implicit sym : SafeSymbol[ToSymbol[T]]) : sym.Out = sym.value
176175

177176
def simplify(implicit tfs : Char.Shell1[Id, T, std.Char]) = tfs(this.getValue)
178177
}
@@ -267,7 +266,6 @@ object TwoFaceAny {
267266
def toFloat(implicit tfs : Float.Shell1[ToFloat, T, std.Int]) = tfs(this.getValue)
268267
def toDouble(implicit tfs : Double.Shell1[ToDouble, T, std.Int]) = tfs(this.getValue)
269268
def toStringTF(implicit tfs : String.Shell1[ToString, T, std.Int]) = tfs(this.getValue)
270-
def toSymbol(implicit sym : SafeSymbol[ToSymbol[T]]) : sym.Out = sym.value
271269

272270
def simplify(implicit tfs : Int.Shell1[Id, T, std.Int]) = tfs(this.getValue)
273271
}
@@ -363,7 +361,6 @@ object TwoFaceAny {
363361
def toFloat(implicit tfs : Float.Shell1[ToFloat, T, std.Long]) = tfs(this.getValue)
364362
def toDouble(implicit tfs : Double.Shell1[ToDouble, T, std.Long]) = tfs(this.getValue)
365363
def toStringTF(implicit tfs : String.Shell1[ToString, T, std.Long]) = tfs(this.getValue)
366-
def toSymbol(implicit sym : SafeSymbol[ToSymbol[T]]) : sym.Out = sym.value
367364

368365
def simplify(implicit tfs : Long.Shell1[Id, T, std.Long]) = tfs(this.getValue)
369366
}
@@ -460,7 +457,6 @@ object TwoFaceAny {
460457
def toLong(implicit tfs : Long.Shell1[ToLong, T, std.Float]) = tfs(this.getValue)
461458
def toDouble(implicit tfs : Double.Shell1[ToDouble, T, std.Float]) = tfs(this.getValue)
462459
def toStringTF(implicit tfs : String.Shell1[ToString, T, std.Float]) = tfs(this.getValue)
463-
def toSymbol(implicit sym : SafeSymbol[ToSymbol[T]]) : sym.Out = sym.value
464460

465461
def simplify(implicit tfs : Float.Shell1[Id, T, std.Float]) = tfs(this.getValue)
466462
}
@@ -555,7 +551,6 @@ object TwoFaceAny {
555551
def toLong(implicit tfs : Long.Shell1[ToLong, T, std.Double]) = tfs(this.getValue)
556552
def toFloat(implicit tfs : Float.Shell1[ToFloat, T, std.Double]) = tfs(this.getValue)
557553
def toStringTF(implicit tfs : String.Shell1[ToString, T, std.Double]) = tfs(this.getValue)
558-
def toSymbol(implicit sym : SafeSymbol[ToSymbol[T]]) : sym.Out = sym.value
559554

560555
def simplify(implicit tfs : Double.Shell1[Id, T, std.Double]) = tfs(this.getValue)
561556
}
@@ -591,8 +586,7 @@ object TwoFaceAny {
591586
def toLong(implicit tfs : Long.Shell1[ToLong, T, std.String]) = tfs(this.getValue)
592587
def toFloat(implicit tfs : Float.Shell1[ToFloat, T, std.String]) = tfs(this.getValue)
593588
def toDouble(implicit tfs : Double.Shell1[ToDouble, T, std.String]) = tfs(this.getValue)
594-
def toSymbol(implicit sym : SafeSymbol[ToSymbol[T]]) : sym.Out = sym.value
595-
589+
596590
def simplify(implicit tfs : String.Shell1[Id, T, std.String]) = tfs(this.getValue)
597591
}
598592
final class _String[T](val value : std.String) extends AnyVal with String[T] {
@@ -620,7 +614,6 @@ object TwoFaceAny {
620614
def || [R](r : Boolean[R])(implicit tfs : Boolean.Shell2[||, T, std.Boolean, R, std.Boolean]) = tfs(this.getValue, r.getValue)
621615
def unary_!(implicit tfs : Boolean.Shell1[!, T, std.Boolean]) = tfs(this.getValue)
622616
def toStringTF(implicit tfs : String.Shell1[ToString, T, std.Boolean]) = tfs(this.getValue)
623-
def toSymbol(implicit sym : SafeSymbol[ToSymbol[T]]) : sym.Out = sym.value
624617

625618
def simplify(implicit tfs : Boolean.Shell1[Id, T, std.Boolean]) = tfs(this.getValue)
626619
}

0 commit comments

Comments
 (0)