To the extent possible under law, Tomas Mikula has waived all copyright and related or neighboring rights to this work.
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 scala.language.implicitConversions | |
object Lazy { | |
def lazily[A](f: => A): Lazy[A] = new Lazy(f) | |
implicit def evalLazy[A](l: Lazy[A]): A = l() | |
} |
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 javafx.beans.value.ChangeListener; | |
import javafx.beans.value.ObservableValue; | |
public final class ChangeSubscriber<T> { | |
private final ObservableValue<T> observable; | |
private final ChangeListener<T> listener; | |
private boolean isSubscribed; | |
public ChangeSubscriber(ObservableValue<T> observable, ChangeListener<T> listener) { |
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 javafx.event.EventTarget; | |
import javafx.event.EventType; | |
import javafx.geometry.Point2D; | |
import javafx.scene.Node; | |
import javafx.scene.Scene; | |
import javafx.scene.input.InputEvent; | |
public abstract class MouseStationaryEvent extends InputEvent { | |
private static final long serialVersionUID = 1L; |
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 javafx.beans.property.SimpleDoubleProperty; | |
public class Leaky { | |
public static void main(String[] args) throws InterruptedException { | |
SimpleDoubleProperty a = new SimpleDoubleProperty(0.0); | |
for(int i = 0; i < 1000000; ++i) { | |
a.add(5).multiply(10).dispose(); | |
} | |
reportMemoryUsage(); |
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 shapeless._ | |
/** In coproduct `C`, replace `A` with `B`. */ | |
trait Replace[C <: Coproduct, A, B] extends DepFn2[C, A => B] { | |
type Out <: Coproduct | |
def lift(f: A => B): C => Out = | |
c => apply(c, f) | |
} |
The output from ghci
demonstrates that wa >>= f
produces the result even though wa
contains diverging computations.
% ghci lazy-writer.hs
GHCi, version 9.4.4: https://www.haskell.org/ghc/ :? for help
[1 of 2] Compiling Main ( lazy-writer.hs, interpreted )
Ok, one module loaded.
ghci> go
False, 42
ghci>