Skip to content

Instantly share code, notes, and snippets.

View TFlexSoom's full-sized avatar
🃏
Playing Magic

Tristan Hilbert TFlexSoom

🃏
Playing Magic
View GitHub Profile

I've written a few FFI bindings that I use for my games:

  • cute-c2-hs and cute-sound-hs - These are bindings to single-header C libraries. The header itself is included in the git repo.
  • sdl-gpu-hs - This C/C++ library is not included in the repo. It is declared as a dependency via pkgconfig-depends in the .cabal file.

Some general tips I've picked up:

  • hsc2hs works great. It doesn't do much for you, but it give you a nice way to create safe bindings.
  • Try to make your binding as "literal" as possible. You will end up with a lot of boilerplate, but it' a good starting point.
    • You can embed any C function in Haskell with basically 0 overhead by using raw Ptrs and primitives.
  • After you have the verbatim C binding, you can build higher-level bindings. I like to make "simple" bindings next - they hide the Ptr allocation and poke-ing with a litt
@kyleburton
kyleburton / bot-verbs.txt
Last active August 19, 2024 23:02
The list of 'bot-verbs' that we give to new team members.
Philosophical:
* writing lines of code is one of the least valuable things I can do
* cultivate your impatience
* reject the status quo, unless we can re-derive it from first-principles
* engineers imprint on the first languages (techniuqes, frameworks or technology) that we find success with (unconsciously seen as caregivers, which we defend w/o always knowing why)
* we tend to overvalue the familiar/known; we tend to undervalue the unfamiliar/unknown, this interferes with our receptiveness to new ideas and personal growth
* we're 90% composed of bad habits; many of our best habits become bad as time passes; this allows us to filter for the fundamental; the great
* make doing the right thing easier than any other thing, or we will fail to achieve greatness, or break bad habits
* be conscious, be intentional
* "is this the highest we can aim?" (I prefer this over "is this the best we can do", the former is aspirational, the latter is judgemental)
@jxson
jxson / README.md
Created February 10, 2012 00:18
README.md template

Synopsis

At the top of the file there should be a short introduction and/ or overview that explains what the project is. This description should match descriptions added for package managers (Gemspec, package.json, etc.)

Code Example

Show what the library does as concisely as possible, developers should be able to figure out how your project solves their problem by looking at the code example. Make sure the API you are showing off is obvious, and that your code is short and concise.

Motivation