Skip to content

Instantly share code, notes, and snippets.

View DmytroMitin's full-sized avatar
😎
everything is ok

Dmytro Mitin DmytroMitin

😎
everything is ok
View GitHub Profile
import Macros.{MyClonable, MyClonableTC}
object App {
class A(val i: Int)(implicit val myClonableTC: MyClonableTC[A]) extends MyClonable { type Self = A }
class B(val s: String)(implicit val myClonableTC: MyClonableTC[B]) extends MyClonable { type Self = B }
val a: MyClonable = new A(1)
val b: MyClonable = new B("bbb")
type T_MAX_LATTICE[T] = T;
trait C_TEST_COLL[T_Result, T_T] extends C_TYPE[T_Result] with C_TINY[T_Result] {
type T_IntegerMaxLattice;
val t_IntegerMaxLattice: C_TYPE[T_IntegerMaxLattice] with C_MAX_LATTICE[T_IntegerMaxLattice, T_Integer];
type T_Integers;
val t_Integers: C_TYPE[T_Integers] with C_SET[T_Integers, T_Integer];
}
class M_TEST_COLL[T_T](name : String,val t_T : C_TYPE[T_T] with C_TINY[T_T])
object App {
sealed trait MyType
trait MySubType1 extends MyType
// trait MySubType2 extends MyType
sealed trait OtherTypeClass[S <: MyType] {
type Out <: MyType
}
object OtherTypeClass {
type Aux[S <: MyType, O <: MyType] = TypeClass[S] {type Out = O}
@DmytroMitin
DmytroMitin / opaque.hs
Created May 23, 2020 08:09 — forked from luqui/opaque.hs
Natural transformations never need to type switch
{-# LANGUAGE RankNTypes, TypeApplications #-}
-- We give a constructive proof that any natural transformation that uses
-- a type switch in its implementation can also be implemented without the type switch,
-- as long as the domain functor is finitely Traversable (and the argument can easily
-- be modified to drop the finiteness property).
-- We do this by providing a function `opaquify` which takes an n.t. which may do
-- type switches, and returns an equivalent n.t. which does not.
import scala.reflect.ClassTag
object DefaultType extends App {
case class AttributeMeasure[T](name: String)(implicit ev: reflect.ClassTag[T]) {
def ct: ClassTag[T] = ev
}
/** This almost works, except for the case:
* {{{
@DmytroMitin
DmytroMitin / 1
Last active June 2, 2020 12:43
Pattern matching in Dotty 0.24.0-RC1
// x match {
// case _: Box[Square] | _: Box[Circle] => ???
// }
[info] matchResult10[Nothing]:
[info] {
[info] case val x13: Object = App.x()
[info] matchAlts1[Unit]:
[info] {
[info] matchAlts2[Unit]:
import scala.reflect.ClassTag
object Bottom extends App {
class C[T](implicit ev: reflect.ClassTag[T]) {
def ct: reflect.ClassTag[T] = ev
}
class X[U, -T]
object X {
@DmytroMitin
DmytroMitin / TypeLevelBacktrack.scala
Created June 6, 2020 23:52 — forked from OlivierBlanvillain/TypeLevelBacktrack.scala
Example of a workaround for the absence of backtracking in implicit resolution. Original problem statement: https://gist.github.com/atamborrino/daa451aea542e912c2d6
import shapeless.{HList, HNil, ::}
import shapeless.ops.hlist.{Selector, Prepend}
import shapeless.test.illTyped
object TypeLevelBacktrack extends App {
/** [[Parent]] / [[Child]] relationship, father side. */
trait FatherOf[Parent, Child]
/** [[Parent]] / [[Child]] relationship, mother side */
trait MotherOf[Parent, Child]
//decompiled from __wrapper$1$a077cb72a4ee423291aac7dfb47454b9$.class
package __wrapper$1$a077cb72a4ee423291aac7dfb47454b9;
import scala.Option;
import scala.Product;
import scala.Serializable;
import scala.Some;
import scala.Tuple4;
import scala.collection.Iterator;
import scala.runtime.AbstractFunction4;
import org.apache.spark.sql.{Dataset, Encoder, SparkSession}
import scala.reflect.runtime
import scala.reflect.runtime.universe._
import scala.tools.reflect.ToolBox
object App {
lazy val spark = SparkSession.builder
.appName(getClass.getName)
.master("local")
.getOrCreate()