Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@frenchy64
Created May 22, 2014 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frenchy64/076d25450eed8f80aabe to your computer and use it in GitHub Desktop.
Save frenchy64/076d25450eed8f80aabe to your computer and use it in GitHub Desktop.
(ns typed-demo.protocol
(:require [clojure.core.typed :as tc])
(:import (java.util Random)))
(tc/defprotocol IRandom
(-next-int
[this limit :- Integer] :- Integer))
(tc/ann-record SeededRandom [seed :- tc/AnyInteger
rng :- java.util.Random])
(defrecord SeededRandom [seed ^java.util.Random rng]
IRandom
(-next-int
[this limit]
(tc/ann-form limit Integer)
;Local binding limit__#0 expected type java.lang.Integer, but actual type Object
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment