- architecture was always:
- box - box - cylinder
- then layers:
- ideally:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn passes-monoid-props | |
[f id a b c] | |
(and (= (f (f a b) c) (f a (f b c))) ;; associativity | |
(= (f a id) a) ;; identity element | |
(= (f id a) a))) | |
(defspec plus-zero-are-monoid 100 | |
(prop/for-all [[a b c] (gen/vector gen/int 3)] | |
(passes-monoid-props + 0 a b c))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns foami.core | |
"FOreign Asynchronous Mechanism Interop" | |
(:require [clojure.core.async :as async])) | |
(defn put! | |
"Takes a `ch`, a `msg`, a single arg function that when passed `true` enables backpressure | |
and when passed `false` disables it, and a no-arg function which, when invoked, closes the | |
upstream source." | |
[ch msg backpressure! close!] | |
(let [status (atom :sending] |
At DICOM Grid, we recently made the decision to use Haskell for some of our newer projects, mostly small, independent web services. This isn't the first time I've had the opportunity to use Haskell at work - I had previously used Haskell to write tools to automate some processes like generation of documentation for TypeScript code - but this is the first time we will be deploying Haskell code into production.
Over the past few months, I have been working on two Haskell services:
- A reimplementation of an existing socket.io service, previously written for NodeJS using TypeScript.
- A new service, which would interact with third-party components using standard data formats from the medical industry.
I will write here mostly about the first project, since it is a self-contained project which provides a good example of the power of Haskell. Moreover, the proces
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns fancy-defn | |
(:require [schema.core :as s] | |
[clojure.core.typed :as t] | |
[circle.schema-typer :as st])) | |
;; Schemas created with s/defn end up using this. | |
(defmethod st/convert schema.core.One [schema] | |
(assert (= false (:optional? schema))) ;; No support for optional arguments yet. | |
(st/convert (:schema schema))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns router | |
#+cljs (:require-macros [cljs.core.match.macros :refer [match]]) | |
(:require [domkm.silk :as silk] | |
[clojure.string :as str] | |
#+clj [content :as content] | |
#+clj [drivers.email :as email] | |
#+clj [clojure.core.match :refer [match]] | |
#+clj [compojure.core :as compojure :refer [defroutes GET POST PUT DELETE]] | |
#+clj [compojure.route :as route] | |
#+clj [com.stuartsierra.component :as component] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE GADTs, RankNTypes #-} | |
import Control.Applicative | |
import Control.Category | |
import Data.List (foldl') | |
import Data.Profunctor | |
import Prelude hiding ((.), id) | |
-- | Explicit state-passing Moore machine | |
data Moore i o where |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# List of all the valid pdf URLs ever posted to the #Clojure IRC channel. | |
# | |
# Many of them are interesting CS papers others are not that useful. What I've done: | |
# | |
# 1. crawled an IRC history archive for the channel | |
# 2. extract pdf list in a file with: grep -riIohE 'https?://[^[:space:]]+pdf' * > pdf-links.txt | |
# 3. remove dupes: cat pdf-links.txt | sort | uniq > pdf-links-uniq.txt | |
# 4. filter only HTTP 200: cat pdf-links-uniq.txt | xargs curl -o /dev/null --connect-timeout 2 --silent --head --write-out '%{http_code} %{url_effective}\n' | grep "^200" > valid-pdf-links.txt | |
# | |
# Now your choice to download them all or not. If you want, use: cat valid-pdf-links.txt | awk '{print $2}' | xargs wget |