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
| /* | |
| * Copyright 2017 the original author or authors. | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software |
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 Option<A> { | |
| protected Option() { } | |
| } | |
| interface App<F, A> { | |
| F proof(); | |
| } | |
| class OptionF { | |
| private OptionF() {} | |
| private static class AppOption<A> implements App<OptionF, 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
| public class Reader<R, A> { | |
| private final Function<R, A> run; | |
| public Reader(Function<R, A> run) { this.run = run; } | |
| public <B> Reader<R, B> map(Function<A, B> f) { | |
| return new Reader<>( r -> f.apply((apply(r))) ); | |
| } | |
| public <B> Reader<R, B> flatMap(Function<A, Reader<R, B>> f) { |
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
| import java.util.function.Function; | |
| import java.util.Arrays; | |
| import java.util.List; | |
| import java.util.Optional; | |
| import java.util.stream.Collectors; | |
| public class Demo { | |
| /** | |
| * An IO operation that results in a value of type T. |
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
| # delete local tag '12345' | |
| git tag -d 12345 | |
| # delete remote tag '12345' (eg, GitHub version too) | |
| git push origin :refs/tags/12345 | |
| # alternative approach | |
| git push --delete origin tagName | |
| git tag -d tagName |
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
| /** | |
| * ``` | |
| * Does JDK8's Optional class satisfy the Monad laws? | |
| * ================================================= | |
| * 1. Left identity: true | |
| * 2. Right identity: true | |
| * 3. Associativity: true | |
| * | |
| * Yes, it does. | |
| * ``` |
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
| /* | |
| Based on the second part of the talk "Dead-Simple Dependency Injection in Scala" by @runarorama at NEScala 2012 | |
| http://marakana.com/s/dependency_injection_in_scala,1108/index.html | |
| */ | |
| sealed trait KVS[A] | |
| case class Put[A](key: String, value: String, a: A) extends KVS[A] | |
| case class Get[A](key: String, h: String => A) extends KVS[A] | |
| case class Delete[A](key: String, a: A) extends KVS[A] |
NewerOlder