Author: Michael Zeng
This file contains 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
import arrow.Kind | |
import arrow.core.Option | |
import arrow.core.left | |
import arrow.core.right | |
import arrow.effects.typeclasses.Async | |
import arrow.typeclasses.ApplicativeError | |
data class UserId(val value: String) | |
data class User(val userId: UserId) | |
data class Task(val value: String) |
This file contains 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
import arrow.* | |
import arrow.core.* | |
import arrow.typeclasses.* | |
import arrow.data.* | |
sealed class ValidationError(val msg: String) | |
data class DoesNotContain(val value: String) : ValidationError("Did not contain $value") | |
data class MaxLength(val value: Int) : ValidationError("Exceeded length of $value") | |
data class NotAnEmail(val reasons: Nel<ValidationError>) : ValidationError("Not a valid email") |
This file contains 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
import arrow.Kind | |
import arrow.core.Option | |
import arrow.core.Try | |
import arrow.core.functor | |
import arrow.effects.IO | |
import arrow.effects.fix | |
import arrow.effects.functor | |
import arrow.typeclasses.Functor | |
/* algebras */ |
This file contains 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 NaturalNum | |
object Zero: NaturalNum() | |
class PlusOne<N: NaturalNum>(): NaturalNum() | |
fun num(zero: Zero) = 0 | |
fun num(one: PlusOne<Zero>) = 1 |
This file contains 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
@Value.Immutable | |
@Value.Style(allParameters = true) | |
public abstract class Foo implements FooModel{ | |
public static final FooModel.Mapper<Foo> MAPPER = new FooModel.Mapper<>((Mapper.Creator<Foo>) ImmutableFoo::of); | |
public static final class Marshal extends FooModel.FooMarshal {} | |
} |
This file contains 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
/** | |
* This class allows to inject into objects through a base class, | |
* so we don't have to repeat injection code everywhere. | |
* | |
* The performance drawback is about 0.013 ms per injection on a very slow device, | |
* which is negligible in most cases. | |
* | |
* Example: | |
* <pre>{@code |
This file contains 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
def toCamelCase(String string) { | |
String result = "" | |
string.findAll("[^\\W]+") { String word -> | |
result += word.capitalize() | |
} | |
return result | |
} | |
afterEvaluate { project -> | |
Configuration runtimeConfiguration = project.configurations.getByName('compile') |
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<!-- google's material design colours from | |
http://www.google.com/design/spec/style/color.html#color-ui-color-palette --> | |
<!--reds--> | |
<color name="md_red_50">#FFEBEE</color> | |
<color name="md_red_100">#FFCDD2</color> | |
<color name="md_red_200">#EF9A9A</color> |
NewerOlder