Skip to content

Instantly share code, notes, and snippets.

@zacque0
zacque0 / main.org
Created April 13, 2022 14:19
GNU Guix and SBCL CFFI

A simple note about how GNU Guix and SBCL CFFI can work together to easily write a wrapper around the shared library.

guix shell sbcl sbcl-cffi sbcl-slime-swank sqlite

Then you need to invoke from shell with preceding LD_LIBRARY_PATH=…:

LD_LIBRARY_PATH="$GUIX_ENVIRONMENT/lib" sbcl --eval '(require :asdf)' --eval '(asdf:load-system :swank)' --eval '(swank:create-server :dont-close t)' --eval '(asdf:load-system :cffi)'
@zacque0
zacque0 / encoder.sml
Last active November 21, 2021 07:34
Standard ML Simple Unicode Codepoint -> UTF-8 Encoder
(* Algorithm based on http://www.herongyang.com/Unicode/UTF-8-UTF-8-Encoding-Algorithm.html *)
exception EncodeError
(* Take a code point as input, and encode it into a list of bytes using UTF-8. *)
fun encodeUTF8 (codepoint : int) : Word.word list =
let val andb = Word.andb
val orb = Word.orb
val >> = Word.>>
val fromInt = Word.fromInt
infix andb orb >>