Skip to content

Instantly share code, notes, and snippets.

@KisaragiEffective
Created March 27, 2021 09:17
Show Gist options
  • Save KisaragiEffective/d056f63e21dcd9322e059d7f579ebb33 to your computer and use it in GitHub Desktop.
Save KisaragiEffective/d056f63e21dcd9322e059d7f579ebb33 to your computer and use it in GitHub Desktop.
IDEAのビルドボタンだとコケる問題
@new _root_.scala.annotation.implicitNotFound("Could not find an instance of PositiveInt for ${T}")
abstract trait PositiveInt[T] extends _root_.scala.Any with _root_.scala.Serializable {
def wrapPositive(int: Int): T;
def asInt(t: T): Int
};
object PositiveInt extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
implicit def positiveIntHasOrder[T](implicit evidence$1: PositiveInt[T]): Order[T] = Order.by(PositiveInt[T].asInt);
def unwrap[T](implicit evidence$2: PositiveInt[T]) = (implicitly[PositiveInt[T]].asInt: (() => <empty>));
def callImplicitApply[T](implicit evidence$3: PositiveInt[T]): PositiveInt[T] = PositiveInt[T];
def callExplicitApply[T](implicit evidence$4: PositiveInt[T]): PositiveInt[T] = PositiveInt.apply[T];
@new scala.inline() def apply[T](implicit instance: PositiveInt[T]): PositiveInt[T] = instance;
abstract trait Ops[T] extends scala.AnyRef {
def $init$() = {
()
};
type TypeClassType <: PositiveInt[T];
val typeClassInstance: TypeClassType;
def self: T;
def asInt: Int = typeClassInstance.asInt(self)
};
abstract trait ToPositiveIntOps extends scala.AnyRef {
def $init$() = {
()
};
@new java.lang.SuppressWarnings(scala.Array("org.wartremover.warts.ExplicitImplicitTypes", "org.wartremover.warts.ImplicitConversion")) implicit def toPositiveIntOps[T](target: T)(implicit tc: PositiveInt[T]): Ops[T] {
type TypeClassType = PositiveInt[T]
} = {
final class $anon extends Ops[T] {
def <init>() = {
super.<init>();
()
};
type TypeClassType = PositiveInt[T];
val self = target;
val typeClassInstance: TypeClassType = tc
};
new $anon()
}
};
object nonInheritedOps extends ToPositiveIntOps {
def <init>() = {
super.<init>();
()
}
};
abstract trait AllOps[T] extends Ops[T] {
type TypeClassType <: PositiveInt[T];
val typeClassInstance: TypeClassType
};
object ops extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
@new java.lang.SuppressWarnings(scala.Array("org.wartremover.warts.ExplicitImplicitTypes", "org.wartremover.warts.ImplicitConversion")) implicit def toAllPositiveIntOps[T](target: T)(implicit tc: PositiveInt[T]): AllOps[T] {
type TypeClassType = PositiveInt[T]
} = {
final class $anon extends AllOps[T] {
def <init>() = {
super.<init>();
()
};
type TypeClassType = PositiveInt[T];
val self = target;
val typeClassInstance: TypeClassType = tc
};
new $anon()
}
}
};
abstract trait PositiveInt[T] extends scala.AnyRef {
def wrapPositive(int: Int): T;
def asInt(t: T): Int
}
object PositiveInt extends scala.AnyRef {
def <init>() = {
super.<init>();
()
};
implicit def positiveIntHasOrder[T](implicit evidence$1: PositiveInt[T]): Order[T] = Order.by(PositiveInt[T].asInt);
def unwrap[T](implicit evidence$2: PositiveInt[T]) = (implicitly[PositiveInt[T]].asInt: (() => <empty>));
def callImplicitApply[T](implicit evidence$3: PositiveInt[T]): PositiveInt[T] = PositiveInt[T];
def callExplicitApply[T](implicit evidence$4: PositiveInt[T]): PositiveInt[T] = PositiveInt.apply[T]
}
package com.github.kisaragieffective.reproduce.idea.a
// derived from https://github.com/GiganticMinecraft/SeichiAssist/blob/53ca2d17ada36255b0ab8eb6e001e54dc9c72588/src/main/scala/com/github/unchama/generic/algebra/typeclasses/PositiveInt.scala
// Licensed under GPLv3, authors: Kory__3 and KisaragiEffective
import cats.Order
import simulacrum.typeclass
/**
* 正のIntと同型な型のクラス。
*
* すべての正のnについて、
*
* - `wrapPositive(n).asInt = n`
*
* を満たす。
*/
@typeclass trait PositiveInt[T] {
/**
* 正整数を包む。非正整数については例外を投げる。
*/
def wrapPositive(int: Int): T
/**
* [[T]] を正整数に変換する。
*/
def asInt(t: T): Int
}
object PositiveInt {
implicit def positiveIntHasOrder[T: PositiveInt]: Order[T] = Order.by(PositiveInt[T].asInt)
def unwrap[T: PositiveInt] = implicitly[PositiveInt[T]].asInt _
def callImplicitApply[T: PositiveInt]: PositiveInt[T] = PositiveInt[T]
def callExplicitApply[T: PositiveInt]: PositiveInt[T] = PositiveInt.apply[T]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment