The last time Hackerfall tried to access this page, it returned a not found error. A cached version of the page is below, or clickhereto continue anyway

So you're learning OCaml... - Edgar Aroutiounian

I try using OCaml for literally everything and that includes going to hackathons, to make this less painful I wrote a library called Podge which helps with simple stuff. I don't claim its a standard library replacement, just a library for getting stuff done. These two code samples assume the file is named code.ml and can be run with utop code.ml

First install with opam:

  1. Reading output of a process
#require "podge"
let () = 
  Podge.Unix.read_process_output "ls -halt" |> List.iter print_endline

The |> just means piping, its piping the output of read_process_output into the input of the partially applied function iter

  1. Reading a file
#require "podge"
let () = 
  Podge.Unix.read_lines "code.ml" |> List.iter print_endline

Similar to 1, this reads all lines of file and gives it to the input of the partially applied function iter.

These are two simple code samples from Podge, check out the repo for other useful modules like: (The README has code examples)

  1. Web for simple HTTP requests and getting data back as JSON,
  2. Xml for querying simple XML documents
  3. ANSITerminal for creating colored shell output
  4. String which is all due to Rudi Grinberg.

Continue reading on hyegar.com