Last active

Embed URL


SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View bounds_bug.clj
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
(ns typed-example.core
(:import (clojure.lang Symbol Seqable))
(:require [clojure.core.typed :refer [ann check-ns defprotocol> ann-datatype ann-protocol inst]]))
(ann-protocol Similar
is-similar? [Similar Any -> Boolean])
(defprotocol> Similar
(is-similar? [this a]))
(ann-datatype MyInt [x :- Number])
(deftype MyInt [x]
(is-similar? [this m]
(= x m)))
(ann find-similar (All [[t :< Similar]]
[t (U nil (Seqable t)) -> Boolean]))
(defn find-similar [a as]
(empty? as) false
(is-similar? a (first as)) true
:else ((inst find-similar t) a (next as))))
;AssertionError Assert failed: 22: Manually instantiated type t is not between bounds Nothing and typed-example.core/Similar
;(and (sub/subtype? ty upper-bound) (sub/subtype? lower-bound ty)) clojure.core.typed.inst/manual-inst (inst.clj:54)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.