The only cross-platform browser that fits in a Gist!
One line install. Works on Linux, MacOSX and Windows.
$> npm install http://gist.github.com/morganrallen/f07f59802884bcdcad4a/download
Summary of Behaviour: | |
A. OpenJDK 7 b65. | |
1. Default in java.security is securerandom.source=/dev/urandom | |
2. If securerandom.source=/dev/urandom, NativePRNG is used, SecureRandom.nextBytes() is non-blocking via /dev/urandom ; SecureRandom.generateSeed(x) is blocking via /dev/random | |
3. if securerandom.source=/dev/random, then SHA1PRNG is used. Initial seed is blocking via /dev/random. No other accesses. | |
4. If securerandom.source=/dev/./urandom then SHA1PRNG is used. Initial seed is non-blocking via /dev/./urandom. No other accesses. | |
B. Oracle JDK 8 b25. |
(ns kebab | |
(:require [camel-snake-kebab :as kebab] | |
[schema.coerce :as c] | |
[schema.core :as s])) | |
(def Data (s/either s/Keyword | |
{(s/recursive #'Data) (s/recursive #'Data)} | |
[(s/recursive #'Data)] | |
#{(s/recursive #'Data)} | |
s/Any)) |
scala> case class UserId(id: Long) | |
defined class UserId | |
scala> def isSusan(id: UserId): Boolean = id == 3L // see the bug? | |
isSusan: (id: UserId)Boolean | |
scala> isSusan(UserId(3L)) | |
res31: Boolean = false// shouldn't this be true? | |
// let's show the compiler how to check whether two UserIds are equal |
I think of Schema as a runtime contracts library (I believe it does coercion and validation, but they seem related to me).
macro protocol { | |
case { _ $name:ident { $fn:protocol_fn ... } } => { | |
// Probably not a good idea to rely on `__fresh`. Sweet.js should provide | |
// some sort of blessed gensym capability. | |
letstx $id = [makeValue(__fresh(), #{ here })]; | |
return #{ | |
function $name(proto, impl) { | |
if (!impl) { | |
impl = proto; | |
proto = {}; |
// The DSL's implementation (i.e. just the applicative interface for Optionals + methods for creating tuples) | |
operator infix <*> { associativity left } | |
@infix func <*><A, B>(lhs: (A -> B)?, rhs: A?) -> B? { | |
switch lhs { | |
case .None: | |
return .None | |
case let .Some(f): | |
return rhs.map(f) | |
} | |
} |
protocol Monoid { | |
class func mzero() -> Self | |
func mop(y: Self) -> Self | |
} | |
func mconcat<M : Monoid>(t: Array<M>) -> M { | |
return (t.reduce(M.mzero()) { $0.mop($1) }) | |
} | |
protocol Num { |
protocol Num { | |
class func zero() -> Self | |
func succ() -> Self | |
func add(y: Self) -> Self | |
func multiply(y: Self) -> Self | |
} | |
extension Int32: Num { | |
static func zero() -> Int32 { return 0 } | |
func succ() -> Int32 { return self + 1 } |
(defn flatmap< | |
"Takes a function and a source channel, and returns a channel which | |
contains the values in each channel produced by applying f to | |
each value taken from the source channel. f must return a | |
channel." | |
[f in] | |
(let [out (a/chan)] | |
(a/go-loop [] | |
(let [item (a/<! in)] | |
(if (nil? item) |