Demonstrations of how clojure.core/concat
can produce a
StackOverflow.
This is the most obvious case: A loop that builds up a sequence by concatenation.
let | |
haskellOverlay = self: super: { | |
haskellPackages = with self.haskell.lib; super.haskellPackages.extend (hself: hsuper: { | |
hello = overrideCabal hsuper.hello (drv: { | |
configureFlags = drv.configureFlags or [] ++ [ "-O2" ]; | |
}); | |
}); | |
}; | |
in | |
{ pkgs ? import <nixpkgs> { overlays = [ haskellOverlay ]; } }: |
{-# language TemplateHaskell, ScopedTypeVariables, RankNTypes, | |
TypeFamilies, UndecidableInstances, DeriveFunctor, GADTs, | |
TypeOperators, TypeApplications, AllowAmbiguousTypes, | |
TypeInType, StandaloneDeriving #-} | |
import Data.Singletons.TH -- singletons 2.4.1 | |
import Data.Kind | |
-- some standard stuff for later examples' sake |
(ns foami.core | |
"FOreign Asynchronous Mechanism Interop" | |
(:require [clojure.core.async :as async])) | |
(def ^:private abandon (doto (async/chan) async/close!)) | |
(def ^:private pending-writes (async/chan)) | |
(defn put! | |
"Tries to put a val into chan, returns either: true if put succeeded, false if chan is |
(ns react-cljs.core | |
(:require-macros [reactjs.macros :refer [pure]]) | |
(:require React [reactjs.core :as r])) | |
(enable-console-print!) | |
(declare render-ui) | |
(defn render-counter [id state cb] | |
(pure state |
(ns react-cljs.core | |
(:require React)) | |
(declare render) | |
(defn handle-change [e] | |
(render {:text (.. e -target -value)})) | |
(defn render [{:keys [text]}] | |
(React/renderComponent |
(defn debounce | |
([c ms] (debounce (chan) c ms)) | |
([c' c ms] | |
(go | |
(loop [start nil loc (<! c)] | |
(if (nil? start) | |
(do | |
(>! c' loc) | |
(recur (js/Date.) nil)) | |
(let [loc (<! c)] |
(ns my.server | |
(:use org.httpkit.server | |
[clojure.string :only [split trim lower-case]]) | |
(:import [org.httpkit.server AsyncChannel])) | |
(defn origin-match? [origin-re req] | |
(if-let [req-origin (get-in req [:headers "origin"])] | |
(re-matches origin-re req-origin))) |
;; ## Changes from cljs.repl.browser | |
;; | |
;; * Multiple concurrent browser-REPLs can be safely used | |
;; * The browser-REPL's HTTP server is now always-on | |
;; * Each browser-REPL session supports a new top-level "entry" URL that | |
;; can be used to easily start the REPL in a browser or other JS runtime | |
;; (i.e. you don't need to have a separate webapp running to initiate the | |
;; browser-REPL connection) | |
;; * The entry (and REPL) URLs are available in slots on the browser-REPL's | |
;; environment, making it trivial to automate browser-REPL sessions |
(defmacro test-> | |
"Takes an expression and a set of test/form pairs. Threads expr (via ->) | |
through each form for which the corresponding test expression (not threaded) is true." | |
[expr | |
& clauses] | |
(assert (even? (count clauses))) | |
(let [g (gensym) | |
pstep (fn [[test step]] `(if ~test (-> ~g ~step) ~g))] | |
`(let [~g ~expr | |
~@(interleave (repeat g) (map pstep (partition 2 clauses)))] |