Skip to content

Instantly share code, notes, and snippets.

@udalov
udalov / getKType.kt
Last active March 16, 2021 21:54
DEPRECATED example how to obtain KType instance from reified T. Please use "typeOf" since 1.3.40!
import java.lang.reflect.*
import kotlin.reflect.KClass
import kotlin.reflect.KType
import kotlin.reflect.KTypeProjection
import kotlin.reflect.KVariance
import kotlin.reflect.full.createType
// --- Interface ---
inline fun <reified T : Any> getKType(): KType =
@mpickering
mpickering / gist:99d62ccdb73f49840220
Last active August 4, 2016 01:05
Native idiom brackets
-- https://wiki.haskell.org/Idiom_brackets
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleContexts, FlexibleInstances, UndecidableInstances #-}
import Control.Applicative
import Control.Monad.Identity
class Applicative i => Idiomatic i f g | g -> f i where
idiomatic :: i f -> g
iI :: Idiomatic i f g => f -> g