Back
force (clj)
(source)function
(force x)
If x is a Delay, returns the (possibly cached) value of its expression, else returns x
Examples
PrecursorApp/precursor
(ns pc.http.routes.api
(:require [cemerick.url :as url]
[cheshire.core :as json]
[clojure.core.memoize :as memo]
[clojure.string :as str]
[clojure.tools.reader.edn :as edn]
[crypto.equality :as crypto]
[defpage.core :as defpage :refer (defpage)]
[pc.auth :as auth]
[pc.crm :as crm]
[pc.datomic :as pcd]
[pc.early-access]
[pc.http.doc :as doc-http]
[pc.http.team :as team-http]
[pc.http.handlers.custom-domain :as custom-domain]
[pc.models.chat-bot :as chat-bot-model]
[pc.models.doc :as doc-model]
[pc.models.flag :as flag-model]
[pc.models.team :as team-model]
[pc.profile :as profile]
[ring.middleware.anti-forgery :as csrf]
[slingshot.slingshot :refer (try+ throw+)]))
(defpage new [:post "/api/v1/document/new"] [req]
(let [params (some-> req :body slurp edn/read-string)
read-only? (:read-only params)
doc-name (:document/name params)]
(if-not (:subdomain req)
(let [cust-uuid (get-in req [:auth :cust :cust/uuid])
intro-layers? (:intro-layers? params)
doc (doc-model/create-public-doc!
(merge {:document/chat-bot (rand-nth chat-bot-model/chat-bots)}
(when cust-uuid {:document/creator cust-uuid})
(when read-only? {:document/privacy :document.privacy/read-only})
(when doc-name {:document/name doc-name})))]
(when intro-layers?
(doc-http/add-intro-layers doc))
{:status 200 :body (pr-str {:document (doc-model/read-api doc)})})
(if (and (:team req)
(auth/logged-in? req)
(auth/has-team-permission? (pcd/default-db) (:team req) (:auth req) :admin))
(let [doc (doc-model/create-team-doc!
(:team req)
(merge {:document/chat-bot (rand-nth chat-bot-model/chat-bots)}
(when-let [cust-uuid (get-in req [:cust :cust/uuid])]
{:document/creator cust-uuid})
(when read-only?
{:document/privacy :document.privacy/read-only})
(when doc-name
{:document/name doc-name})))]
{:status 200 :body (pr-str {:document (doc-model/read-api doc)})})
{:status 400 :body (pr-str {:error :unauthorized-to-team
:redirect-url (str (url/map->URL {:host (profile/hostname)
:protocol (if (profile/force-ssl?)
"https"
(name (:scheme req)))
:port (if (profile/force-ssl?)
(profile/https-port)
(profile/http-port))
:path "/new"
:query (:query-string req)}))
:msg "You're unauthorized to make documents in this subdomain. Please request access."})}))))
hraberg/deuce
(ns deuce.emacs.indent
(:use [deuce.emacs-lisp :only (defun defvar)])
(:require [clojure.core :as c]
[deuce.emacs.buffer :as buffer]
[deuce.emacs.data :as data]
[deuce.emacs.editfns :as editfns])
(:refer-clojure :exclude []))
(defun move-to-column (column &optional force)
"Move point to column COLUMN in the current line.
Interactively, COLUMN is the value of prefix numeric argument.
The column of a character is calculated by adding together the widths
as displayed of the previous characters in the line.
This function ignores line-continuation;
there is no upper limit on the column number a character can have
and horizontal scrolling has no effect.
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))))
(t/defalias
^{:doc "A Clojure delay (see clojure.core/{delay,force})."
:forms '[(Delay x)]}
t/Delay
(t/TFn [[x :variance :covariant]]
#?(:clj (clojure.lang.Delay x)
:cljs (cljs.core/Delay x))))
cc/force (t/All [x] (t/IFn [(t/Delay x) :-> x]
#_[(t/I x (t/Not (t/Delay t/Any))) :-> x]
[t/Any :-> t/Any]))
marick/structural-typing
(ns structural-typing.clojure.f-core
(:require [structural-typing.clojure.core :as subject])
(:use midje.sweet))
(fact force-vector
(subject/force-vector 1) => (vector 1)
(subject/force-vector [1]) => (vector 1)
(subject/force-vector '(1)) => (vector 1))
mauricioszabo/repl-tooling
(ns repl-tooling.editor-integration.autocomplete-test
(:require [reagent.core :as r]
[clojure.test :refer [async testing is]]
[clojure.core.async :as async]
[check.core :refer [check]]
[check.async-old :refer [async-test]]
[matcher-combinators.matchers :refer [embeds]]
[devcards.core :as cards :include-macros true]
[repl-tooling.repl-client.clojure :as clj]
[repl-tooling.eval-helpers :as h]
[repl-tooling.editor-integration.connection :as conn]))
(testing "Clojure"
(. (autocomplete) then #(async/put! clj %))
(check (async/<! clj)
=> (embeds [{:candidate "foo", :type :local}
{:candidate "for", :type :macro, :ns "clojure.core"}
{:candidate "force", :type :function, :ns "clojure.core"}
{:candidate "format", :type :function, :ns "clojure.core"}])))
(. (autocomplete) then #(async/put! cljs %))
(check (async/<! cljs) => (embeds [{:candidate "foo", :type :local}
{:candidate "for", :type :macro, :ns "cljs.core"}
{:candidate "force", :type :function, :ns "cljs.core"}]))))))