Skip to content

Instantly share code, notes, and snippets.

View frenchy64's full-sized avatar

Ambrose Bonnaire-Sergeant frenchy64

  • Madison, Wisconsin
View GitHub Profile
@frenchy64
frenchy64 / bash_profile.sh
Created July 19, 2017 13:55
Update clojure spec alpha
update_spec_alpha () {
git grep -l clojure.spec | xargs sed -i '' 's/clojure.spec /clojure.spec.alpha /g'
git grep -l clojure.spec | xargs sed -i '' 's/clojure.spec.test /clojure.spec.test.alpha /g'
git grep -l clojure.spec | xargs sed -i '' 's/clojure.spec.gen /clojure.spec.gen.alpha /g'
}
Retrieving banks-0.1.9.pom from s3p://sparkfund-maven/releases/
Could not transfer artifact sparkfund:banks:pom:0.1.9 from/to sparkfund (s3p://sparkfund-maven/releases/): Cannot run program "aws": error=2, No such file or directory
Retrieving jimfs-1.2.0.pom from s3p://sparkfund-maven/releases/
Could not transfer artifact sparkfund:jimfs:pom:1.2.0 from/to sparkfund (s3p://sparkfund-maven/releases/): Cannot run program "aws": error=2, No such file or directory
java.lang.Thread.run Thread.java: 745
java.util.concurrent.ThreadPoolExecutor$Worker.run ThreadPoolExecutor.java: 617
java.util.concurrent.ThreadPoolExecutor.runWorker ThreadPoolExecutor.java: 1142
org.sonatype.aether.util.concurrency.RunnableErrorForwarder$1.run RunnableErrorForwarder.java: 60
org.sonatype.aether.connector.wagon.WagonRepositoryConnector$GetTask.run WagonRepositoryConnector.java: 601
@frenchy64
frenchy64 / automatic.clj
Created February 16, 2017 19:20
Automatic annotations for `for`
(defn- multi-perm
"Handles the case when you want the permutations of a list with duplicate items."
[l]
(let [f (frequencies l),
v (vec (distinct l)),
indices (apply concat
(for ^{::t/ann (t/Coll Long)} [^{::t/ann Long} i (range (count v))]
(repeat (f (v i)) i)))]
(map (partial map v) (lex-permutations indices))))
@frenchy64
frenchy64 / 0_before.clj
Created February 15, 2017 21:20
Loop inference
(ns clojure.core.typed.test.rt-infer.loop
{:lang :core.typed
:core.typed {:features #{:runtime-infer}}}
(:require [clojure.core.typed :as t]))
(defn b [coll]
(loop [c coll
out []]
(if (seq c)
(recur (next c) (conj out (inc (first c))))
@frenchy64
frenchy64 / 0_before.clj
Last active February 13, 2017 07:03
Runtime type inference
(ns clojure.core.typed.test.rt-infer.anon-lambda
{:lang :core.typed
:core.typed {:features #{:runtime-infer}}}
(:require [clojure.core.typed :as t]))
(defn b [coll]
(->> coll
(map (fn [n]
(inc n)))
(filter
(ann even (All [a]
(IFn [Int -> Boolean]
[(I a (Not Int)) -> (I a (Not Int))])))
(defn even [a]
(cond
(integer? a) (even? a)
:else a))
; (even 1) ; can't type check this yet... WIP
1. Clone this repository https://github.com/frenchy64/clojurescript/tree/tools.analyzer-ast
2. Checkout the `tools.analyzer.ast` branch.
3. `lein install` that branch.
4. Now you should have `[org.clojure/clojurescript "0.0-SNAPSHOT"]` in your maven repo
5. You now have push rights to `https://github.com/typedclojure/core.typed`.
6. I'll soon have a CLJS branch we can all work on.
Relevant files:
- the clojurescript type checker
- https://github.com/typedclojure/core.typed/blob/master/module-check/src/main/clojure/clojure/core/typed/check_cljs.clj
@frenchy64
frenchy64 / bit.clj
Created November 3, 2016 21:55
Bit manipulation in Cloure
(require '[clojure.pprint :refer [pprint]])
(defn binary-str [bitmap]
(let [s (Integer/toBinaryString bitmap)]
(if (= 32 (count s))
s
(str (apply str (repeat (- 32 (count s)) \0))
s))))
;; get a feel for 2's complement
(ns prim-wrap
(:require [clojure.math.combinatorics :as comb]))
(declare wrap-prim)
(defn instrument-var [vr]
(wrap-prim vr @vr))
(def prim-invoke-interfaces
(into #{}
@frenchy64
frenchy64 / spec.clj
Created August 31, 2016 09:10
spec demo
(ns runtime-infer-demo.server-port
{:lang :core.typed
:core.typed {:features #{:runtime-infer}}}
(:require [clojure.core.typed :as t]
[clojure.spec :as s]))
(deftest configure-server-port-test
(is
(= (->
(configure-server-port