Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > 0d83ec22f69e435b33ac31c9ec4ee1aa > files > 7

ocaml-preludeml-devel-0.1-0.14.20090113.fc13.i686.rpm

Prelude.ml: an OCaml stdlib replacement with a Haskellish flavour.


Requirements:
  pcre, netstring (ocaml-net)
  oUnit for the tests

Compile:
  omake

Run tests:
  omake test

Licensed under the MIT license.


Features
--------
A more consistent interface across lists, arrays, strings and bytestrings.
Bytestrings, strings wrapped in char_of_int / int_of_char.
Parallel combinators for (1D) Bigarrays and the aforementioned collections.
Shell command utilities.
Filesystem utilities.
Path utilities.
IO utilities.
User/group utilities.
Time utilities.
Function combinators, option combinators, exception combinators,
tuple combinators, comparisons, conversions, recursions, floats, ints,
hashes, maps, unfolds, folds, scans, spans, slices and subs.

Everything in a single module for a very scripting language -like experience.


There are two versions here, a (currently) more fully tested prelude.ml in this
directory, and a rewritten src/prelude.ml which has more stuff and a lower
tests/functions-ratio.

I have aimed to keep the list functions tail-recursive, the trade-off between a
speed loss from reversing lists and having support for arbitrary length lists
weighing towards the latter in my scales.

Some functions are implemented in a very combinatorial wanking -fashion and
should be rewritten for speed and clarity. Alternatively I could say that
they're good eta/beta-reduction tests for the compiler.


Latest news
-----------
  - 50% done with writing a more complete set of tests for src/prelude.ml
  - added the unit testing framework
  - merged all the files in src/ into a single src/prelude.ml


Examples
--------

(* my last modified file in /tmp *)
lsFull "/tmp" |> filter (eq (currentUid ()) @. fileUid) |> maximumBy mtime

(* concatenate files a, b and c into d *)
concatFiles "d" ["a"; "b"; "c"]

(* grep `find' output for AAC files *)
readCmd ["find"; "music"] |> lines |> filter (xmatch "\\.m4[ap]$")

(* fill a 100MB Bigarray with coreCount() parallel processes *)
bapinit Bigarray.char (fun i -> chr (Unix.getpid() mod 256)) (int 10e8)

(* blend two bytestrings together in parallel *)
bpzipWith average2 s1 s2

(* the speed gains here are likely non-existent, as forking and marshalling
   overheads dominate the compute-poor blending function *)

(* or written out as a parallel init that reads from the closure *)
bpinit (fun i -> ((buget s1 i) + (buget s2 i)) / 2) (min (blen s1) (blen s2))


As you may notice, the different collections have different prefixes for the
function names. List functions have no prefix, Array functions have 'a',
String functions have 's', Bytestring functions have 'b' and Bigarray
functions have 'ba'. Additionally, float functions use a 'f' suffix,
e.g. sumf [1.0; 2.0] vs. sum [1; 2].

There are PreList, PreArray, PreString and Bytestring modules for the
collections as well, but do note that they take some liberties with the
argument orders of some functions in the name of easier composition,
e.g. Array.init : int -> (int -> 'a) -> 'a array
 vs. PreArray.init : (int -> 'a) -> int -> 'a array.

 in map (PreArray.init id) (10--15)
and map (fun i -> Array.init i id) (10--15)


Development
-----------
http://www.github.com/kig/preludeml/tree/master

Contact
-------
Ilmari Heikkinen <ilmari.heikkinen@gmail.com>