

Twitter search in o'caml - sant0sk1
http://gist.github.com/107562

======
bumbledraven
I'm having trouble building this. I installed ocaml-3.11.0 and a bunch of
ocaml packages (including libjson-wheel-ocaml-dev) on my Debian Squeeze
system, but when I run the build command from the source file, I get:
ocamlfind: Package `json-static' not found

Then I downloaded json-static from <http://martin.jambon.free.fr/json-
static.html> and, following the README, typed 'make' in that directory, which
yielded: File "pa_json_static.ml", line 123, characters 14-22: While expanding
quotation "ctyp" in a position of "expr": Parse error: [ctyp] expected after
"(" (in [ctyp]) File "pa_json_static.ml", line 1, characters 0-1: Error:
Preprocessor error

Not sure where to go from here. I'm quite used to following the maze of
uninstalled dependenices when building software written in C or Perl, but I'm
new to OCaml.

------
mshafrir
I've never seen OCaml code before. Can someone explain this part of the code?

    
    
      (* sorry, can't resist some pattern matching. sweet sickly  arcane sugar. *)
      let _ =
          match Sys.argv with
            [| _; q |] -> display (search q)
          | _ -> failwith "Usage: twittersearch \"search terms\""

~~~
mrkurt
I don't know if you're familiar with pattern matching in general, but you can
think of it as a switch-on-crack.

The jist of that code is: we're going to look at Sys.argv, which is a list. If
it's a two element list, ignore the first element (underscore as "hole") and
pass the second element to search, then display the result.

If it's anything else, fail with a nice message.

~~~
mrkurt
Oh, silentbicycle is right. [| ... |] is array syntax, rather than a list.

