A disparate collection of experimental data structures
Find a file
2015-11-26 22:04:07 +02:00
examples Tuple readme + example 2015-11-26 21:55:37 +02:00
src White space hunting in pack 2015-11-26 21:30:51 +02:00
.gitignore Separation from tensority 2015-10-09 10:47:51 +02:00
.merlin Separation from tensority 2015-10-09 10:47:51 +02:00
_oasis Updated project files 2015-11-26 22:04:07 +02:00
_tags Updated project files 2015-11-26 22:04:07 +02:00
LICENCE Tuple readme + example 2015-11-26 21:55:37 +02:00
opam Updated project files 2015-11-26 22:04:07 +02:00
README.md Updated project files 2015-11-26 22:04:07 +02:00

Oceti is a disparate collections of experimental data structures, all relying on some form of type-level computation. They are mainly intended as brainteasers or unreliable prototypes. Some of the most interesting examples are the reimplementation of tuples as immutable heteregenous array in src/tuple.ml or composable ranges in src/range.ml.

Tuple

As an example, the tuple module allow you to define a tuple with

        open Tuple
        open Index.Defs (* definitions of _1, ..., _10 *)
        let x = tuple _3 1 "hi" (+)

Elements of the newly defined tuple can be then accessed using the bigarray index operator .{}:

  let two = 1 + x.{_0} (* or 1 + get _0 x *)

Note that the index starts at 0. Unfortunately, the contrived construction used to define these tuple types disallows pattern matching. However, having an unified tuple family has some advantages:

  let y = tuple _2 [] 3

  let f x y =
      let ( % ) = x.{_2} in
      x.{_0} % y.{_1}

  let four = f x y

These unified tuples are immutable. One way to construct new tuple is to use map to apply a given function f to a specific element:

  let w = map _1 ( fun s -> s ^ "erophant" ) x
  let hierophant = w.{_1}

Another possibility is to append two tuples together

 let x_y = append _2 x y