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 / 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
(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 #{}
#lang racket
(define (emit s) s)
(define (process-file in out)
(with-input-from-file in
(lambda ()
(with-output-to-file out
#:exists 'replace
(lambda ()
(ns clojure.core.typed.test.mini-occ
{:lang :core.typed
:core.typed {:features #{:runtime-infer}}
}
(:require [clojure.test :refer [deftest is]]
[clojure.core.typed :as t]
[clojure.pprint :refer [pprint]]))
;; Start: Generated by clojure.core.typed - DO NOT EDIT
@frenchy64
frenchy64 / var.md
Last active February 1, 2016 17:47

Defining and using Vars in Typed and Untyped Lands with Gradual Typing

One of the key aspects of gradual typing is that the same code can execute in two different contexts with different kinds of contracts. For example take the following code:

(ns my-typed
  {:lang :core.typed})

(ann my-plus [Num Num -> Num])
(defn my-plus [a b] (+ a b))
Types in Clojure
================
What is Typed Clojure?
- optional type system Clojure
- based on Typed Racket "Gradual typing"
- dynamic checking
- static checking <---
Why is it built that way?
@frenchy64
frenchy64 / mapcat.clj
Created December 27, 2013 05:47
mapcat
clojure.core/mapcat
(All [c b ...]
[[b ... b -> (Option (Seqable c))] (Option (Seqable b)) ... b -> (Seq c)])
(ns clojure.core.typed.test.unsound-record
(:require [clojure.core.typed :as t]))
(t/ann-record Foo [a :- Number])
(defrecord Foo [a])
(t/ann unsound [(t/Map Any Any) -> Number])
(defn unsound [r]
(let [r (assoc r :a nil)]
(assert (instance? Foo r))
(ann-form (fn [a] (assoc a :a 1))
(All [[x :> (Map Nothing Nothing) :< (Map Any Any)]]
[x -> (Assoc x ':a Number)]))
{:then
(&
(|
(is (U clojure.core.typed/EmptyCount nil) v1)
(is (U nil false) v156717)
(when
(is (U nil false) v156717)
(is (U clojure.core.typed/EmptyCount nil) v1)))
(|
(when