I hereby claim:
- I am noidi on github.
- I am noidi (https://keybase.io/noidi) on keybase.
- I have a public key whose fingerprint is 8B98 202B 7E91 F525 BA56 422D 1EE1 0668 A212 782E
To claim this, I am signing this object:
;; I hope this example illustrates why I think the types that Clojure | |
;; programmers use are hard to represent with the type systems I've seen in | |
;; other languages. I have only a very superficial knowledge of type theory, so | |
;; I may well be mixing terms or even spouting complete nonsense. Apologies in | |
;; advance! | |
;; Idiomatic Clojure code tends to use very few custom types, and instead | |
;; represents most data as a composition of built-in types like maps, vectors, | |
;; and sets. For example, instead of a Person type you might use a map like the | |
;; following: |
I hereby claim:
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
file 'm_sdl.so' => 'm_sdl.c' do | |
sh 'gcc -shared -fpic -o m_sdl.so -Wall -Werror -std=gnu99 m_sdl.c -I/opt/gtm -O3 $(sdl2-config --cflags --libs)' | |
end | |
file 'trumps.o' => 'trumps.m' do | |
sh 'mumps trumps.m' | |
end | |
task :run => ['trumps.o', 'm_sdl.so'] do | |
sh 'env GTMXC_sdl=m_sdl.xc mumps -run trumps' |
;; [09:46] < aphyr> hullo | |
;; [09:54] < aphyr> I'm trying to type an expression like [f g h], where (f (g (h nil))) is valid. | |
;; [09:55] < aphyr> e.g. something I could apply (comp) to | |
;; [09:55] < aphyr> But I'm having trouble figuring out how to enforce that each fn should take the next fn's output type | |
(ns cttest.core | |
(:require [clojure.core.typed :as t])) | |
(t/ann foo (t/All [a b c] | |
[[b -> c] [a -> b] [nil -> a] -> c])) |
;;; Changes: | |
;;; - Annotate the parameter of the lambda given to filter. This was the cause of the error. | |
;;; - Change the last parameter of lookup-by from Seq to Seqable to allow it to work with vectors. | |
;;; - Replace (IFn [a -> b]) with [a -> b]. They're equivalent. | |
(t/ann lookup-by (t/All [a b] | |
[b [a -> b] (t/Option (t/Seqable a)) -> (t/Option a)])) | |
(defn lookup-by | |
"Convenience filter. Returns the first item in coll where (= value (lookup-fn item))" |
(ns cljs-hello.hello | |
(:require-macros [cljs-hello.macros :as m])) | |
(defn make-world [] | |
(let [geometry (THREE.CubeGeometry. 200 200 200) | |
material (THREE.MeshBasicMaterial. (js* "{color: 0xff0000, | |
wireframe: true}")) | |
mesh (THREE.Mesh. geometry material) | |
scene (doto (THREE.Scene.) | |
(.add mesh)) |
tl;dr: Solving a very specific problem using FP tends to produce a very general solution that's applicable to a wide range of problems.
Let's start with some Java code that we'll simplify using functional programming.
class Department {
Employee getYoungestEmployee() {
if (employees.isEmpty()) return null;
git clone git://github.com/sjl/caves/
cd caves
Start a REPL:
lein repl
It'll grab the deps and start fine. Cool. Close out of it.
Now edit the name of one of the methods in a protocol (and all the things that use it, of course):
# HG changeset patch | |
# Parent cc08f20788db64c79c232265909150ee3677493a | |
Use the JAR from tomighty.org | |
diff -r cc08f20788db PKGBUILD | |
--- a/PKGBUILD Thu Dec 08 17:48:11 2011 +0200 | |
+++ b/PKGBUILD Thu Dec 08 18:09:05 2011 +0200 | |
@@ -8,10 +8,13 @@ | |
url="http://www.tomighty.org/" | |
license=('Apache') |