Skip to content

Commit

Permalink
Use @JsName to give a better name to new instanceOf Prism (#3424)
Browse files Browse the repository at this point in the history
* Use @JsName to give a better name to new instanceOf Prism

* Push correct version
  • Loading branch information
serras authored May 15, 2024
1 parent 30cbd15 commit c3315be
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ private fun OpticsProcessorOptions.processElement(ele: ADT, foci: List<Focus>):
else ->
"${ele.visibilityModifierName} $inlineText fun $angledTypeParameters ${ele.sourceClassName}.Companion.${focus.paramName}(): $Prism<$sourceClassNameWithParams, ${focus.classNameWithParameters}>"
}
"$firstLine = $Prism.pInstanceOf()"
"$firstLine = $Prism.instanceOf()"
}
}
4 changes: 2 additions & 2 deletions arrow-libs/optics/arrow-optics/api/arrow-optics.api
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,11 @@ public abstract interface class arrow/optics/PPrism : arrow/optics/POptional {
public abstract fun first ()Larrow/optics/PPrism;
public abstract fun foldMap (Ljava/lang/Object;Lkotlin/jvm/functions/Function2;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public abstract fun getOrModify (Ljava/lang/Object;)Larrow/core/Either;
public static fun instanceOf (Lkotlin/reflect/KClass;)Larrow/optics/PPrism;
public abstract fun left ()Larrow/optics/PPrism;
public abstract fun liftNullable (Lkotlin/jvm/functions/Function1;)Lkotlin/jvm/functions/Function1;
public abstract fun modify (Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static fun none ()Larrow/optics/PPrism;
public static fun pInstanceOf (Lkotlin/reflect/KClass;)Larrow/optics/PPrism;
public static fun pLeft ()Larrow/optics/PPrism;
public static fun pRight ()Larrow/optics/PPrism;
public static fun pSome ()Larrow/optics/PPrism;
Expand All @@ -304,11 +304,11 @@ public final class arrow/optics/PPrism$Companion {
public final fun eitherLeft ()Larrow/optics/PPrism;
public final fun eitherRight ()Larrow/optics/PPrism;
public final fun id ()Larrow/optics/PIso;
public final fun instanceOf (Lkotlin/reflect/KClass;)Larrow/optics/PPrism;
public final fun invoke (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Larrow/optics/PPrism;
public final fun none ()Larrow/optics/PPrism;
public final fun only (Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)Larrow/optics/PPrism;
public static synthetic fun only$default (Larrow/optics/PPrism$Companion;Ljava/lang/Object;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Larrow/optics/PPrism;
public final fun pInstanceOf (Lkotlin/reflect/KClass;)Larrow/optics/PPrism;
public final fun pLeft ()Larrow/optics/PPrism;
public final fun pRight ()Larrow/optics/PPrism;
public final fun pSome ()Larrow/optics/PPrism;
Expand Down
4 changes: 2 additions & 2 deletions arrow-libs/optics/arrow-optics/api/arrow-optics.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ abstract interface <#A: kotlin/Any?, #B: kotlin/Any?, #C: kotlin/Any?, #D: kotli
final fun <#A2: kotlin/Any?> none(): arrow.optics/PPrism<arrow.core/Option<#A2>, arrow.core/Option<#A2>, kotlin/Unit, kotlin/Unit> // arrow.optics/PPrism.Companion.none|none(){0§<kotlin.Any?>}[0]
final fun <#A2: kotlin/Any?> only(#A2, kotlin/Function2<#A2, #A2, kotlin/Boolean> = ...): arrow.optics/PPrism<#A2, #A2, kotlin/Unit, kotlin/Unit> // arrow.optics/PPrism.Companion.only|only(0:0;kotlin.Function2<0:0,0:0,kotlin.Boolean>){0§<kotlin.Any?>}[0]
final fun <#A2: kotlin/Any?> some(): arrow.optics/PPrism<arrow.core/Option<#A2>, arrow.core/Option<#A2>, #A2, #A2> // arrow.optics/PPrism.Companion.some|some(){0§<kotlin.Any?>}[0]
final inline fun <#A2: kotlin/Any, #B2: #A2> pInstanceOf(kotlin.reflect/KClass<#B2>): arrow.optics/PPrism<#A2, #A2, #B2, #B2> // arrow.optics/PPrism.Companion.pInstanceOf|pInstanceOf(kotlin.reflect.KClass<0:1>){0§<kotlin.Any>;1§<0:0>}[0]
final inline fun <#A2: kotlin/Any?, #B2: reified #A2> pInstanceOf(): arrow.optics/PPrism<#A2, #A2, #B2, #B2> // arrow.optics/PPrism.Companion.pInstanceOf|pInstanceOf(){0§<kotlin.Any?>;1§<0:0>}[0]
final inline fun <#A2: kotlin/Any, #B2: #A2> instanceOf(kotlin.reflect/KClass<#B2>): arrow.optics/PPrism<#A2, #A2, #B2, #B2> // arrow.optics/PPrism.Companion.instanceOf|instanceOf(kotlin.reflect.KClass<0:1>){0§<kotlin.Any>;1§<0:0>}[0]
final inline fun <#A2: kotlin/Any?, #B2: reified #A2> instanceOf(): arrow.optics/PPrism<#A2, #A2, #B2, #B2> // arrow.optics/PPrism.Companion.instanceOf|instanceOf(){0§<kotlin.Any?>;1§<0:0>}[0]
}
open fun <#A1: kotlin/Any?, #B1: kotlin/Any?> compose(arrow.optics/PPrism<in #C, out #D, out #A1, in #B1>): arrow.optics/PPrism<#A, #B, #A1, #B1> // arrow.optics/PPrism.compose|compose(arrow.optics.PPrism<in|1:2,out|1:3,out|0:0,in|0:1>){0§<kotlin.Any?>;1§<kotlin.Any?>}[0]
open fun <#A1: kotlin/Any?, #B1: kotlin/Any?> plus(arrow.optics/PPrism<in #C, out #D, out #A1, in #B1>): arrow.optics/PPrism<#A, #B, #A1, #B1> // arrow.optics/PPrism.plus|plus(arrow.optics.PPrism<in|1:2,out|1:3,out|0:0,in|0:1>){0§<kotlin.Any?>;1§<kotlin.Any?>}[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import arrow.core.left
import arrow.core.right
import arrow.core.some
import arrow.core.toOption
import kotlin.js.JsName
import kotlin.jvm.JvmName
import kotlin.jvm.JvmStatic
import kotlin.reflect.KClass
Expand Down Expand Up @@ -225,8 +226,8 @@ public interface PPrism<S, T, A, B> : POptional<S, T, A, B> {
/**
* [Prism] to focus on a particular subtype [B]
*/
@JvmStatic
public inline fun <A, reified B: A> pInstanceOf(): Prism<A, B> = Prism(
@JvmStatic @JsName("instanceOfReified")
public inline fun <A, reified B: A> instanceOf(): Prism<A, B> = Prism(
getOption = { s -> if (s is B) s.some() else arrow.core.none() },
reverseGet = { s -> s }
)
Expand All @@ -235,7 +236,7 @@ public interface PPrism<S, T, A, B> : POptional<S, T, A, B> {
* [Prism] to focus on a particular subtype [B]
*/
@JvmStatic
public inline fun <A: Any, B: A> pInstanceOf(klass: KClass<B>): Prism<A, B> = Prism(
public inline fun <A: Any, B: A> instanceOf(klass: KClass<B>): Prism<A, B> = Prism(
getOption = { s -> klass.safeCast(s).toOption() },
reverseGet = { s -> s }
)
Expand Down

0 comments on commit c3315be

Please sign in to comment.