Public Vars

Back

list* (clj)

(source)

function

(list* args) (list* a args) (list* a b args) (list* a b c args) (list* a b c d & more)
Creates a new seq containing the items prepended to the rest, the last of which will be treated as a sequence.

Examples

typedclojure/typedclojure
(ns ^:no-doc typed.clj.ext.clojure.core__reify
  "Typing rules clojure.core/reify"
  (:require [clojure.core.typed.internal :as internal]
            [typed.cljc.checker.check :as chk]
            [typed.cljc.analyzer :as ana2]
            [typed.cljc.checker.check.unanalyzed :refer [defuspecial]]))

(defuspecial defuspecial__reify
  "defuspecial implementation for clojure.core/reify"
  [{original-reify-form :form :as original-expr} expected]
  (-> original-expr
      ana2/analyze-outer
      ((fn [expr]
         {:pre [(= :unanalyzed (:op expr))]
          :post [(= :unanalyzed (:op %))]}
         (update expr :form (fn [form]
                              {:pre [(= 'reify* (first form))]}
                              (-> (list* (vary-meta (first form) assoc ::original-reify-expr original-expr)
                                         (rest form))
                                  (with-meta (meta form)))))))
      (chk/check-expr expected)))
typedclojure/typedclojure
(ns ^:no-doc typed.clj.ext.clojure.core__doseq
  "Typing rules clojure.core/doseq"
  (:require [clojure.core.typed.contract-utils :as con]
            [clojure.core.typed.errors :as err]
            [typed.clj.checker.check :refer [check-expr]]
            [typed.clj.checker.parse-unparse :as prs]
            [typed.clj.analyzer.passes.emit-form :as emit-form]
            [typed.clj.analyzer.utils :as ana-utils]
            [typed.clj.ext.clojure.core__for :as ext-for]
            [typed.clj.ext.clojure.core__let :as ext-let]
            [typed.cljc.analyzer :as ana2]
            [typed.cljc.checker.check.let :as let]
            [typed.cljc.checker.check-below :as below]
            [typed.cljc.checker.check.if :as if]
            [typed.cljc.checker.filter-ops :as fo]
            [typed.cljc.checker.lex-env :as lex]
            [typed.cljc.checker.var-env :as var-env]
            [typed.cljc.checker.type-rep :as r]
            [typed.cljc.checker.type-ctors :as c]
            [typed.cljc.checker.cs-gen :as cgen]
            [typed.cljc.checker.utils :as u]
            [typed.cljc.checker.check.unanalyzed :refer [defuspecial]]))

(defuspecial defuspecial__doseq
  "defuspecial implementation for clojure.core/doseq"
  [{ana-env :env :keys [form] :as expr} expected]
  (let [_ (assert (<= 2 (count form)) form)
        [args-syn & body-syns] (next form)
        {:keys [new-syms expanded-bindings prop-env ana-env reachable]}
        (ext-for/check-list-comprehension-binder 
          {:form form
           :args-syn args-syn
           :ana-env ana-env
           :prop-env (lex/lexical-env)})
        expr (-> expr
                 (update :form
                         (fn [form]
                           (-> (map-indexed
                                 (fn [i args-syn]
                                   ;; add back short-circuited args
                                   (if (= 1 i)
                                     expanded-bindings
                                     args-syn))
                                 form)
                               (with-meta (meta form))))))]
        (if-not reachable
          (assoc expr
                 u/expr-type (below/maybe-check-below
                               (r/ret r/-nil
                                      (fo/-false-filter))
                               expected))
          (let [cbody (var-env/with-lexical-env prop-env
                        (-> `(do ~@body-syns)
                            (ana2/unanalyzed ana-env)
                            check-expr))
                expr (-> expr
                         (update :form
                                 (fn [form]
                                   (-> form
                                       vec
                                       (subvec 0 2)
                                       (conj (emit-form/emit-form cbody))
                                       list*
                                       (with-meta (meta form))))))]
            (assoc expr
                   u/expr-type (below/maybe-check-below
                                 (r/ret r/-nil
                                        (fo/-false-filter))
                                 expected))))))
typedclojure/typedclojure
(ns ^:no-doc typed.ann.clojure
  "Type annotations for the base Clojure distribution."
  #?(:cljs (:require-macros [typed.ann-macros.clojure :as macros]))
  (:require [clojure.core :as cc]
            [typed.clojure :as t]
            #?(:clj [typed.ann-macros.clojure :as macros])
            #?(:clj typed.ann.clojure.jvm) ;; jvm annotations
            #?(:clj clojure.core.typed))
  #?(:clj
     (:import (clojure.lang PersistentHashSet PersistentList
                            APersistentMap #_IPersistentCollection
                            #_ITransientSet
                            IRef)
              (java.util Comparator Collection))))

cc/set (t/All [x] [(t/Seqable x) :-> #?(:cljs (t/Set x)
                                        :default (PersistentHashSet x))])
cc/hash-set (t/All [x] [x :* :-> #?(:cljs (t/Set x)
                                    :default (PersistentHashSet x))])
;TODO
;cc/hash-map (t/All [x y z :..]
;                   (t/IFn [(t/cat z z) :.. z :-> (t/Assoc '{} z :.. z)]
;                          [(t/cat x y) :* :-> (t/Map x y)]))
cc/hash-map (t/All [x y] [(t/cat x y) :* :-> (t/Map x y)])
cc/array-map (t/All [x y] [(t/cat x y) :* :-> (t/Map x y)])
cc/sorted-map (t/All [x y] [(t/cat x y) :* :-> (t/SortedMap x y)])
cc/sorted-map-by (t/All [x y] [[x x :-> t/Int] (t/cat x y) :* :-> (t/SortedMap x y)])
cc/sorted-set (t/All [x] [x :* :-> (t/SortedSet x)])
;;FIXME use t/Comparator for first arg
cc/sorted-set-by (t/All [x] [[x x :-> t/Int] x :* :-> (t/SortedSet x)])
cc/list (t/All [x] [x :* :-> (#?(:clj PersistentList :cljs t/List) x)])
;cc/list* (t/All [x] [x :* (t/Seqable x) :-> (t/NilableNonEmptyASeq x)])
cc/list* (t/All [x] (t/IFn [(t/Seqable x) :-> (t/NilableNonEmptyASeq x)]
                           [x (t/Seqable x) :-> (t/NonEmptyASeq x)]
                           [x x (t/Seqable x) :-> (t/NonEmptyASeq x)]
                           [x x x (t/Seqable x) :-> (t/NonEmptyASeq x)]
                           [x x x x (t/Seqable x) :-> (t/NonEmptyASeq x)]
                           [x x x x x (t/Seqable x) :-> (t/NonEmptyASeq x)]
                           [x x x x x x (t/Seqable x) :-> (t/NonEmptyASeq x)]
                           [x x x x x x x (t/Seqable x) :-> (t/NonEmptyASeq x)]
                           [x x x x x x x x (t/Seqable x) :-> (t/NonEmptyASeq x)]
                           [x x x x x x x x x (t/Seqable x) :-> (t/NonEmptyASeq x)]
                           [x x x x x x x x x x (t/Seqable x) :-> (t/NonEmptyASeq x)]))