public
Description: OCaml stdlib replacement with a Haskellish flavour
Homepage:
Clone URL: git://github.com/kig/preludeml.git
commit  f2203f4f461af89ba7fee25f90e93f04ad8440d4
tree    2a0c53f671ab5e871452137f194dca7f84f165da
parent  85aa9166718aecfd9fafaa5839ebe00e71abc82f
name age message
file .gitignore Sun Jan 18 14:38:23 -0800 2009 examples/bounded_space_mandelbrot.ml: showcases... [kig]
file LICENSE Sun Dec 21 22:21:06 -0800 2008 license header in each file, LICENSE [kig]
file OMakefile Sun Jan 18 13:21:44 -0800 2009 examples/blurred_mandelbrot: demonstrating para... [kig]
file OMakeroot Sun Sep 21 07:41:45 -0700 2008 first versions of makefiles [Ilmari Heikkinen]
file README Wed Jan 28 23:20:40 -0800 2009 README: note on backburner status [kig]
file TESTING Sun Jan 18 12:10:07 -0800 2009 is(Execut|Read|Writ)able, tests for chmod and t... [kig]
directory bugs/ Sun Jan 18 12:19:09 -0800 2009 BUG added: [0005] integer averages overflow [kig]
directory examples/ Sun Jan 18 14:38:23 -0800 2009 examples/bounded_space_mandelbrot.ml: showcases... [kig]
directory src/ Mon Feb 16 15:01:15 -0800 2009 withRawCmd: use Unix.close_process so that ther... [kig]
directory test/ Thu Jan 22 16:13:31 -0800 2009 withCd, rm_r, catch, testing utils, tests for r... [kig]
directory tools/ Mon Jan 26 17:45:37 -0800 2009 PreString.findAllIndexes, replaced Boyer-Moore ... [kig]
README
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

Run tests, printing out the test name before running it:
  omake test_verbose

Released 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.


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
-----------
  - working on other stuff, will try to trickle in bug fixes when found, along
    with extra tests
  - done with writing a more complete set of tests for src/prelude.ml


Examples
--------

open Prelude

(* 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>