This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| typealias HomList<A, B> = ((A) -> B) -> List<B> | |
| fun <A, B> List<A>.yoneda(): HomList<A, B> { | |
| return { f -> this.map(f) } | |
| } | |
| fun <A, B> HomList<A, B>.lower(): List<A> { | |
| return buildList { | |
| this@lower { a -> | |
| add(a) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface Mapper<P, V> { | |
| fun P.toValue(): V | |
| fun V.toPayload(): P | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sealed class HomeActions { | |
| class ShowPosts(val posts: List<Post>) : HomeActions() | |
| class ShowUsers(val users: List<User>) : HomeActions() | |
| } | |
| data class HomeState(val posts: List<Post> = listOf(), val user: List<User> = listOf()) | |
| private val homeActions: ConflatedBroadcastChannel<HomeActions> by lazy { ConflatedBroadcastChannel<HomeActions>() } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface BloderComparable<T> { | |
| fun customCompareTo(b: T) : Int | |
| } | |
| // O(1) | |
| fun <T : BloderComparable<T>> List<T>.firstComparableIsEqualsTo(item: T) : Boolean = this[0].customCompareTo(item) == 0 | |
| // O(n) | |
| fun <T : BloderComparable<T>> List<T>.containsComparable(item: T) : Boolean = this.firstOrNull { | |
| it.customCompareTo(item) == 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ContextValidation(private val validator: FormValidator) : DefaultValidation(validator) { | |
| fun whenBrazil(conditions: BrazilValidations.() -> Unit) { | |
| if (isBrazilApp()) BrazilValidations(validator).conditions() | |
| } | |
| fun whenColombia(conditions: ColombiaValidations.() -> Unit) { | |
| if (isColombiaApp()) ColombiaValidations(validator).conditions() | |
| } |