Skip to content

Instantly share code, notes, and snippets.

Schemalessness and types

Attempt to discuss the question: does the tendency towards schemaless data transfer make type systems less relevant? The question came up in a conversation on twitter.

Short answer: No. Data transfer, data serialization, schemas, and type systems are all independent from each other.

Schemaless means schema-delayed

Given a datastore with no schema, what can you know about the shape and meaning of the data stored in it? Barely anything. You may know that valid values can be represented using some particular serialization format, such as JSON. Maybe you even know that values can only be JSON objects, as opposed to arrays or primitive values. Those are constraints that a system may apply to data. (In my tweet I called that a "meta-schema", but I realize that that's not actually a fitting term.) They allow for concrete expectations about the shape of the data that can possibly be stored in and retrieved from the system.

data Type = T String
| Type :-> Type -- infix! (must start with `:`)
deriving Show
int = T "Int"
main = do
print (int :-> int)
-- T "Int" :-> T "Int"
print ((int :-> int) :-> int :-> int)
// This technique is very old. It's based on Church pairs.
// http://en.wikipedia.org/wiki/Church_encoding#Church_pairs
cons = function (a, b) {
return function (f) {
return f(a, b);
}
}
first = function (a, b) {
@fronx
fronx / find.js
Last active August 29, 2015 13:57
function find (ary, fn) {
var match = undefined;
for (var i = 0; !match && i < ary.length; i++)
if (fn(ary[i])) match = ary[i];
return match;
}
find([1,2,3,4], function(x) { return x > 2; })
@fronx
fronx / ping log
Created May 28, 2014 08:16
I left the console open over night and you can see how the network connection gets dropped and ping times go up.
~ $ ping 92.225.156.181
PING 92.225.156.181 (92.225.156.181): 56 data bytes
64 bytes from 92.225.156.181: icmp_seq=0 ttl=64 time=4.691 ms
64 bytes from 92.225.156.181: icmp_seq=1 ttl=64 time=2.607 ms
64 bytes from 92.225.156.181: icmp_seq=2 ttl=64 time=2.581 ms
64 bytes from 92.225.156.181: icmp_seq=3 ttl=64 time=2.901 ms
64 bytes from 92.225.156.181: icmp_seq=4 ttl=64 time=5.160 ms
64 bytes from 92.225.156.181: icmp_seq=5 ttl=64 time=2.768 ms
64 bytes from 92.225.156.181: icmp_seq=6 ttl=64 time=2.600 ms
64 bytes from 92.225.156.181: icmp_seq=7 ttl=64 time=2.691 ms
module NestedLists where
data NestedList a = Nest [NestedList a] | Item a
deriving Show
nestedList = Nest [ Item 1
, Item 2
, Nest [ Item 3
, Nest [ Item 4
, Item 5
@fronx
fronx / Foo.hs
Last active August 29, 2015 14:03
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
import Prelude hiding ((*))
import qualified Prelude as P
class Mul a b c | a b -> c where
(*) :: a -> b -> c
{-# LANGUAGE FlexibleInstances #-}
module Unityped where
import Prelude hiding ((*), (==), (++), print, show, concat)
import qualified Prelude as P
import Data.List hiding ((++))
data D = B Bool
| N Int
@fronx
fronx / ShowFn.hs
Last active August 29, 2015 14:04
instance (Num a, Show a) => Show (FnShow a) where
show (FnShow1 fnStr fn) =
concat (map showFn [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
where showFn n = fnStr ++ " " ++ show n ++ " = " ++ show (fn n) ++ "\n"
show (FnShow2 fnStr fn) =
concat (map showOp [0, 1, 2, 3])
where showOp n = show (FnShow1 (fnStr ++ " " ++ show n) (fn n))
show (FnShow3 fnStr fn) =
concat (map showOp [0, 1, 2, 3])
where showOp n = show (FnShow2 (fnStr ++ " " ++ show n) (fn n))

CoderDojo Berlin

CoderDojo ist ein Club für Kinder und Jugendliche im Alter von 5 bis 17 Jahren, die programmieren lernen und Spaß haben wollen. Freiwillige Mentor_innen helfen den Kindern, ihre Ideen umzusetzen. Dabei lernen sie spielerisch die Grundlagen des Programmierens. Und auch wenn sie die Grundlagen schon kennen, gibt es noch mehr als genug neue Konzepte zu lernen.

Wann / Wo

Wir treffen uns einmal im Monat, jedesmal woanders. Den nächsten Termin und Ort findest du immer hier: http://bit.ly/coderdojoberlin

Ablauf