Skip to content

Instantly share code, notes, and snippets.

View strager's full-sized avatar

strager strager

View GitHub Profile
Undefined symbols for architecture x86_64:
"_b_deserialize_size_t", referenced from:
DatabaseInMemory::deserialize(unsigned long (*)(char*, unsigned long, void*), void*) in DatabaseInMemory.cc.o
"_b_deserialize_sized", referenced from:
std::__1::unique_ptr<UnresolvedQuestionAnswer, std::__1::default_delete<UnresolvedQuestionAnswer> > b_deserialize_sized<UnresolvedQuestionAnswer>(unsigned long (*)(bool*, unsigned long (*)(char*, unsigned long, void*), void*), unsigned long (*)(char*, unsigned long, void*), void*) in DatabaseInMemory.cc.o
std::__1::unique_ptr<UnresolvedDependency, std::__1::default_delete<UnresolvedDependency> > b_deserialize_sized<UnresolvedDependency>(unsigned long (*)(bool*, unsigned long (*)(char*, unsigned long, void*), void*), unsigned long (*)(char*, unsigned long, void*), void*) in DatabaseInMemory.cc.o
"_b_serialize_size_t", referenced from:
serialize_uuid(B_UUID, void (*)(char const*, unsigned long, void*), void*) in DatabaseInMemory.cc.o
DatabaseIn
for (auto i = begin; i != end; ++i) {
qas.erase(i);
}
{-# LANGUAGE ExistentialQuantification #-}
import Data.Typeable (Typeable, TypeRep, typeOf)
import Unsafe.Coerce (unsafeCoerce)
data Magic = forall a. Magic
(a -> a -> Bool)
TypeRep
a
def safeHead([a] -> a?):
->xs
if (xs isEmpty):
none
else:
xs head some
def find([a] (a -> Bool) -> a?):
filter safeHead
@strager
strager / brainfuck.ktn
Created August 29, 2013 07:28
A Brainfuck interpreter, written in the Kitten programming language (http://kittenlang.org/)
type Instruction Char
type Program [Instruction]
type Memory [Int]
////////////////////////////////////////////////////////////
// Configuration
def debug: false
// Some programs want 0; some want -1.
@strager
strager / kitten-ssa.md
Created October 6, 2013 06:32
Kitten SSA form (WIP)

Kitten SSA form

By example

Naming conventions:

  • c# is a lambda extracted to be top-level.
  • l#_x is a local named x in the source code.
  • p# is a function parameter.
  • s# is a data stack variable.
@strager
strager / hello-world.ktn.ssa
Last active December 24, 2015 20:29
Hello World in Kitten SSA form
// NOTE: apply is broken!
// NOTE: arity is incorrect.
// NOTE: parameters are not yet explicit.
!= (0 -> 0):
s0 <- neInt p0 p1
return s0
@strager
strager / html.ktn
Created October 15, 2013 05:43
HTML example written in Kitten (kittenlang.org).
////////////////////////////////////////////////////////////
// Core.
type Node (Element | [Char])
type Element ([Char] & [Attribute] & [Node])
type Attribute ([Char] & [Char])
def element([Char] [[Char] & [Char]] [Node] -> Element):
->{name attributes children}
(name, attributes {to Attribute} map, children) to Element
forall _0 _1 . (t0 [t1 (type var a)] [Char] -> t0 Int + ())
("unify",t4,t3)
("declare",_4,t3)
("unify",(t4 -> t3 t2 (type of x) + ()),(t6 -> t6 t5 + ()))
("declare",_2,t5)
("declare",_3,t6)
("unify",t10,t7)
("declare",_10,t7)
("unify",t7 [t5],t8 [t9] [t9])
("declare",_5,t9)
@strager
strager / effects.md
Created October 22, 2013 02:54
Notes and ideas about effects

Effects

  • Ordered

    The ordering of two operations is significant (outside of data dependencies). For example, writing to a file and removing a file are order-dependent.

  • Mutating

    An operation is observable to non-deterministic operations. Mutations are non-reversible after a non-deterministic operation depends upon the mutation.