Skip to content

Commit f2fe59d

Browse files
author
pakoito
committed
Add Fix and FixInstances
1 parent 66cbe2f commit f2fe59d

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package kategory
2+
3+
@higherkind data class Fix<F>(val FF: Functor<F>, val unfix: Fix<HK<F, HK<FixHK, F>>>) : FixKind<F> {
4+
5+
fun projectT(): HK<ComposedType<FixHK, F>, FixKind<F>> = unfix.lift()
6+
7+
companion object {
8+
inline fun <reified F> embedT(compFG: HK<ComposedType<ComposedType<FixHK, F>, FixHK>, F>, FF: Functor<F> = functor<F>()): FixKind<F> =
9+
Fix(FF, compFG.lower().lower().ev())
10+
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package kategory
2+
3+
interface FixInstances<F> : Birecursive<FixHK, F> {
4+
override fun projectT(fg: HK<FixHK, F>): HK<ComposedType<FixHK, F>, FixKind<F>> =
5+
fg.ev().projectT()
6+
7+
override fun embedT(compFG: HK<ComposedType<ComposedType<FixHK, F>, FixHK>, F>): FixKind<F> =
8+
Fix(FG(), compFG.lower().lower().ev())
9+
}

0 commit comments

Comments
 (0)