Skip to content

Instantly share code, notes, and snippets.

@ytomino
ytomino / dt.nim
Created January 12, 2016 22:16
Trying dependent types in nim
type Cell[T] = ref object
car: T
cdr: Cell[T]
type List[T, N] = distinct Cell[T]
proc makeNil[T]: List[T, range[0..0]] = nil
proc makeCons[T, N](car: T; cdr: List[T, N]): auto =
type N1 = range[0..high(N)+1]
@ytomino
ytomino / c-bits-mman.ads
Created June 15, 2021 11:29
Boehm GC in x86_64-linux-gnu
-- This file is translated by "headmaster" version 0.30-e83b81d (devel).
-- The original C header's license should be applied to this file.
-- All conditional-directives are expanded for the exclusive use of your
-- environment, it is not recommended to commit this file to any repository.
-------------------------------------------------------------------------------
package C.bits.mman is
pragma Preelaborate;
MAP_32BIT : constant := 64;
MAP_DENYWRITE : constant := 2048;
MAP_EXECUTABLE : constant := 4096;
@ytomino
ytomino / c-alloca.ads
Last active June 10, 2021 15:27
libyaml in x86_64-linux-gnu
-- This file is translated by "headmaster" version 0.30-e83b81d (devel).
-- The original C header's license should be applied to this file.
-- All conditional-directives are expanded for the exclusive use of your
-- environment, it is not recommended to commit this file to any repository.
-------------------------------------------------------------------------------
with C.stddef;
package C.alloca is
pragma Preelaborate;
function alloca (size : stddef.size_t) return void_ptr;
pragma Import (C, alloca, "alloca");
@ytomino
ytomino / c-alloca.ads
Last active June 10, 2021 15:03
libxml2 in x86_64-linux-gnu
-- This file is translated by "headmaster" version 0.30-e83b81d (devel).
-- The original C header's license should be applied to this file.
-- All conditional-directives are expanded for the exclusive use of your
-- environment, it is not recommended to commit this file to any repository.
-------------------------------------------------------------------------------
with C.stddef;
package C.alloca is
pragma Preelaborate;
function alloca (size : stddef.size_t) return void_ptr;
pragma Import (C, alloca, "alloca");
@ytomino
ytomino / magicmoduletype.ml
Created April 25, 2021 01:44
GADTの型パラメータをObj.magicで一致させることで無関係な後続の式の型チェックを回避できる
module type T1 = sig
type t (* any abstract type *)
val one: t
end;;
module M1: T1 = Int;;
type 'a repr = C1: M1.t repr (* GADT is needed *)
let one: string =
@ytomino
ytomino / c-alloca.ads
Last active November 5, 2020 04:03
i686-apple-darwin10
-- This file is translated by "headmaster" version 0.30-611630a (devel).
-- The original C header's license should be applied to this file.
-- All conditional-directives are expanded for the exclusive use of your
-- environment, it is not recommended to commit this file to any repository.
-------------------------------------------------------------------------------
with C.stddef;
package C.alloca is
pragma Preelaborate;
function alloca (a1 : stddef.size_t) return void_ptr;
pragma Import (C, alloca, "alloca");
@ytomino
ytomino / c-alloca.ads
Last active November 4, 2020 23:53
x86_64-apple-darwin13
-- This file is translated by "headmaster" version 0.30-18d0286 (devel).
-- The original C header's license should be applied to this file.
-- All conditional-directives are expanded for the exclusive use of your
-- environment, it is not recommended to commit this file to any repository.
-------------------------------------------------------------------------------
with C.stddef;
package C.alloca is
pragma Preelaborate;
function alloca (a1 : stddef.size_t) return void_ptr;
pragma Import (C, alloca, "alloca");
@ytomino
ytomino / c-alloca.ads
Last active November 4, 2020 23:52
x86_64-apple-darwin12
-- This file is translated by "headmaster" version 0.30-18d0286 (devel).
-- The original C header's license should be applied to this file.
-- All conditional-directives are expanded for the exclusive use of your
-- environment, it is not recommended to commit this file to any repository.
-------------------------------------------------------------------------------
with C.stddef;
package C.alloca is
pragma Preelaborate;
function alloca (a1 : stddef.size_t) return void_ptr;
pragma Import (C, alloca, "alloca");
@ytomino
ytomino / c-alloca.ads
Last active November 4, 2020 23:52
x86_64-apple-darwin11
-- This file is translated by "headmaster" version 0.30-18d0286 (devel).
-- The original C header's license should be applied to this file.
-- All conditional-directives are expanded for the exclusive use of your
-- environment, it is not recommended to commit this file to any repository.
-------------------------------------------------------------------------------
with C.stddef;
package C.alloca is
pragma Preelaborate;
function alloca (a1 : stddef.size_t) return void_ptr;
pragma Import (C, alloca, "alloca");
@ytomino
ytomino / c-alloca.ads
Last active November 4, 2020 23:51
x86_64-apple-darwin10
-- This file is translated by "headmaster" version 0.30-18d0286 (devel).
-- The original C header's license should be applied to this file.
-- All conditional-directives are expanded for the exclusive use of your
-- environment, it is not recommended to commit this file to any repository.
-------------------------------------------------------------------------------
with C.stddef;
package C.alloca is
pragma Preelaborate;
function alloca (a1 : stddef.size_t) return void_ptr;
pragma Import (C, alloca, "alloca");